Skip to content
forked from BetrSpot/GGData

GGData is a simple persistent data storage class for your game or app. Currently it supports the Corona SDK and Love 2D.

Notifications You must be signed in to change notification settings

brianmtully/GGData

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GGData

GGData is a simple persistent data storage class for the Corona SDK.

Basic Usage

Require The Code
local GGData = require( "GGData" )
Create or load a box
local box = GGData:new( "sample" )
Set some values
box:set( "message", "hello, world" )
box.anotherValue = 10
Get some values
print( box:get( "anotherValue" ) ) -- prints 10
print( box.message ) -- prints 'hello, world'
Save the box
box:save()
Enable or disable iCloud backup
box:setSync( true )
box:setSync( false )
Check if iCloud is enabled or disabled
print( box:getSync() )
Enable integrity checking. This should be set BEFORE adding values and needs to be set on each run as the key is not stored ( as it would defeat the point ).
local crypto = require( "crypto" )
box:enableIntegrityControl( crypto.sha512, "SECRET_KEY" )
If you decide to enable integrity checking after you have already set a bunch of values you will want to update all the hashes.
box1:enableIntegrityControl( crypto.sha512, "MONKEY" )
box1:updateAllIntegrityHashes()
When adding or editing values via any of the helper methods integrity data will be stored automatically but if you store the data manually you will also need to add this extra data.
box.newValue = "Hello, World!"
box:storeIntegrityHash( "newValue" )
Verify the integrity of all items. Any values that are detected as wrong will be nilled out. Remember to save after doing this :-)
local corruptEntries = box1:verifyIntegrity()
print( corruptEntries ) -- How many, if any, values were removed due to being different than expected.

About

GGData is a simple persistent data storage class for your game or app. Currently it supports the Corona SDK and Love 2D.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%