Jump to content

Recommended Posts

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

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)

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)

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 :)

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?

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.xml

LUA 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 by Destiny8Chicken

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

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

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

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?

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

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...