Skip to content

General GML hints from @sinthorion

EttyKitty edited this page May 5, 2025 · 3 revisions

Original link https://discord.com/channels/714022226810372107/1116557105705537576/1121659833888817282

You got code in two places (maybe 3):

  1. Objects, which are actual physical game objects, with position and step+draw methods, etc. Though they are very often used as simply global controller objects (where their position isn't used and they never draw anything). There's also the Temp objects that are placed just as temporary markers for other code. Most code runs in the context of an object instance, and whenever you see a variable being set without being declared (with the var keyword), that's most likely an instance variable, not a global variable.
  2. Scripts, which are basically just functions to be called from anywhere. Though they act more like macros in the sense that they operate in the same scope (of the instance) they were called from. On top of that they also have arguments, conveniently named argument0 etc.
  3. I haven't checked if this game has any, but a potential third place where GM can have code is room creation scripts. A room is like a scene, there can always be only one room active. The game does have a few different rooms, I imagine one for the main menu, one for the chapter creation, one for the actual game, etc.

All object code is organised in events, like step (called each tick), draw, create, click, etc. Special mention deserve the Alarm events. These are triggered by other code setting an object instance's alarm[n] variable to some value greater 0. I guess it counts down by 1 per tick.

Then there's the with() construct. This runs the code block once in the context for each existing instance of that object. You see a lot of with(obj_star) in the code, which does something for each star system.

A kind of entry point for this game is obj_controller.Create , which also contains a detailed comment by Duke about some program structure.

Clone this wiki locally