GMLC
Runtime compiler and interpreter to load, compile, and execute GML code at runtime.
🎮 GMLC
📘 Overview
The first full public release of GMLC, a runtime compiler and interpreter that lets GameMaker projects load, compile, and execute real GML code at runtime, enabling mod support, live scripting, and scratchpad experimentation directly inside GameMaker.
⚙️ Core Features
- Runtime Compilation: Parse and evaluate GML source strings during gameplay.
- Sandboxed Execution: Tiered capability profiles (
pure,safe,moderate,unsafe) for secure script isolation. - Hook System: Functions defined in a compile can be referenced back in native runtime (
main(),create(),step(), etc.). - Environment Support: Correct handling of
self,other,global, and static scopes. - Constructor & Function Parity: Full support for
static,constructor, andmethodsemantics. - AST-Driven Architecture: Real GML syntax parsing with tokenization and abstract syntax trees.
- Error Diagnostics: Structured compile/runtime error messages with caret and line reporting.
- Namespace Management: Mods and scratchpad sessions can run in isolated namespaces with safe reloads.
🧩 Setup & Installation
GMLC depends on SNAP by Juju Adams, which must be installed first.
Requirements
- SNAP (required): https://github.com/JujuAdams/SNAP
Installation Steps
- Download and import SNAP into your project (via its
.yympsor preferred install method). - Download the latest GMLC
.yympspackage from the repository or itch.io page. - In the GameMaker IDE, select Tools > Import Local Package.
- Choose the GMLC
.yympsfile and confirm import. - The GMLC scripts will appear under your project’s resource tree and are immediately ready to use.
No special initialization is required after import.
🚀 Quickstart
GMLC allows you to compile and execute GML source code strings at runtime. Here’s the most minimal example possible:
var env = new GMLC_Env();
var program = env.compile("return 42;");
var result = program(); // Executes the compiled code
show_debug_message(result); // Prints: 42
A compiled program behaves similarly to a native gm script. It’s callable, but can also contain other callable functions.
For example, fetching a specific function such as main, step, or draw from a compiled program:
var env = new GMLC_Env();
var program = env.compile(@'
function foo() {
return "bar";
}
');
var _foo = env.get("foo");
show_debug_message(_foo()); // Prints: bar
If the user declares a constant named global or uses GameMaker’s built-in global, functions can also be accessed directly via global.foo.
Note: GMLC can be updated to recognize newer GML functions than those bundled with its release by supplying a newer
GmlSpec.xmlfile from your local GameMaker runtime cache:
C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-<runtime.version>
⚠️ Note on execute_string()
GMLC also includes a legacy style helper named execute_string(_code).
It compiles and runs a code string immediately without caching or environment reuse.
This makes it significantly slower than using a GMLC_Env, but it can be convenient for quick, throwaway tests or debugging.
Example:
execute_string(@'show_debug_message("quick test");');
Use this only for temporary experimentation; for any real runtime scripting, always prefer creating an environment and compiling once.
🧠 Additional Notes
That’s all you need for a first run, but you may want to:
- Read about sandbox profiles
GMLC_EXPOSUREenum if you plan to expose runtime functions safely. - Use hooks if you want your compiled code to integrate into native events (
create,step,draw, etc.). - Special thanks to Juju Adams for use SNAP's XML parser until a stand alone design is finished.
- Special thanks to TabularElf for the many talks about his GMLSpeak, and improvements and design changes. Much of our work is shared between the projects.
❓ FAQ
Q: Can I use GMLC outside of GameMaker?
No; GMLC runs entirely inside the GameMaker runtime and is intended for in engine use.
Q: Is this compatible with both LTS and Monthly builds?
Yes.* GMLC targets standard GML syntax and should work in both, however I can not ensure that every feature will work as testing the entire runtime on multiple versions is an insermountable task, if you have issues please submit a bug report or feature request.
Q: Why is execute_string() so slow?
It does not reuse or cache the compiler environment, it recompiles the string every call.
Use GMLC_Env for anything persistent.
Q: Can I give my modders access to built-in GameMaker functions?
Yes. Use the sandbox capability system (pure, safe, moderate, unsafe) to control what functions are exposed.
Q: Can I expose my own functions?
Yes. Yes please see the variety of expose_* in GMLC_Env.
🔀 Alternatives
catspeak-lang - Catsaii: An extremely robust modding toolset with long term support.
gmlspeak - TabularElf: An extension to catspeak-lang, which allows for gml like code to be parsed for use inside catspeak
TXR - YellowAfterLife: A lightweight and simple expression parser.
SNAP - JujuAdams: SNAP contains a module for parsing and executing simple GML.
RunGML - sdelaughter: A lisp structured GML executer, very unique!
gml.gml - kenan238: A newer lightweight, single script GML interpreter.
inspiration from neerikiffu: https://discord.com/channels/724320164371497020/724320751624257646/1178721426983882915