Question

Puzzled by the Lua 5.0 documentation references to things like _LOADED, LUA_PATH, _ALERT and so on (that I could not use in Lua 5.1), I discovered all of those have been removed and the functionality put elsewhere. Am I right in thinking that the only one global variable left in Lua 5.1 is _VERSION?

Was it helpful?

Solution

The docs seem to think that's almost the case....

_G A global variable (not a function) that holds the global environment (that is, _G._G = _G). Lua itself does not use this variable; changing its value does not affect any environment, nor vice-versa. (Use setfenv to change environments.)

It looks like there's also _PROMPT and _PROMPT2, but only when using standalone lua interactively:

If the global variable _PROMPT contains a string, then its value is used as the prompt. Similarly, if the global variable _PROMPT2 contains a string, its value is used as the secondary prompt (issued during incomplete statements). Therefore, both prompts can be changed directly on the command line or in any Lua programs by assigning to _PROMPT.

OTHER TIPS

Assuming you don't open any libs, there's also _G, pairs, ipairs and newproxy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top