vitorbertolucci
Member
- Joined
- Apr 15, 2014
- Messages
- 75
- Reaction score
- 18
I'm running TFS 0.4, but I believe it's still relevant to newer releases.
Hello, as everyone that codes in lua must know, each datapack folder has it's own lua enviroment (or at least seems like). The lib folder is the only one that's able to declare global variables that will be known to all other folders, but the thing I'm dealing with right now is that I need to have a global table declared in the lib folder and edit it from two other folders. Basically:
data/lib/myFile.lua
Lua:
myTable = {}
data/actions/scripts/myAction.lua
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
myTable[1] = os.time
end
data/actions/scripts/myTalkaction.lua
Lua:
function onSay(cid, words, param, channel)
myTable[2] = os.time() - myTable[1]
end
Of course it wouldn't be that simple use, but it's something like that I am after.
I thought about using global storages to send information from one environment to another but the problem is that I would need to run a check every few seconds (which is only possible in globalevents folder that has it's own enviroment).
Any idea will be appreciated.