Requesting some wisdom from the LUA gurus as I can't seem to find any modding posts touching on this. I am encountering an odd but frustrating LUA issue where I can access the "world" table from vanilla Tech LUA scripts but not from the vanilla Script file "rotting.lua". I also see other LUA files in the Script directory accessing the "world" table such as "Stagehandutil.lua" so I can't figure out why the disparity... The Starbound log shows “attempt to index a nil value (global 'world')” when trying to access the 'world" table from scripts\items\rotting.lua e.g. code: "local playerIds = world.playerQuery(entity.position(), 1000)" Tech Lua = Works Rotting Lua = “attempt to index a nil value (global 'world')” I have copied and pasted the same code between various tech lua's and rotting.lua so there are no typos or case issues, yet I am getting different results between vanilla LUA scripts running this code... My ultimate goal is to get the hunger status of the player from code running in rotting.lua but I can't get past this fundamental table access issue.
Not all things have access to world. More specifically not all things have access to the same things other things do.
Well sugarbombs, Thank you for the quick response. Without the ability to currently pass a global variable between scripts and some vanilla LUA without fundamental table access, is there any other means to pass a value/state between scripts eloquently or clunky? Attempting to make rot conditional but having some difficulty finding what rotting.lua can be aware of outside of "baseItem" and "root". Even hinting at another mod that perhaps showcases passing values would be an appreciated bread crumb trail. I'm trying to stick to using vanilla files to stay as legitimate as possible. Aside from that my heart is not set on using one technique or LUA file over another.
You can try to use this snippet if code it will print all the available tables from where the script is executed. You can replace _env with any table and it will give you it's content. for k,v in pairs(_ENV) do sb.logInfo(k.." : "..tostring(v)) end I hope my phone auto correct didn't mess up the code