How does saving data on GPGS work? (SOLVED)

Since gpgs.snapshot_set_data() takes a string as the argument I was wondering how to upload the actual game data. An explanation on how this process works would be appreciated. Thanks in advance.

You can convert Lua tables back and forth between being strings and tables.

local my_table = {}
table.insert(my_table, "my_value")
local buffer = sys.serialize(my_table) -- now a string
local new_table = sys.deserialize(buffer) -- now a table again
5 Likes

Thanks for the explanation.

2 Likes

So gpgs.get_data() returns an empty string I can’t seem to figure out why. For some context here are some screenshots.
The code:

Screenshot 2022-01-09 043456

logcat:

What am I missing?

1 Like

You check that it’s not nil, but you don’t check the length of the string?

The error message mentions “buffer size 0”

My bad. I’ve done that now. The length of the string is 0.

Please make sure you read example and GPGS Documentation

First of all it’s not enough to set data, you also need to call gpgs.commit_and_close() after.
Also, before getting data snapshot should be opened using gpgs.snapshot_open()

2 Likes

It works now. Thanks.