Skip to content

TheLinx/lstate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lstate

lstate is a Lua library which allows easy and painless storing of tables in Lua.

Dependencies

How to install (with LuaRocks)

Run the command luarocks install state

How to install (Manually)

Put the folder state somewhere in your Lua module path.
On Linux/Mac this is usually something like /usr/local/share/lua/5.1/.
On Windows it’s C:\Program Files\Lua\5.1\.

How to use

Take a look at this example:

require("state")
-- initialize our data table
data = {aVariable = ""}
-- if there is a previous state, load it
local st = state.load("exampleStateProgram")
if st then data = st end
-- print the variable
print("Stored variable: "..data.aVariable)
-- store a new value
io.write("Input a value to be stored: ")
data.aVariable = io.read("*line")
-- save the table
state.store("exampleStateProgram", data)

Easy, isn’t it?

About

Data saving for Lua

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages