Playdate.datastore boolean error

Hello,
I'm using PlayDate SDK v1.12.0 on Windows with the simulator.
When I read a boolean with "playdate.datastore.read()", if the boolean is true, works fine.
But, if the boolean is false, the returned value is "nil" (Need to be false).

Strange. This is working as expected for me:

import "CoreLibs/object"

a = { this=false, that=true }
playdate.datastore.write(a, "test")
b = playdate.datastore.read("test")
printTable(b)

function playdate.update() end

returns

{
	[that] = true,
	[this] = false,
}

I'm on a Mac but I don't expect that would make any difference. Does the above also drop the false value for you?

1 Like

Okay, found the problem, I was using this code to check if the value existed :

-- Data is the datastore.read result
-- Name is the name of the value
if data[name] then
    return data[name]
else
    return nil
end

But when data[name] was false, the program returned null

Now I'm using :

return data[name]

No more useless checks

Thank you !

1 Like