Skip to content

Example Code

Grisgram edited this page May 9, 2025 · 4 revisions

Here are some examples, what you could do at startup of your game:

Allow different window modes

Command line given: yourgame.exe --fullscreen or yourgame.exe --windowed

// CASE 1: allow fullscreen switch if windowed is default
if (ARGS.has_option("fullscreen"))
    window_set_fullscreen(true);

// or CASE 2: allow windowed mode, if fullscreen is default
if (ARGS.has_option("windowed"))
    window_set_fullscreen(false);

Allow setting some size arguments

Command line given: yourgame.exe -w=1280 -h=720

if (ARGS.has_command("w") && ARGS.has_command("h")) {
    window_set_fullscreen(false);
    window_set_size(
        ARGS.get_command("w").value,
        ARGS.get_command("h").value
    );
}

Allow offline mode

Command line given: yourgame.exe --offline

if (!ARGS.has_option("offline")) room_goto(rmLogin); else room_goto(rmMain);

Enable/Disable verbose logging

Command line given: yourgame.exe +verbose

global.verbose_log = ARGS.is_switch_enabled("verbose");

Use a GameMaker command line parameter

Command line given: yourgame.exe -software

if (has_switch("software")) global.shader_details = false; 

Scan through the args manually

Sometimes you might want to receive "just a file name" or other things, that are not in the pattern of a command, a switch or an option.

You can always analyze the commandline by yourself. Just loop through the args array:

for (var i = 0; i < ARGS.count; i++) {
    var arg = ARGS.args[@i];
    // ... do whatever you want
}

Clone this wiki locally