• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Transfer information between environments (folders)

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.
 
Oh... it sucks being stuck to 0.4, TFS 1.2 is so much better =/
But I'm still accepting ideas on how to do something like what I showed in the thread.
 
why are you stuck to 0.4? it takes maybe an hour or two to convert to 1.2
you don't even have to convert old scripts because it has backwards compatibility, the main thing you have to change is xml files because they're loaded different
 
Because our server ir 8 years old now and we have so many scripts and source modifications. But the primary issue for us to convert was converting all scripts, I also didn't know about backwards compatibility... I will take a look at it
 
Back
Top