Jump to content

Recommended Posts

function SimPostInit(player)

GLOBAL.LoadScript("commands.lua")

AddTestToolController(player)

end

function AddTestToolController(player)

player:AddComponent("testtoolcontroller")

end

AddSimPostInit(SimPostInit)

[00:00:24]: [string "../mods/NEKIO/modmain.lua"]:145: attempt to index local 'player' (a nil value)

LUA ERROR stack traceback:

        ../mods/NEKIO/modmain.lua(145,1) in function 'AddTestToolController'

        ../mods/NEKIO/modmain.lua(141,1)

        =(tail call) ?

        =[C] in function 'xpcall'

        scripts/mods.lua(144,1)

        scripts/mods.lua(620,1) in function 'SimPostInit'

        scripts/gamelogic.lua(654,1) in function 'DoInitGame'

        scripts/gamelogic.lua(771,1) in function 'cb'

        scripts/saveindex.lua(120,1)

        =[C] in function 'GetPersistentString'

        scripts/saveindex.lua(102,1) in function 'GetSaveDataFile'

...

        =[C] in function 'GetPersistentString'

        scripts/saveindex.lua(68,1) in function 'Load'

        scripts/gamelogic.lua(955,1) in function 'callback'

        scripts/playerprofile.lua(564,1) in function 'Set'

        scripts/playerprofile.lua(447,1)

        =[C] in function 'GetPersistentString'

        scripts/playerprofile.lua(445,1) in function 'Load'

        scripts/gamelogic.lua(954,1) in main chunk

        =[C] in function 'require'

        scripts/mainfunctions.lua(691,1)

AddSimPostInit adds a function to a table.

Then, when the world starts, they all get executed like:

for k, v in pairs(simpostinits) do	v(wilson)end

The thing is, that wilson is indeed the result of GetPlayer() in Don't Starve, the player playing.

 

In DST, however, that wilson is nil.

 

So like @Kzisor, says, you want to use AddPlayerPostInit.

AddPlayerPostInit(function(player)	player:DoTaskInTime(0, function()		if player == GLOBAL.ThePlayer then			player:AddComponent("testtoolcontroller")		end	end)	end)

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