Jump to content

Recommended Posts

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 by BeeChoc
Link to comment
https://forums.kleientertainment.com/forums/topic/160614-character-mod-problem/
Share on other sites

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.

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)

 

  • Like 1
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.

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.

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)

 

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