@selticesystems,
I will write an article on scope of variables, but till then a quick explanation.
Do you know what a “scope” is? for the benefit of others, I will just re-iterate that. The scope of a variable indicates the reach and lifetime of a variable. So a local variable is available to that function/module only.
Now when you declare your ball_1 as local in the external.lua, it will be available *only* to that file not to any other file, even if you use require. To make this available to others, you need to *not* make it local. Easy as that.
I would avoid playing with the _G. Think of the _G as, I can write code in Assembly to make the system do what I want, but would I use assembly code or would I use C/C++/Lua code? The correct answer is “as circumstances dictate”. But generally, as a rule of thumb, I would avoid all assembly code.
cheers,
?
[import]uid: 3826 topic_id: 14295 reply_id: 52993[/import]