BeeChoc Posted November 11, 2024 Share Posted November 11, 2024 (edited) beechoc.rarHello everyone, I have a little problem with my character mod. Everything worked great, the mod had no problems with other mods everything worked. I wanted to add 2 server mods and suddenly nothing works, even if I remove the new mods. It told me twice about a line in my modmain.lua saying that a value was nil (nil value) but this line has not changed so I don't understand... beechoc.rar Edited November 11, 2024 by BeeChoc Link to comment https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/ Share on other sites More sharing options...
Baguettes Posted November 11, 2024 Share Posted November 11, 2024 Please put your crash log here too, that is so we can assess the problem at hand. But right now, I could make a few guesses seeing how you mentioned modmain: GetPlayer is deprecated in DST. That, and you certainly cannot access the player instance inside your taffy postinit. Also, you may want to move the postinit functions down below the rest of the code. Try attaching OnEatFn via the eater component to yourself and check for taffy eaten, then use Sanity DoDelta for the extra sanity bonus. This should apply in the same frame, so it'd appear as if you gained +20 instead of +15. Link to comment https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/#findComment-1756703 Share on other sites More sharing options...
yanecc Posted November 11, 2024 Share Posted November 11, 2024 In the modmain.lua. REPLACE GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("taffy", function(inst) if GetPlayer().prefab == "beechoc" then inst.components.edible.sanityvalue = 20 end end) WITH AddPrefabPostInit("taffy", function(inst) if inst.components.edible ~= nil then inst.components.edible.getsanityfn = function(inst, eater) return eater.prefab == "beechoc" and 20 end end end) 1 Link to comment https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/#findComment-1756707 Share on other sites More sharing options...
Baguettes Posted November 11, 2024 Share Posted November 11, 2024 3 minutes ago, yanecc said: In the modmain.lua. REPLACE GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("taffy", function(inst) if GetPlayer().prefab == "beechoc" then inst.components.edible.sanityvalue = 20 end end) WITH AddPrefabPostInit("taffy", function(inst) if inst.components.edible ~= nil then inst.components.edible.getsanityfn = function(inst, eater) return eater.prefab == "beechoc" and 20 end end end) Ah, I completely forgot about edible being a thing. This definitely works better than what I suggested. Link to comment https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/#findComment-1756708 Share on other sites More sharing options...
BeeChoc Posted November 11, 2024 Author Share Posted November 11, 2024 7 hours ago, yanecc said: In the modmain.lua. REPLACE GetPlayer = GLOBAL.GetPlayer AddPrefabPostInit("taffy", function(inst) if GetPlayer().prefab == "beechoc" then inst.components.edible.sanityvalue = 20 end end) WITH AddPrefabPostInit("taffy", function(inst) if inst.components.edible ~= nil then inst.components.edible.getsanityfn = function(inst, eater) return eater.prefab == "beechoc" and 20 end end end) Thank you ! Everything works fine now, there's just one another really small problem i have it's not that bad but since we're here imma ask. When choosing my character before entering a world, i dont see the stats, question mark instead of the value but in game there's no problem tho. Link to comment https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/#findComment-1756746 Share on other sites More sharing options...
Chesed Posted November 11, 2024 Share Posted November 11, 2024 58 minutes ago, BeeChoc said: Thank you ! Everything works fine now, there's just one another really small problem i have it's not that bad but since we're here imma ask. When choosing my character before entering a world, i dont see the stats, question mark instead of the value but in game there's no problem tho. In your character's lua file, change: Quote TUNING.beechoc_HEALTH = 200 TUNING.beechoc_HUNGER = 200 TUNING.beechoc_SANITY = 100 and Quote inst.components.health:SetMaxHealth(TUNING.beechoc_HEALTH) inst.components.hunger:SetMax(TUNING.beechoc_HUNGER) inst.components.sanity:SetMax(TUNING.beechoc_SANITY) to be entirely capitals like this: Quote TUNING.BEECHOC_HEALTH = 200 TUNING.BEECHOC_HUNGER = 200 TUNING.BEECHOC_SANITY = 100 Quote inst.components.health:SetMaxHealth(TUNING.BEECHOC_HEALTH) inst.components.hunger:SetMax(TUNING.BEECHOC_HUNGER) inst.components.sanity:SetMax(TUNING.BEECHOC_SANITY) Link to comment https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/#findComment-1756747 Share on other sites More sharing options...
BeeChoc Posted November 11, 2024 Author Share Posted November 11, 2024 3 hours ago, Chesed said: In your character's lua file, change: and to be entirely capitals like this: Perfect ! Thank you ! 1 Link to comment https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/#findComment-1756778 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