sys.save() and sys.load() expect a filename and a table as the only arguments, but there’s nothing preventing the table from being as simple or complex as you want it to be. Put everything you wish to save in a table and pass it along to sys.save():
local save_state = {
level_stars = { 3, 2, 1, 2, 3, 0 },
options = { sound = true },
coins = 12345,
lives = 2,
current_level = 6,
}
local success = sys.save(sys.get_save_file("my_cool_game", "save_state"), save_state)
As for your question on pprint() I think you’re missing something about how Lua tables are constructed. Somewhat simplified you could say that Lua tables can work either as a 1-indexed arrays or as key-value maps. This would be a 1-indexed array-like table:
local array = { "foo", "bar" }
In this case print(array[1])
would print “foo” and print(array[2])
would print “bar” and pprint(array)
would print:
{
1 = foo,
2 = bar,
}
Here’s an example of a key-value mapped table:
local map = { foo = "bar", key = "value" }
In this case print(map.foo
or print(map["foo"])
would print “bar” and pprint(map)
would print:
{
key = value,
foo = bar,
}
As you can see, in neither case a pprint() will print the name of the table itself. This is the expected result. Passing something as a parameter to a function call is a matter of passing the actual value, not the name of whatever variable this value might have been assigned to.