GameDevs - please create multiple user accounts in your games

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
5 Likes

Wholeheartedly agree (especially for RPG games)!

Did something similar for Under The Tree, but added some use of coroutine.yield() to add a progress bar as the save files for each slot are quite large:

utt_save_load_slot_demo

IMO save slots for more complex games should be considered a 'best practice' (maybe something to add to Designing for Playdate)?

1 Like

Wow, it takes a lot to need a progress bar. What do you have in that object?

Thank you for bringing this up and giving a practical suggestion!

Just for the record: Multiple player save files

Strongly agree with this and it's on my list to add save slots in Easy Godding

Imo it's very easy to do

UTT is a 'big game' :wink: .

I just had exactly the same thought. Gladly, Discourse pointed out to me that you've already posted the link (-: I missed your remark before. It deserves to be highlighted separately (for Playdate devs).

Teaser:

(edit: the data required for a single slot grows as the game progresses, the number above reflects three slots filled with late-game state)