How does require().method() appear to be - local or global value?
I have actually a file similar to this. I want to include this file into another one, and call the method setRelation(params)
.
[lua]local Superparents = {}
function Superparents.setRelation( params )
–code
end
return Superparents[/lua]
I have tried to included the above file like this:
[lua]require(“Superparents”).setRelation( Child1, “RootClass” )[/lua]
AND like this:
[lua]local sp = require(“Superparents”)
sp.setRelation( Child1, “RootClass” )[/lua]
…both variations worked, but which one appears to be created locally (local table) and which one globally (global accessible table)? Which one would you prefer?
I’ve digged into the _G variable, but didn’t found my answer, because I saw both times the same happening. It was both times included in _G and looked like so: Superparents { setRelation = "function ..." }
[import]uid: 73502 topic_id: 19307 reply_id: 319307[/import]