Voxel Game Maker

Docs Tutorials

Take apart: Logic Lab

Seventeen machines, one idea each, all made of script nodes. Open their graphs, see how they work, then change them.

In the editor: Welcome ▸ Tutorials ▸ 2.3 ▸ ▶ Start opens a fresh copy of Logic Lab with this lesson's checklist.

Take apart · about 35 minutes · Advanced mode

What you'll learn: how script graphs work: Events, Conditions, Actions, waiting, and scripts that call each other. Logic Lab has no code nodes at all.

Before you start: do Switches, moving platforms and traps.

#1. Play it first

Open Logic Lab (the welcome window's samples, or File ▸ New Project… and pick it) and press F5. It's a garden lab with 17 stations. Each has a sign that names its script. The counter at the top right shows how many you've tried; try all 17 to win. Try at least five now, including the coins, the lifts and the Counter bot on the central crossing.

#2. Find the scripts

Stop with Shift+F5 and switch to Advanced with Basic | Advanced on the toolbar. The Scripts tab joins the bottom panels. Every graph is listed there by the name on its sign. Double-click one to open it.

#3. A chain: Coin (= code)

Open Coin (= code). Read it left to right:

  • an Event: Player touches / steps on it;
  • Set variable adds 1 to coins;
  • Show text (popup) shows = "Coins: " .. coins .. " of 3". A field that starts with = is worked out when the node runs;
  • a Condition with Code is true coins >= 3. On Yes, Open / close a door opens coin_door;
  • both ways end at Remove object, so the coin vanishes.

#4. A script every station calls: Station tried

Open Station tried. Its Event is Called by Run script, with one input, station. A Condition with List has (and its Not tick) counts each station once, Add to list keeps it, and at 17 it shows a banner and wins. Every station ends with a Run script node that calls it.

#5. Side by side: Three lifts

Open Three lifts. The Event's output has three wires, one to each Move object node, so the lifts rise together. Their wires meet in Wait for all, so the chime plays once the slowest lift is up.

#6. Waiting: Patient gate

Open Patient gate. Wait until pauses the script until you stand on the plate, the gate opens, a second Wait until waits for you to step off, the gate closes, and the last node wires back to the first Wait until. No timers, no switches.

One catch: a script that's waiting doesn't start its other Events. Keep a waiting loop in a script of its own.

#7. Breakpoints: Counter bot

Open Counter bot. Right-click its Condition node and tick Breakpoint (or click the dot on the node's title). Press F5 and press E on the bot. The game pauses there, the editor shows the graph with the node turned orange, and Live Values opens with bot_count. Change it, then Step (F10) or Continue (F5).

In a separate game window (Play ▸ Play in a Window) the game still pauses and shows the node in its own panel, but the graph and Live Values only follow a game that plays inside the editor: pick Play ▸ Play Here (in the Editor) to see them.

#8. Change it

  1. In Three lifts, make the third lift rise higher.
  2. In Coin (= code), make the door open at 2 coins: change the condition and the popup text.
  3. In Patient gate, add a Wait of 1 second before the gate closes.

Play it now: check every change.

#Try it yourself

  • Pick a station you haven't opened. Guess how it works from playing it, then open its script and see if you were right.
  • In your own project, build a station: a lever whose script moves three objects with Wait for all.

#Learn more

#Next

A talking character.