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.

1 Like

We've got this all patched up (I think) but Will and I disagree on a small point and you get to be the tie-breaker. :slight_smile:

If you launch the simulator via the command line and pass an argument to the game, what happens when you hit the reload button (assuming nothing else has been loaded since, and the game didn't call playdate.restart())? Does it restart the game with the original argument from the command line, or with no argument?

1 Like

Cool! I can’t cast a vote because I never use command line arguments with Simulator!

But I will cast a tie breaker anyway in case nobody else chimes in… I think I’d want the original argument to be repeated? I’m pretty 50/50 though…

Oh yeah this is a h hard one.

I'd also keep the argument. And if you are willing to spend the time, add shift as a modifier to clear the arg. (cmd shift R, shift-click the restart button)

I'm comparing this to Chrome's reload. Which reloads a page retaining cookies normally, but will clear the cache when you hold shift.

1 Like

We are planning on adding a keyboard modifier to clear them on reload, but it won't make it into this release. Probably in 3.0.

1 Like