Hiya, I have a pretty large table containing a couple of sub-tables (don't know what they're called
) that I want to write and read from a file so that I can save my game. Given some context, the table contains the properties for each block in the map, where there are 10 properties per block, 60 blocks per map and n maps. When I load the map, each block in the maps should be assigned the properties that I saved!
However, I've been struggling to find a way to properly read and write this table into just a text document.
Ser *sounds* like the best choice for me but I really don't understand what's going on in the readme and how I would use it:
Code: Select all
local serialize = require 'ser'
print(serialize({"Hello", world = true}))
-- prints:
-- return {"Hello", world = true}
My second idea was to write the table in lines of data seperated by commas and then use Lua's string functions to split the string at the commas, but I couldn't figure out how i'd use gmatch and match etc etc to split the string and it all got a bit messy!
If anyone has any other suggestions or could give me some help that'd be great, thanks very much!!