Vadim Dyachenko edited this page Sep 1, 2018 · 4 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);

enum Some { one, two, sizeof }
var v:Some = Some();
v.one = 1;
r = v.two;
var v = ds_grid_create(4, 4);
ds_grid_set(v, 0, 0, "hi");
var r = ds_grid_get(v, 0, 0);

enum Some { one, two, sizeof }
var v = array_create(Some.sizeof);
v[@Some.one] = 1;
r = v[Some.two];
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

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.