Voxel Game Maker

Docs User guide

Making things happen

Rules, script graphs and code: three levels of the same thing, and when to move up.

Doors that open, coins that count, enemies that shout: everything that happens in your game is the same three pieces, When something happens, If something is true, Do something. The editor lets you write those pieces three ways. They're levels of one ladder, not three different tools: start at the bottom and climb only when you need to. Basic shows Rules; script graphs and code are in Advanced (Basic | Advanced on the toolbar).

Level Where Good for
1. Rules Properties ▸ Rules on an object One object doing one thing: When the player presses E, If they have the Key, Do open the gate.
2. Script graphs The Scripts tab (Advanced) Logic that branches, waits, repeats, or ties several objects together.
3. Quick code A Code node in a script (Advanced) Math, lists, loops and your own functions: anything that gets long as nodes.

#One example, three ways

A gate that disappears when the player has the Key, and says it's locked when they don't.

1. As a Rule. Select the gate. In Properties ▸ Rules, press + Add a rule:

  • When: the player presses E
  • Only if: Has item, Key
  • Do: Hide object (this object)
  • Otherwise: Show text (popup), It's locked.

2. As a script graph. With the gate selected, Create ▸ New Script… makes a script that runs on it. Build the same chain as nodes:

  • an Event node: Player presses E
  • then a Condition node: Has item Key
  • its Yes goes to an Action node: Hide object
  • its No goes to an Action node: Show text (popup) It's locked.

3. As code. Keep the Event node and put one Code node after it:

if has("Key") >= 1 then
  self.hide()
else
  popup("It's locked.")
end

That code is exactly what right-click ▸ Copy as code gives for the nodes in step 2. Pick nodes, copy them as code, and you can see how any graph reads as code.

#When to move up a level

  • Rule ▸ script graph when a Rule needs to wait, choose between more than two outcomes, repeat, keep track of something, or change other objects step by step.
  • Script graph ▸ code when the graph is mostly math, lists or loops, or the same nodes appear again and again. A Code node can sit in the middle of a graph, so you never have to rewrite the parts that already work as nodes.

You never have to climb: plenty of finished games are made only of Rules and behaviors.

#Where each one lives

The other places you'll see logic are the same three levels in different spots:

  • Trigger (a behavior, Advanced): a Rule is a Trigger. Basic shows it as a Rule, Advanced as a Trigger with every When / If / Then option.
  • A script on an object: drop it from the Scripts tab onto the object (or Create ▸ New Script… with it selected). It runs as that object, so this object means it.
  • A script for the whole level: drop it on the ground, or World settings ▸ Scripts. It runs once for the level, for things like timers, waves and score.
  • The Player controls script (Game Settings ▸ Player): what the player does when it walks, jumps, attacks or is hurt.
  • Code anywhere a number goes: type = in a field for a small piece of code, such as = coins * 2.

See Behaviors and items for Rules, Triggers and script graphs, and the Quick code guide for code. Without code lists every node next to the code that does the same.