Skip to main content

Scripts

Creating a new script

mod.resource.script.create({
name: "clamp01",
args: ["value"],
body: ({ a }) => `return max(0, min(1, ${a.value}));`,
});

Call it from any GML you generate with call:

mod.resource.object.create({
// ...
events: {
create: ({ v, call }) => `
${ v.output } = ${ call("clamp01", v.input) };
`,
},
});

Changing existing code

There are two ways you can change a script code.

By wrapping code around using hook:

mod.resource.script.hook(killPlayer, ({ original, send }) => `
${ send("died") }
return ${original.call()};
`);

Or by inserting new GML splice GML around one statement found in the game's own code.

mod.resource.script.insert({
at: someStatement,
place: "after", // or "before"
body: () => `show_message("hi");`,
});

mod.content contains the decompiled GML statements, use it to find what to hook or insert around.