Objects
Creating a new object
You can create new GameMaker objects:
mod.resource.object.create({
name: "hud",
persistent: true,
// Before writing new GML, you can register variables here
// this is useful as it will automatically add prefixes to it
// so you don't risk name collisions with games or other mods.
vars: ["count"],
events: {
create: ({ v }) => `${v.count} = 0;`,
step: ({ v, send }) => `
if (keyboard_check_pressed(ord("H"))) {
${v.count} += 1;
// Send a GML -> JS event
${send("bumped", `string(${v.count})`)}
}
`,
draw: ({ v }) => `draw_text(8, 8, "count: " + string(${v.count}));`,
},
// React to a JS -> GML event
receive: {
reset: ({ v }) => `${v.count} = 0;`,
},
});