Destiny8Chicken Posted February 13, 2015 Share Posted February 13, 2015 So I'm trying to have a character whose max health is equal to his current sanity level plus 100, here's the code: inst.components.health:SetMaxHealth(100+(inst.components.sanity.current)) However the game seems to take (inst.components.sanity.current) as a fixed number (200 specifically) which doesn't change, or at least this is what I can assume as the max health seems to remain at 300. Could anyone give a novice modder some advice on how to fix this please? Thank you Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/ Share on other sites More sharing options...
DarkXero Posted February 13, 2015 Share Posted February 13, 2015 If you only have that line in your master_postinit, then if will only get executed once.And that once is when you start your world and the character gets created. You will have to make that line a periodic task or tie it to a component somehow, like:inst:ListenForEvent("sanitydelta", function(inst, data) inst.components.health:SetMaxHealth(100+(inst.components.sanity.current)) inst.components.health:DoDelta(0)end) Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-612827 Share on other sites More sharing options...
rezecib Posted February 13, 2015 Share Posted February 13, 2015 I think you might also need to have it rescale the current health based on its percentage before adjustment:inst:ListenForEvent("sanitydelta", function(inst, data) local percent = inst.components.health:GetPercent() inst.components.health:SetMaxHealth(100+(inst.components.sanity.current)) inst.components.health:SetPercent(percent)end) Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-612858 Share on other sites More sharing options...
Destiny8Chicken Posted February 14, 2015 Author Share Posted February 14, 2015 ok thank you for the responses I'll try that, does that code still go in the master position just to check? Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-612972 Share on other sites More sharing options...
Destiny8Chicken Posted February 14, 2015 Author Share Posted February 14, 2015 never mind on where it goes, I figured it out, but apparently I broke something unrelated and I have no idea what I did or how to fix it, all I know is that the screen mentioned my saveslot portraits, if you need the log I am happy to provide it but please tell me how to locate it in the Don't Starve Together Beta folder, thank you for all your help I really appreciate it and hope I can get this stuff working and up on the steam workshop soon Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-612984 Share on other sites More sharing options...
Destiny8Chicken Posted February 14, 2015 Author Share Posted February 14, 2015 ok so as it turns out I broke the mod by trying to erase the start inventory (as the mod (the medic mod) which I'm using as a base contains 10 honey poultices as the start inventory), so how would I clear the start inventory without breaking the mod? Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613013 Share on other sites More sharing options...
Destiny8Chicken Posted February 14, 2015 Author Share Posted February 14, 2015 (edited) also even now that I've "fixed" the mod, it only works some of the time. The warning message says../mods/Crona Gorgon without ragnarok/images/saveslot_portraits/cronag.xmlLUA ERROR stack traceback: scripts/widgets/image.lua(30,1) in function 'SetTexture' scripts/screens/servercreationscreen.lua(638,1) in function 'MakeSaveTile' scripts/screens/servercreationscreen.lua(601,1) in function 'RefreshLoadTitles' scripts/screens/servercreationscreen.lua(123,1) in function '_ctor' scripts/class.lua(181,1) in function 'ServerCreationScreen' scripts/screens/serverlistingscreen.lua(1190,1) in function 'cb' scripts/frontend.lua(447,1) in function 'DoFadingUpdate' Edited February 14, 2015 by Destiny8Chicken Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613016 Share on other sites More sharing options...
Destiny8Chicken Posted February 14, 2015 Author Share Posted February 14, 2015 whilst I'm sure you could work this out from the code anyway as you seem to be very knowledgeable coding, everything seems to work unless I try to host a server and I'm using my mod Character (Crona) in one of the save slots Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613018 Share on other sites More sharing options...
rezecib Posted February 14, 2015 Share Posted February 14, 2015 @Destiny8Chicken, Do you have saveslot portrait art? Did this work before? Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613022 Share on other sites More sharing options...
Destiny8Chicken Posted February 14, 2015 Author Share Posted February 14, 2015 Yes it does have saveslot portrait art and I'm pretty sure it worked before, however I think I'm just gonna start over (I did some things to give Crona a custom weapon and everything went to hell), thanks for all your help Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613025 Share on other sites More sharing options...
Pyrobolser Posted February 14, 2015 Share Posted February 14, 2015 I think it is a problem with your assets. Or something related to wrong image name, or wrong call of an image.Maybe you changed the name of your character, but not the name of the images, or something like that. Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613099 Share on other sites More sharing options...
Goat Slice Posted February 14, 2015 Share Posted February 14, 2015 ok so as it turns out I broke the mod by trying to erase the start inventory (as the mod (the medic mod) which I'm using as a base contains 10 honey poultices as the start inventory), so how would I clear the start inventory without breaking the mod? I'm not sure if you have solved this problem or not, but all you have to do to clear the start inventory on my medic mod is to clear the 10 ' "bandage", ' keywords that come after local start_inv = { in the medic.lua Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613144 Share on other sites More sharing options...
Destiny8Chicken Posted February 15, 2015 Author Share Posted February 15, 2015 ah ok thanks CheeseNuggets, just to ask how would you set the start_inv to find something from the mods' folder rather than the Don't Starve Together Beta prefabs? Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613276 Share on other sites More sharing options...
Goat Slice Posted February 15, 2015 Share Posted February 15, 2015 ah ok thanks CheeseNuggets, just to ask how would you set the start_inv to find something from the mods' folder rather than the Don't Starve Together Beta prefabs? In your character.lua you should do something like this" local prefabs = { "hat_bowler" } local start_inv = { "hat_bowler" } "You of course would need your item or items own .lua (for me it's hat_bowler.lua) To be there first. The last line of the character.lua should also be something like" return MakePlayerCharacter("wade", prefabs, assets, common_postinit, master_postinit, start_inv) "(you would have to replace "wade" with your own character's name.)Did that help? Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613366 Share on other sites More sharing options...
Destiny8Chicken Posted February 15, 2015 Author Share Posted February 15, 2015 yep it does work however it looks like my weapon needs a bit more work before I give it to my character, but other than the custom weapon everything is pretty much working so thanks! Now I just need to wait for my modding partner to finish the artwork and boom, we're done Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613397 Share on other sites More sharing options...
Destiny8Chicken Posted February 15, 2015 Author Share Posted February 15, 2015 are there any tutorials on how to create custom weapons (does gunpowder count as a weapon?) for DST(B)? Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613398 Share on other sites More sharing options...
polygone Posted February 16, 2015 Share Posted February 16, 2015 For creating a custom weapon you could use this tutorial: (I can't paste into the forums unless it's in a code box welp)It's what I've used to get mine working. The only thing you'd have to do differently is if you want it to actually deal damage/have a durability you'd use something like these: inst:AddComponent("weapon") inst.components.weapon:SetDamage(TUNING.SPEAR_DAMAGE) inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(TUNING.SPEAR_USES) inst.components.finiteuses:SetUses(TUNING.SPEAR_USES)Also I believe gunpowder just counts as an item since you can't actually equip it. Link to comment https://forums.kleientertainment.com/forums/topic/50910-how-to-make-current-sanity-affect-max-health/#findComment-613441 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now