Hi everybody, this is my very first question in the forum. I’ve just started working with Lua and Corona SDK! so, expect not so hot questions
If the file doesn’t exist, create it, put some values in, calculate the hash. If the file exists, open it and check the integrity. If it fails, set up the default values back. However, it always fails! I appreciate any insights
Best regards!
local GGData = require "GGData" local Weapons = { } Weapons.default = { a1 = { isAvailable = true, ammo = -1 }, a2 = { isAvailable = false, ammo = 0 }, a3 = { isAvailable = false, ammo = 0 }, a4 = { isAvailable = false, ammo = 0 }, a5 = { isAvailable = false, ammo = 0 } } function Weapons:load( ) local box = GGData:new( "weaponsData" ) box:enableIntegrityControl( crypto.sha512, "password" ) box:verifyIntegrity( ) local weapons = box:get("weapons") if weapons == nil then box = GGData:new( "weaponsData" ) box:enableIntegrityControl( crypto.sha512, "password" ) box:set( "weapons", self.default ) box:save( ) end return weapons end Weapons:load( )