Skip to main content

SET

[[SET(variable,value)]]

SET is used to assign a value to a Variable. The Variables assigned in this way can then be used with the [[IF .. ]] Action.

The SET Action allows for great versatility in QuestDown, allowing text or Actions to change in response to Events during the Quest.

Variable names must be alphanumeric only and cannot contain spaces or other special characters. The assigned values can be numbers or text.

Here are some examples:

  • [[SET(Key,1)]]
  • [[SET(Key, found)]]
  • [[SET(Goal1, complete)]]

Starting from hQuestMaster version 1.050, SET also supports increment operators via +Number (e.g., +1, +10, +55) or ++ (equivalent to +1), decrement via -Number (e.g., -1, -7, -23) or -- (equivalent to -1), TURN (which represents the current turn), and RND(FROM, TO) which generates a random number between FROM and TO.

  • [[SET(key_found, ++)]]
  • [[SET(key_found, +5)]]
  • [[SET(key_used, --)]]
  • [[SET(key_used, -7)]]
  • [[SET(found_on_turn, TURN)]]
  • [[SET(rolled_dice, RND(1,6))]]

Examples

Example 1: {[[(V), ON_SEARCH_TREASURES]] After a long search, you found under the table a key covered in blood. [[SET(key,1)]]}

In this example, after the search is performed, the key variable is set to 1. By using IF and GET (see below), it is then possible to create Events or Actions that depend on whether the key has been found or not.

  • Example 2: {[[(V), ON_SEARCH_TREASURES]] After a long search, you found under the table a key covered in blood. [[SET(key, key_found)]]}

Example 2 is identical to Example 1, except that instead of assigning the value 1 to key, the value key_found is assigned (it is irrelevant in terms of functionality, but it shows two ways to use the SET Action).

  • Example 3: {[[(Z), ON_DEATH(C23)]] The Orc boss is dead! now you can exit the dungeon [[SET(boss_killed, 1)]]}
Using the code from Example 3 sets the boss_killed variable to 1 after the Orc boss is killed. This element can be reused by other automations (see examples with IF).