Command Line Extra Arguments on Simulator (Windows)

,

Mentioned in the sdk docs is the following:
https://sdk.play.date/1.10.0/Inside%20Playdate.html#v-argv


I am able to open the simulator from the command line on windows with the command

>PlaydateSimulator.exe helloWorld.pdx

and it will boot right into helloWorld.pdx

but adding additional arguments such as

>PlaydateSimulator.exe helloWorld.pdx debug

gives me a window stating

Unexpected parameter: 'debug'

and then a prompt with proper usage

Usage: PlaydateSimulator [/h] (pdx path to load (.pdx file or directory)]
/h, --help          Display this information.

how can i use the playdate.argv feature mentioned in the sdk documentation?

(edits: formatting)

This still seems to be the case in the newest sdk release 1.12
https://sdk.play.date/1.12.0/Inside%20Playdate.html#v-argv still mentioned here

am i doing something wrong? would be awesome for testing to have this option

This is only currently supported in the Mac Simulator. I'll see if I can get it into the Windows Simulator as well. Thanks for the report!

Resurrecting this old topic because it was never resolved or closed: is it possible to inspect the command line arguments that PlaydateSimulator was launched with from the playdate API?

My use case is the following: I have an external level editor that I use to create levels of my game and I’d like to implement a “quick test” functionality in it where I can hit a button and have the PlaydateSimulator launch my game already inside the level that I’m editing. I would do this by having a dev-only option like PlaydateSimulator mygame.pdx –level Level.level, but for this I would need access to the argc/argv variables from inside the game (something like char **playdate→system→getCmdlineArgs(int *argc)), but I’m not finding anything of this sort in the C API docs.

This just gives you the args as a string, I think it's up to you to split the args yourself

(I just use a single string with my testing)

const char* launchArgs = pd->system->getLaunchArgs(NULL);

2 Likes

Thanks, I totally missed it somehow!

Hm, I might be missing something else though: I just tried it and the return value is null.

I'm launching the Simulator (on Linux) with args “foo bar” and when calling the function (upon receiving kEventInit) I always get a null pointer out of it (outpath is correctly filled with the PDX file name).

The docs don't specify when the function should be called so I assume it should always be valid to call…

I called it when the kEventInit event is fired in my game. (sim running on Windows, haven't tested since 3.0.0 I think)

Interesting, so maybe it's a Linux specific bug.

Just tested on 3.0.2 and yes, it does still work (I briefly thought it wasn’t, but I had only edited the command line for my release config!)

Passing in hello world as the args, gives:

You should also see those args in the console

image

I do see the args in the console but launchArgs returns null…I'll make more experiments when I have time but I'm pretty sure we have the same setup except I'm on Linux and I'm launching the simulator directly from the terminal (like “./PlaydateSimulator foo bar”)

The only difference is the windows visual studio integration runs

Simulator.exe c:\path\to\mygame.pdx hello world

(assuming you just didn’t forget to include the game pdx above)

(assuming you just didn’t forget to include the game pdx above)

Well…that was it. I was starting the simulator without the pdx name and manually launching it with Ctrl+O. Now it works as expected.

Thanks for the help!