TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/g-js-api/G.js/llms.txt
Use this file to discover all available pages before exploring further.
$ object is the central configuration and utility namespace in G.js. It bundles the most commonly used top-level helpers — exporting the level, adding objects, printing debug info, and wiring up trigger functions — into a single import-friendly reference. In global mode (the default), $ is injected automatically into the global scope so you can call $.exportConfig(...) without any import. In safe mode you import it explicitly from the package.
exportConfig is available both as $.exportConfig and as a standalone named
export from @g-js-api/g.js/safe. In safe mode either form works identically.Members
$.exportConfig(conf)
Configures how the finished level is exported and kicks off the export pipeline. This must be called before any GD content is added to the level. It returns a Promise, so always await it at the top level of your script.
The export configuration object. See
ExportConfig below.$.add(...objects)
Adds one or more GD objects to the current level context. Equivalent to calling .add() on each object individually.
One or more objects created with
object() or trigger().$.print(...args)
Prints debug information to the console during level compilation. Accepts any number of arguments, just like console.log.
Values to print. All arguments are forwarded as-is.
$.callback_objects(cb)
Registers a callback function that is called on every object in the level right before export. Use this to post-process or audit objects globally.
Callback invoked with each raw object dictionary before the level is exported.
$.extend_trigger_func(t, cb)
Extends an existing trigger function group t by appending the triggers produced inside cb to it. This lets you add more behavior to a trigger function after it has already been created.
The trigger function group to extend.
Callback whose triggers are appended to the existing function group. Receives the group as its first argument, mirroring the
trigger_function API.$.trigger_fn_context()
Returns the current context group when called from inside a trigger_function callback. Useful when you need a reference to the group that owns the current trigger function, for example to remap IDs or stop execution.
any — the $group that represents the current trigger function context.
ExportConfig
The export target.
| Value | Behaviour |
|---|---|
levelstring | Prints the raw GD levelstring to stdout |
savefile | Writes the level directly to the GD save file |
live_editor | Sends the level to the GD Live Editor |
gmd | Exports the level as a .gmd file |
Optional fine-grained export settings. See
ExportOptions below.ExportOptions
When
true, prints a summary of object counts, group usage, and other stats to the console after export.When
true, emits a warning if the level is close to or exceeds the 9 999-group limit.The name to give the exported level. Used when writing to the save file or exporting as
.gmd.File path for the output when using the
savefile or gmd export types. Defaults to the GD save location.Whether to re-encrypt the save file after writing. Disable only if you are post-processing the file yourself.
When
true, runs the G.js optimizer over the level before export, deduplicating trigger functions and collapsing redundant groups.When
true, replaces existing level objects in the save file rather than appending to them.A group ID (or boxed group ID object) whose objects should be stripped from the output before export. Handy for removing editor-only helper objects.
When
true, G.js automatically repositions trigger objects into a neat column off-screen so they do not collide with gameplay objects.The X coordinate at which to start placing auto-positioned triggers. Negative values place them off the left edge of the level.
Override the output path specifically for
gmd exports. Takes precedence over path when both are set.