Jump to content

Recommended Posts

So, i was trying to give Wolfgang a higher sanity drain the lower his sanity is.

local function onsanitychange(inst, data)
    local sanityboost = 1
    if inst.components.sanity:GetPercent()<0.50 then
        sanityboost = 1.5
    end
end
GLOBAL.TUNING.WOLFGANG_SANITY_NIGHT_DRAIN = 1.25 * sanityboost

AddPrefabPostInit("wolfgang", function(inst)
    if GLOBAL.TheWorld.ismastersim then
        inst:ListenForEvent("sanitydelta", onsanitychange)
    end
end)

But when i try to load a world this error shows up:

attempt to perform arithmetic on global 'sanityboost' (a nil value)

I don't understand the reason, can someone explain why and help me fix it?

Thanks!

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