GM 2023.1 introduced singletons:
function foo() constructor {
static bar = 1;
}
foo(); // initialised at least once so static is set
/// now you can do this anywhere:
foo.bar; // returns 1
However, GMLive (yet) doesn’t support this syntax. There’s however very easy way to bypass this issue.
Instead of foo.bar
you need to write static_get(foo).bar
- as in fact while compiling, GM translates former to latter, which means only latter is used in compiled games.
Have fun playing with new syntax!