Voxel Game Maker

Docs Cookbook

NPC who says something new the second time

Place the NPC (a Villager). In Properties, What is it? ▸ Character, then click Write what they say….

#Without code

  1. Place the NPC (a Villager). In Properties, What is it? ▸ Character, then click Write what they say…. The Dialogue tab opens with a Start wired to a Say. Type the first greeting in the Say: Hello, stranger! The bridge is out.
  2. Drag from the Start's right dot to empty space and add a Condition node. Set it to Variable is: Whose Global, Variable met_villager, Is at least, Value 1.
  3. From its Yes dot, add a Say: Back again? The bridge is still out.
  4. Wire its No dot to the first Say, then from that Say add an Action node: Set variable, Whose Global, Variable met_villager, How set, Value 1.
  5. Try it: press ▶ Play, talk to the villager (E), walk away and talk again.

#Quick code

Where it goes: on the NPC, Event: *Player presses E (the use key.

*):

if self.met then
  self.say("Back again? The bridge is still out.")
else
  self.say("Hello, stranger! The bridge is out.")
  self.met = true
end