I'm trying to use lua with my c++ program and when I look up for how to use multiple lua script with I found this result https://stackoverflow.com/a/61684333/22979136
I modified this result and eventualy end up with this
local file_env = {}
local file_chunk = {}
function AddScript(ScriptLocation, index, Nd)
file_env[index] = setmetatable({}, {__index = _G})
file_chunk[index] = loadfile(ScriptLocation)
_ENV = file_env[index]
file_chunk[index]()
file_env[index].InitNode(Nd)
file_env[index].Start()
end
function UpdateScript(index)
print(file_env[index])
file_env[index].Update()
end
but there is some issue
when I call the "UpdateScript" function in my c++ program I get no result and "print(file_env[index])" just gives me the "nill" result
how can I fix this?
I tried to call the "UpdateScript" function inside the "AddScript" function but that didnt seem to help