lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi Mario wrote:

I want to save/restore all global variables to/from a file. I did search this list first and I found references to a save.lua contained in the distro that should demonstrate how to do this if I understood correctly but this file isn't part of the current Lua distro. I downloaded the Lua 4 version but it doesn't work with Lua 5. How do I do what I want in Lua 5?

I think you could use this

or this

You can let it save the global environment _G.

--- From the manual
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. (Use setfenv to change environments