Skip to content
Venomalia edited this page Dec 19, 2024 · 6 revisions

In Zelda: Four Swords Adventures, Variables control many interactions and events within levels. They are essential for setting conditions, triggering events, and determining actor behavior.
There are three main types of variables, each serving a different purpose:

  • Actor Variables
  • Local Variables (Room)
  • Global Variables (Map)

Actor Variables

Actor Variables are specific pieces of data that define the behavior of individual Actors (e.g., switches, doors, chests, enemies). Each actor has 4 bytes of data, which form up to 8 variables depending on the actor type or behavior.

Functionality:

  • To set the type or appearance of an actor (e.g., the color for a Sword Soldier).
  • To determine length or size, as seen with a door.
  • To specify which local variables are set by this actor.
  • To specify which local variables activate this actor.

Local variables (Room)

Local Variables are variables that are valid within a single room. They allow for room-specific events and actions to be controlled. There are 31 local variables per room, each of which can be either on or off.

Functionality:

  • Local variables can be set or retrieved by specific actors.

Example Usage of Local Variables

  • Open a door to access the next room when a switch has been pressed.
  • Make a treasure chest appear after a torch has been lit.

Global variables (Map)

Global Variables are variables that persist across all rooms within a level. They are used for events or conditions that need to be checked or triggered across multiple rooms. There are 31 global variables per map, each of which can be either on or off.

Functionality:

  • Global variables can only be set by a Global Switch (GLBS) actor.
  • They can be retrieved by a Local Switch (LCLS) actor to set a local variable.

Example Usage of Local Variables

  • Open a path when a puzzle has been solved in another room.

Tutorial

Turning on a Torch with a Switch

This tutorial walks you through the process of linking a Switch (SWTH) to a Torch (TRCH) so that the torch lights up when the switch is activated.

1. Place the Tiles
Select the Tile Sheet tab in the left panel and place a torch and a switch tile on the canvas.
torch and a switch tile

2. Place the Actors
Open the Actors Tab and Right-click on the canvas to add a new Actors, add a SWTH(switch) and TRCH(torch) a Actor.
SWTH and TRCH a Actor

  • SWTH, L:0, X:0, Y:0, V:0,0,0,0.
  • TRCH, L:0, X:0, Y:0, V:0,0,0,0.

3. Configure the Actor Variables

  1. Select the SWTH actor on the canvas.
  2. Set Variable 1a to 1.
  3. Repeat the same step for the TRCH actor. Select the SWTH Actor in the canvas and set Variable 1a to 1 and do the same with the TRCH Actor.
    Set Actor Variables 1a
  • SWTH, L:0, X:0, Y:0, V:8,0,0,0.
  • TRCH, L:0, X:0, Y:0, V:8,0,0,0.

Result
When you interact with the switch in-game, it will light up the torch.
Switching on the torch with a switch


Making a Treasure Chest Appear After Defeating All Enemies

This tutorial will guide you through creating a scenario where a treasure chest appears after all enemies in a room are defeated.
We will use the following actors: Enemy Annihilation Switch (ZNSW), Panel Rewriting (PNPC), and Treasure Chest(TKRA).

1. Place the Actors
Open the Actors Tab and add the required actors:

  • ZNSW (Enemy Annihilation Switch): This triggers the event when all enemies are defeated.
  • PNPC (Panel Rewriting NPC): This will change the tile to a treasure chest once triggered.
  • TKRA (Treasure Chest): Represents the actual treasure chest and determines the contents.
  • Enemies: Add actors to represent enemies in the room (e.g., OKTA (Octoroks) or SLR1(Sword Soldier)). Place them as needed.

grafik

  • ZNSW, L:0, X:0, Y:0, V:0,0,0,0.
  • PNPC, L:0, X:0, Y:0, V:0,0,0,0.
  • TKRA, L:0, X:0, Y:0, V:0,0,0,0.
  • OKTA, L:0, X:0, Y:0, V:0,0,0,0.

2. Configure the Actor Variables

  • ZNSW (Enemy Annihilation Switch):
    • Set Variable 1a to 1 to activate a local variable when all enemies are defeated.
  • PNPC (Panel Rewriting NPC):
    • Set Variable 1a to 1 (to match the variable set by ZNSW).
    • Set Variable 1b to 4 So that the chest appears with dust particles.**
    • Set Variable 4 to 48 to display the treasure chest tile when activated.
  • TKRA (Treasure Chest):
    • Set Variable 4 to the desired chest contents. For example, 16 for a key.
    • Ensure that TKRA and PNPC are placed on the same tile.

grafik

  • ZNSW, L:0, X:0, Y:0, V:8,0,0,0.
  • PNPC, L:0, X:0, Y:0, V:12,0,0,48.
  • TKRA, L:0, X:0, Y:0, V:0,0,0,16.

Result
When all enemies are defeated:

  1. The ZNSW switch triggers and sets Local Variable 1.
  2. The PNPC actor changes the tile to a treasure chest.
  3. The player can interact with the chest TKRA to collect the item. 051303_zeldatt_ss_GBA05