Now I test if snapshots work (install game, set new highscore, uninstall game, check if the highscore is previous one). But it doesn’t work
Logcat : http://prntscr.com/qjajwo
gpgs script file :
local use_saved_games = sys.get_config("gpgs.use_saved_games") == "1"
function callback(self, message_id, message)
print(message_id)
pprint(message)
if message_id == gpgs.MSG_SIGN_IN or message_id == gpgs.MSG_SILENT_SIGN_IN then
if message.status == gpgs.STATUS_SUCCESS then
end
if message.status == gpgs.STATUS_FAILED then
gpgs.login()
end
if use_saved_games then
gpgs.snapshot_open("googledata", true, gpgs.RESOLUTION_POLICY_MANUAL)
end
end
end
function init(self)
msg.post(".", "acquire_input_focus")
if gpgs then
gpgs.set_callback(callback)
gpgs.silent_login()
end
if gpgs then
local bytes, error_message = gpgs.snapshot_get_data()
if not bytes then
print("snapshot_get_data ERROR:", error_message)
else
print("snapshot_get_data", bytes)
end
end
end
function update(self, dt)
if gpgs then
if self.is_logged_in ~= gpgs.is_logged_in() then
self.is_logged_in = gpgs.is_logged_in()
end
if use_saved_games then
if self.snapshot_is_opened ~= gpgs.snapshot_is_opened() then
self.snapshot_is_opened = gpgs.snapshot_is_opened()
end
end
end
end
function on_message(self, message_id, message, sender)
if message_id == hash("set_data") then -- lose screen sends this message in init
if gpgs then
local success, error_message = gpgs.snapshot_set_data("googledata")
if not success then
print("snapshot_set_data ERROR:", error_message)
end
end
end
end
function final(self)
if gpgs then
gpgs.snapshot_commit_and_close()
end
if gpgs then
gpgs.logout()
end
end
I have tried to move gpgs.snapshot_commit_and_close() near the save data, but then, after I lose my game crashes.