gml_pragma(command, [optional...]);
Argument | Description |
---|---|
command | A string with one of the commands listed below. |
[optional...] | Some of the available commands require an optional argument or arguments. These are explained below for each command. |
Returns: N/A
The gml_pragma function affects how the YYC target compiles your code and should be called with the different commands to further optimise the final compilation of your project. These commands are effectively pre-processed before the game is compiled and so the function can be placed anywhere in your project and it will still be processed before the game is fully compiled. The available commands are as follows:
- "forceinline" - When the function is called with the "forceinline" pragma in a script resource, the YYC will compile the project with the script inline, rather than referenced. This will give a further processing boost, but care must be taken when using it as it will also inflate the final executable file size, especially if the in-lined code is large and/or used in multiple different places, as well as greatly increase the compile time.
- "global", "[gml code]" - The "global" pragma permits you to call some GML code before anything else and will execute the second GML string at a global scope, before the first room of the game executes. For example:
gml_pragma("global", "scr_Init()");
This will call the script "scr_Init" before the first room of the game is run.
- "PNGCrush" - The "PNGCrush" pragma will use the PNGCrush program on each texture created. Note that this can add significantly to the time that it takes to compile the game, so you don't want it on all the time, although it can make significant savings on final file size.
- "Texgroup.Scale", "[TextureGroupName]", "[Scale Divisor]" - The "Texgroup.Scale" will scale the given texture group on compile. You need to give an additional two arguments here: the "[TexGroupName]", which is the name (a string) of the texture group to scale, and the "[Scale Divisor]" (also a string), which is the divisor you wish to use for the scaling, i.e:
gml_pragma("Texgroup.Scale", "level1", "2");
This will half all the textures in the "level1" texture group.
gml_pragma("forceinline");
The above example code will force the script where it is used to be in-lined on compile.