Skip to content
Vadim Dyachenko edited this page Sep 1, 2018 · 13 revisions

Welcome to the GMEdit wiki!

Check out the "Pages" section on the right side.

Here's a small breakdown of additional language features that GMEdit offers on top of GML:

Feature What you can do Instead of what
#args
#args a, b
// optional arguments:
#args a, b = 4, ?c
 
 
var a = argument0, b = argument1;
// optional arguments:
var a = argument[0];
var b = argument_count > 1 ? argument[1] : 4;
var c = argument_count > 2 ? argument[2] : undefined;
#import
#import variable_instance_get as v_get
var v = v_get(self, "some");
// multiple items:
#import scr_some_package.* as Pkg
Pkg.one(1);
return Pkg.two(2);
// [transformed to in saved file]
var v = variable_instance_get(self, "some");
// multiple items:

scr_some_package_one(1);
return scr_some_package_two(2);
types
var v:Grid = new Grid(4, 4);
v.set(0, 0, "hi");
var r = v.get(0, 0);
var v = ds_grid_create(4, 4);
ds_grid_set(v, 0, 0, "hi");
var r = ds_grid_get(v, 0, 0);
inline functions
on_click = #lambda { trace("hi!"); }
on_destroy = #lambda { trace("bye!"); }
 
 
 
 
on_click = scr_obj_test_on_click;
on_destroy = scr_obj_test_on_destroy;
// ... in scr_obj_test_on_click:
trace("hi!");
// ... in scr_obj_test_on_destroy:
trace("bye!");
coroutines
/// array_foreach(array)
#gmcr
var arr = argument0;
var len = array_length_1d(arr);
for (var i = 0; i < len; i++) {
    yield arr[i];
}

// used like:
var iter = array_foreach(0, myarray);
while (array_foreach(iter)) {
    show_debug_message(iter[0]);
}

For practical reasons, you wouldn't do this to yourself

Better workflow:

Syntax extensions:

  • `vals: $v1 $v2` (template strings)
  • #args (pre-2.3 named arguments)
  • ??= (for pre-GM2022 optional arguments)
  • ?? ?. ?[ (pre-GM2022 null-conditional operators)
  • #lambda (pre-2.3 function literals)
  • => (2.3+ function shorthands)
  • #import (namespaces and aliases)
  • v:Type (local variable types)
  • #mfunc (macros with arguments)
  • #gmcr (coroutines)

Customization:

User-created:

Other:

Clone this wiki locally