Jump to content

Problem with function


Recommended Posts

Hello!

Can someone help me with this?
What am I doing wrong?


Error:

 

[00:02:16]: error calling PrefabPostInit: waxwell in mod workshop-1400410016 (Phobias of Wolfgang): 
[string "../mods/workshop-1400410016/modmain.lua"]:115: attempt to index field 'sanity' (a nil value)
LUA ERROR stack traceback:
        ../mods/workshop-1400410016/modmain.lua(115,1)
        =(tail call) ?
        =[C] in function 'xpcall'
        scripts/mods.lua(158,1) in function 'mod'
        scripts/mainfunctions.lua(267,1)    
[00:02:16]: Disabling workshop-1400410016 (Phobias of Wolfgang) because it had an error.    
[00:02:16]: [string "../mods/workshop-1400410016/modmain.lua"]:115: attempt to index field 'sanity' (a nil value)
LUA ERROR stack traceback:
        ../mods/workshop-1400410016/modmain.lua(115,1)
        =(tail call) ?
        =[C] in function 'xpcall'
        scripts/mods.lua(158,1) in function 'mod'
        scripts/mainfunctions.lua(267,1)
[00:02:16]: [string "../mods/workshop-1400410016/modmain.lua"]:115: attempt to index field 'sanity' (a nil value)
LUA ERROR stack traceback:
        ../mods/workshop-1400410016/modmain.lua(115,1)
        =(tail call) ?
        =[C] in function 'xpcall'
        scripts/mods.lua(158,1) in function 'mod'
        scripts/mainfunctions.lua(267,1)

My code:

 

AddPrefabPostInit("wilson", function(inst)

    inst.components.sanity.night_drain_mult = TUNING.WILSON_NIGHT_DRAIN_MULT
    inst.components.sanity.neg_aura_mult = TUNING.WILSON_NEG_AURA_MULT

end)


Yes, the mod is called "Phobias of Wolfgang", but it's not just for Wolfgang.
This error does not exist on the server without caves, but when I create a world with caves I see this error.

Edited by Tezumoto
Link to comment
Share on other sites

The issue is you need to check to make sure this doesn't run on clients.

AddPrefabPostInit("wilson", function(inst)
	if GLOBAL.TheWorld.ismastersim then	
		inst.components.sanity.night_drain_mult = TUNING.WILSON_NIGHT_DRAIN_MULT
		inst.components.sanity.neg_aura_mult = TUNING.WILSON_NEG_AURA_MULT
	end
end)

 

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...