-
Notifications
You must be signed in to change notification settings - Fork 0
Import and Use
- Go to the page of the latest release.
- Download the
CommandLineArgs.yympsfile - Open your GameMaker Project
- Select
Tools -> Import Local Packageand choose the downloaded file - A Folder
CommandLineArgsappears in your Asset Browser
There are two possible points in time, where you can use the code:
- In a global scope during initialization
- In a function or a Create event of any object (like your global GameController, if you have one)
In global scope, if you write code outside of any function, in a script file, you have no control over the initialization order of your scripts. You simply don't know, "who will run first".
As the CommandLineArgs library offers a global variable through a macro (ARGS), you have no chance, to know, whether this variable is already initialized or not.
For this case, the library offers another macro, ENSURE_ARGS which you should call before accessing the ARGS macro.
A short example, for better understanding:
// global scope, outside of any function
// this will run before the first room, when everything is initalized
ENSURE_ARGS;
if (ARGS.has_option("fullscreen"))
window_set_fullscreen(true);
Tip
The ENSURE_ARGS macro only needs to be called, when running in global scope. If you analyze your commandline arguments in the Create event of any controller object, it is guaranteed, that the ARGS global already has a value and the commandline has been analyzed.
Now find out, how to use the ARGS class in the Functions page.
© 2024-