Quick links: documentation
Supported versions: GameMaker 8.1[1]
A collection of Cool Tricks for dynamically loading scripts in GameMaker 8.1¹.
Based on my own findings and techniques of yesteryear.
Features:
- Can load and call "scripts" (snippets)
Snippets can call each other, support arguments, and generally act like scripts. - Can load objects from a GMEdit-like single-file format
- A little syntactic sugar for snippet code
- A few helper functions
[1] Technically any version that has argument[]
/argument_count
and execute_string
/object_event_add
,
which is most likely versions between GM8.1 (incl.) and GM:HTML5 (incl.).
The extension consists of a DLL and a bunch of GML scripts.
The DLL does code preprocessing and other operations that were deemed too slow to do in GM8.1.
The scripts use object_event_add
+ event_perform_object
to store and call the final code without parsing penalties that would occur with execute_string
.
Syntax | Result | Notes |
---|---|---|
var i = 0
globalvar g = 1 |
var i; i = 0
globalvar g; g = 1 |
Single-variable declarations only! |
enum E {
A,
B,
C = 5,
D
}
trace(E.D); |
global.__E__A = 0;
global.__E__B = 1;
global.__E__C = 5;
global.__E__D = 6;
trace(global.__E__D); |
Init is done on spot - avoid function calls in enum field "values". |
missing(1, 2); |
snippet_call("missing", 1, 2); |
Allows snippets to call each other without forward declaration. |
You could use it for dynamic content loading if you are making a game in GM8.1.
Myself I wanted something that could run snippets of GM8.1 code without opening GM8.1, which is convenient timing given that GM8.1 doesn't open at the time of writing.
This is an example project that has snippets setup and does
snippet_init();
snippet_load_listfile("startup.gmk-snips");
on game start.
If you compile a GMEdit version from git, you can open .gmk-snips
files in it for a slightly-better code editing experience.
- A plugin for GMEdit
that lets you run the snippet-set by pressing F5 when a
.gmk-snips
is open.
- Wildcard support in listfiles?
(folder/*.gml
) script_execute
hook (that does either script_execute or snippet_call depending on whether index is number/string)
Author: YellowAfterlife
License: MIT?