Voxel Game Maker

Docs Tutorials

Take apart: Hollowfield

A side quest built only from script graphs: a talking scarecrow, three bells and a pumpkin that wakes at midnight.

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

Take apart · about 40 minutes · Advanced mode

What you'll learn: how a whole quest is made from script graphs: a character who remembers where you are in the story, objects that count themselves, and a script that waits for the end.

Before you start: do Take apart: Logic Lab and Enemies and health.

#1. Play it first

Open Hollowfield (the welcome window's samples, or File ▸ New Project… and pick it) and press F5. Zombies rise all night and your lantern fires by itself. A few steps from the start, the scarecrow Old Jack calls you over. Press E: he asks you to ring three old bells, at the chapel, the farmhouse and on the south road. Ring them all, then go back to him. Keep playing past four minutes to see what happens at midnight.

The night's waves are run by Quick code. The crossroads quest is made only of script nodes, with no Code nodes. That's the part you take apart.

#2. Find the pieces

Stop with Shift+F5, and switch to Advanced with Basic | Advanced on the toolbar. In the Scripts tab you'll find Old Jack, Old Jack waits, Scarecrow sway, Old bell and Midnight.

Click Old Jack in the level. In Properties, his Values for code hold step (where you are in his quest), lines and happy_lines. He has three Script behaviors, one each for Old Jack, Old Jack waits and Scarecrow sway.

#3. Old Jack

Open Old Jack. Three Events start it:

  • A condition becomes true with Player is near: his hello, once each time you walk up.
  • Player presses E leads to a Switch node on = self.step. On new he asks for the bells, Start quest gives you The three bells, Set variable makes step asked, and Send message tells himself bells_asked. On asked he counts the bells. On done he thanks you.
  • Every few seconds, a Random chance and Pick from list choose a line from lines to mutter. These sit in a Frame called Gloomy. A second frame, Cheery, does the same with happy_lines and starts off.

#4. Old bell

Open Old bell. All three bells share it. A Condition with Quest is active keeps them cracked until Jack asks. Each bell then marks its own rung, uses Add to list to put its name in rung_bells, rings, lights up with Add behavior and a Tween, and pops up its count. Last, For each zombie within 7 tiles runs a Hit area on it.

#5. Old Jack waits

Open Old Jack waits. It starts on A message is sent (bells_asked), then Wait until List size is at least 3 for rung_bells. Then it sets step to done, uses Complete quest, Give XP and Heal player, and Turn script on / off swaps Jack's Gloomy frame for Cheery.

Why a second script? A script that's waiting doesn't start its other Events. A Wait until inside Old Jack would stop him talking.

#6. Midnight

Open Midnight, the level's own script. Its Every few seconds Event fires at 240 seconds, a Condition on the variable midnight lets it run only once, then Pick one chooses a jack-o'-lantern at random, Make it a… turns it into a Chaser enemy, and Change a behavior setting makes it tough. Last, Send message tells Old Jack, who shouts about it.

#7. Change it

  1. In Midnight, set the Event's seconds to 60, so midnight comes sooner.
  2. In Old Jack's Values for code, add a line of your own to lines.

Play it now: wait by Old Jack for your line, and watch for midnight after one minute.

#Try it yourself

  • Add a fourth bell. Copy one, give it a new Script name, and change every 3 in the scripts to 4.
  • In your own game, give a character a quest with two scripts: one that talks, one that waits.

#Learn more

#Next

Capstone: a small adventure with a quest.