Hey Everyone,
I’m currently a Computer Science major at Emory University and stumbled across Corona SDK and the LUA language. I absolutely love using both.
I’ve created some great classes for anyone and everyone to implement in their games. The Data Saver Class is particularly great.
data saver link: https://github.com/jakemor/Usefull-Lua-Classes/blob/master/Safe%20(simple%20data%20saver)/safe.lua
It’s very simple to use … (make sure safe.lua is in your project folder)
-- require safe.lua local safe = require( "safe" ); -- create an instance. first param = key, second = developer mode (files stored locally, remove before building) local info = safe.new("info", "dev") -- treat info like any other table! info.score = 100 info.name = "jake" info.score = 300 -- when your ready to save, just call the save() function info:save() -- print function to keep things simple info:print()
Some cool things to keep in mind:
When you create a new instance, it checks to see if any previous safes with key “info” have ever been created, and loads them … no need for a load function!
Data can also be shared between files!
Just go to a different file and create an instance with the same “info” key. It will be populated with that keys content since last save.
note: be sure to not to delete info.path! ( auto populated when safe.new() is called )
A super simple highscore class that implements safe.lua is in the works.
check the whole repository out for future useful classes: https://github.com/jakemor/Usefull-Lua-Classes
Best,
Jake Mor