Hi @Defold team and Community
I am currently playing around with the gpgs extension, since i wanted to use it in my current project. In had in mind to use it for storing highscores and other user data (save games). While the highscore part was rather easy, i am struggling a bit with saving user related data.
Here are the relevant parts of my code for saving any data:
onMessage function:
if message_id == hash("addCoins") then
print("addCoins message received")
gpgs.snapshot_open("coins", true, gpgs.RESOLUTION_POLICY_LAST_KNOWN_GOOD)
local success, error_message = gpgs.snapshot_set_data(10)
if error_message then
print(error_message)
end
gpgs.snapshot_commit_and_close()
local bytes, error_message = gpgs.snapshot_get_data()
end
update function:
print("snapshot open: " .. tostring(gpgs.snapshot_is_opened()))
generated log of my application:
04-25 18:43:21.891 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:21.908 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:21.925 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:21.943 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:21.959 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:21.975 6336 6369 D defold : DEBUG:SCRIPT: button pressed
04-25 18:43:21.976 6336 6369 D defold : DEBUG:SCRIPT: addCoins message received
04-25 18:43:21.979 6336 6369 D defold : DEBUG:SCRIPT: Can’t write data to the snapshot. The snapshot wasn’t open.
04-25 18:43:21.979 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:21.993 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:22.009 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
04-25 18:43:22.027 6336 6369 D defold : DEBUG:SCRIPT: snapshot open: false
Use save games is enabled in google play console and in the game.project file. Still the snapshot is never opened. Is my code wrong? Do you have any idea what else i could check? Any input is appreciated