Recently I have been exploring the luac 5.1 api and I was wondering if it is possible to loop through every global value in the 5.1 api, I know it is possible to do this in 5.2 ( referenced here ) as lua_pushglobaltable(lua_State*) exists. I know there is LUA_GLOBALSINDEX however I'm not sure how to use it for this purpose. Any help would be greatly appreciated!
Thanks :)
You can use the code in the answer you've mentioned. Just do this:
Here is a complete program that lists all global variables. If you remove the define, it works in Lua 5.2 and 5.3.