Datastore.write not correctly writing zero-indexed array

I started using BigNum to represent large numbers, after having problems writing my own. Works nicely. Only trouble is, when I load my save game data that I previously saved, the numbers come back zero.

Well, the problem is that BigNum is zero-indexed internally (don't ask me why!!! I don't know why anyone would do this!!) This problem took me 3 days to identify, haha. So anyway apparently datastore.write isn't writing values in the 0 index of a table.

You can test this by running the following code:

    arraytest = { [0] = "drink me" }
    playdate.datastore.write(arraytest, "testing")

testing.json will contain the following:

{
}

but in the simulator, arraytest looks like:

If this is intended, that's fine - I will do the work converting bignum to 1-indexed. But it did seem like maybe this was a bug so I thought I'd post it just in case.

1 Like

I have a fix for that but it requires using non-standard JSON files with integer keys. Seems to work, but I'd like to get more testing on it before we ship it.

1 Like

Ahhh great thanks Dave!