This question might seem really complicated in the title, but it's not. Sorry, I couldn't find the words to describe this problem.
So, I've got a file that needs to be run in another file's context. E.g.
File 1 declares this variable and loads File 2's contents and runs them.
local LOCALS = {}
local file2 = loadfile(file2)
file2()
File 2 references an index in that variable:
if LOCALS["test"] == "this is a test" then
print("True!")
else
print("False!")
end
But it just comes up with this error:
string:1: attempt to index ? (a nil value)
Obviously because it doesn't recognise the 'LOCALS' table. I don't want to make everything global, so how can I run File2 as if it was part of File1's code (without putting that code in File1) so that it does recognise File1's variables?
I would assume this has been answered before because it seems like a pretty obvious question in some cases..Unless not?
Anyway, any help would be appreciated! :)/>