Wherigo Creator

13. Rolling dice and showing variables

Show a variable in a message

In a message (or the ending message), write a variable’s name between braces: {Score}. During the game it is replaced by its value. The easiest way is the “+ variable” list under the message, which inserts the name at the right place.

Inserting a variable in a message

Case doesn’t matter. A name that matches no variable is shown as is.

Show the player’s name

To greet the player by name, add the action 🙂 Player name → variable (at start, for instance): it copies the player’s username into a text variable. Then display it like any variable: Hello {FirstName}!. The name comes from the player’s Wherigo account on the device; in the site player it is the logged-in username (“Joueur” if no one is signed in).

Roll dice

Add the 🧩 Code block action and choose Roll dice (total into a variable) or Roll dice (total and detail) (a second text variable also gets each die, e.g. “3 + 14”). Set the number of dice (1 to 20) and the faces per die (6, 4, 8, 10, 12, 20, 100, 2 for heads or tails…). Out-of-range values are brought back within limits, so the cartridge never crashes.

Roll dice block
Dice result in the player
💡 Combine with If… then for a duel. Randomness differs on every game, including on GPS units and Wherigo apps.

Code blocks are available from the “guided code blocks” level (Explorer).