Whimsy

Writing scenarios

Scenarios are series of steps actors will perform on certain events. Every actor may have a scenario, and only actors can have them. With scenarios, actors can react on what happens in the world and respond to hero's actions, for example, start dialogues or play a sound.

To find the scenario editor, open any actor and click on the "Scenario" tab at the top of the screen. On the right side, you will find a block library, and in the center will be a canvas on which you can place various blocks to form.

Basic rules of Scenarios

The rules for writing scenarios are:

  • Blocks execute from left to right, with white arrows indicating the flow of the scenario.
  • There're event blocks (colored ones with the "❕" sign) and commands (regular blocks)
  • Every block must be connected to an event, directly or through other blocks — otherwise, it will never execute.
  • There can be one or more events in each actor, and any number of commands.
  • While events are the start of an algorithm, certain blocks are final, meaning that no blocks can be put after them — for example, "Destroy themselves" or "End game". Some blocks are final in some cases — for example, if an apple actor destroys all apples, the scenario will end, too.

When something is happening in a game, it looks whether certain events on actors should trigger, and those events then run the command blocks.

Adding and changing blocks

All the blocks are listed in the panel on the right of the script editor as buttons. To add a block, either press a button, or drag it into the canvas.

Connecting (and disconnecting!) blocks

To form a sequence of actions, you need to connect nodes with each other. There is a couple ways you can do it:

  • Move one block close to another; when their inputs and outputs are close, you will see a temporary link that will settle once you drop the block.
  • Drag your pointer from one handle to another.

To remove a link, do the following:

  • Mouse, touchpads, styluses: right-click the link;
  • Touch devices: long-press the link;
  • Keyboard: press the link to select it first, then hit <- Backspace

Removing blocks

To remove a block, do the following:

  • Mouse, styluses: right-click a block and select "Delete" in the appeared context menu.
  • Touch devices: long-press a block and select "Delete" in the appeared context menu.
  • Keyboard: select a block with a press and hit <- Backspace
Tip

With a keyboard, you can select multiple blocks by holding Shift and dragging your pointer. Ctrl also works for picking individual blocks to add them to a selection or remove them from it.

Moving around the scenario

Scenario can span infinitely — sometimes they won't fit onto one screen! To move around, press anywhere in an empty space and move your pointer.

If you get lost, use the minimap in the bottom-right corner to move around, or press the button in the bottom-left corner of the scenario canvas to overview all blocks.

To zoom in and out:

  • With a mouse: Scroll the wheel;
  • On touch devices: pinch to zoom;
  • On any device: use + and - buttons in the bottom-left corner. You can also double-tap/double-click the canvas to zoom in.