@rob,
I don’t entirely understand your question. You’re basically looking for loose globals or accidentally created globals? Can you give a for example?
Note: You should be able to do some interesting debug setup by modifying the metatable for _G:
http://www.lua.org/pil/14.2.html
You could make your globals ‘shout out’ when they get created or initialized.
You could try this:
-
Modify _G to report when globals are created or initialized.
-
Modify require to spit out the file name you’re requiring. This will make it easier to find globals that are created during init/loading.
[lua]_G.cachedRequire = require
_G.require = function( … )
print("***@@@*** Requiring file: ", arg[1] )
cachedRequire( unpack(arg) )
print("Done requiring file: ", arg[1], “***@@@***” )
end[/lua]
- Run game.
When you load your game, you’ll get a bunch of messages. You will be able to find and check globals that were created during the require because they’ll be framed by the ‘requiring’ messages.
Then it will go quiet.
After than, any more messages saying, “I got initialized.” are probably be accidental globals.
Am I making sense?
It’s a bit brute force, but it might help solve most of the accidental globals. [import]uid: 110228 topic_id: 33072 reply_id: 131346[/import]