Playdate.restart() with [arg] does not work on device, behaves weirdly in Simulator

I sometimes pass a string argument via Lua playdate.restart(“quick”), so I can skip some superflous visuals on the relaunch. (I check for playdate.argv[1] == “quick” on launch.)

On-device this does nothing: playdate.argv is not set by the .restart([arg]).

On the Simulator, things are weirder:

The restart never happens at all (separate bug report) but the command line argument IS stored. It takes affect on next launch—even with a fresh build-and-run of the game, where I’d want that one-time argument cleared.

Even beyond that, the stored argument never goes away: it persists, unwanted, across multiple build-and-runs. To clear it, you must quit and relaunch the Simulator app (this is SDK 2.6.2 on Mac with Nova).

Weirdest of all is the interaction between Simulator and device:

The stored argument from the Simulator’s failed restart() is made permanent on the device, happening at every launch, even fresh from the launcher screen.

The only way I’ve found to clear the argument on device is to quit-and-relaunch the Simulator as above (clearing the arg retained there) then upload fresh to device.

In short:

My game on-device is obeying leftover argument strings from failed Simulator restart()s, but is unable to set and read such strings itself.

As a result, I can’t transmit information across a restart via playdate.restart([arg]).

(As a workaround, I’ll redo this via saving of a little JSON data.)

2 Likes

These are fun ones, thanks for the report! I'm going to dig into this.

2 Likes

A quick update, I partially fixed this in 2.7 beta 9. We now correctly clear the launch args after game launch. What isn't fixed is using the args on device. That is a bit more involved and had to wait.