I have two scripts running, and I cannot merge both of the scripts into one. There has to be two running.
Script A is almost completely local but it does call on a global function a few times. These are defined in Script B. I would like to know if it is possible that the function use local variables inside of script A somehow.
It is like this:
--Script A
local lastUpdateID = 308
local var1,var2=6,7
_G.writeDefinition(var1,var2)
--Script B
function _G.writeDefinition(var1,var2)
-- Right here, is it possible that we can alter the
-- variable lastUpdateID? < (This is my question)
end
I have tried looking into getfenv and setfenv but they do not show that the local variable exists. The whole point of this is so that when Script A calls writeDefinition, lastUpdateID is incremented by one. lastUpdateID must remain a local variable, however.
EDIT: Ryan Stein's solution worked, but I have come across another problem later in the scripts.
Now it is like this:
local f_count=1
local function sell_lox()
local sellID=5
_G.writeDefinition(sellID,sellID.." PX_lvs")
end
It is similar to the original problem. From what I can tell, the only thing I can get is the SellID when writeDefinition is called. Is there a way to increment f_count from this when writeDefinition is called?