I share my playdate with my kids, and for anything that can save progress, it creates a difficult situation where we are all using the same account. This sucks for RPG games, or even just games were you are slowly progressing through many levels.
I think the best is to have at least 5 or 6 game slots to allow friends and family to share your game.
Here is some sample code for how I did this in Elf Factory:
ExampleSlot = { highestLevelCompleted = 0, levelStatus = {}, name = nil }
local defaultSlotData = {
Clone(ExampleSlot),
Clone(ExampleSlot),
Clone(ExampleSlot),
Clone(ExampleSlot),
Clone(ExampleSlot),
Clone(ExampleSlot),
}
SlotData = LoadData('slots', defaultSlotData)
And then I create a menu to choose a slot, and if name is nil, you can enter a new name. At the bottom of the slot choosing menu, you can choose delete a slot, and it brings you to a delete a slot menu.
The implementation of the menu scenes depends on how you write your app, but hopefully this gives a good help on how to handle the data.
Here are some util funtions the above code relies on.
function Clone(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[Clone(orig_key)] = Clone(orig_value)
end
setmetatable(copy, Clone(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
function LoadData(name, default)
local output = playdate.datastore.read(name)
if (output == nil) then
output = default
playdate.datastore.write(output, name, true)
end
return output
end