Skip to content

SetFlag

Referee: set a session flag, like one that records a lever pulled to open a portcullis.

Full documentation: SetFlag. Wire type: set_flag.

Legal session modes: battle, encounter, exploring, game_over, town, victory

JSON Schema

{
  "description": "Referee: set a session flag, like one that records a lever pulled to open a portcullis.\n\nA flag is a named value you store in the session. This command is legal in\nevery mode, `game_over` and `victory` included. Flags are saved with the session. Your code and\nlisteners read them from the referee view. To test one in an adventure document, use a\n`FlagEqualsCondition`, like the condition on\na door that opens once the lever has been pulled.\n\nModes:\n    `town`, `exploring`, `encounter`, `battle`, `game_over`, `victory`\n\nRejections:\n    None.\n\nEvents:\n    `FlagSetEvent` with the key and value.",
  "properties": {
    "command_type": {
      "const": "set_flag",
      "default": "set_flag",
      "title": "Command Type",
      "type": "string",
      "description": "The name that identifies the command class in serialized data. Each command class fixes\nit to a distinct snake_case string, like `\"move_party\"` or `\"open_door\"`, and constructing\nthe class sets it, so you never pass it yourself.\n`parse_command` and the\n`AnyCommand` union use it to rebuild the right class\nfrom a serialized mapping. A class's value never changes between releases."
    },
    "source": {
      "anyOf": [
        {
          "minLength": 1,
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Source",
      "description": "Who or what issued the command on whose behalf: an authored trigger or quest id, or the\nname of one of your game's systems. The engine never reads it, so a command with a\n`source` does exactly what the same command without one does. The session logs and\nreplays it with the command, so the log alone shows why something happened. Leave it\n`None` when there's nothing to record. An empty string fails validation when the command\nis constructed."
    },
    "key": {
      "minLength": 1,
      "title": "Key",
      "type": "string",
      "description": "The flag's name: any non-empty string you choose. Keep a name the same between releases\nof your game, because saves contain the flags and adventure documents refer to them by name."
    },
    "value": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "integer"
        },
        {
          "type": "boolean"
        }
      ],
      "title": "Value",
      "description": "What the flag is set to: a string, an integer, or a boolean. Setting a flag that's\nalready set replaces its value. To compare this value in an adventure document, use a\n`FlagEqualsCondition`. So a door that opens\nonce a lever has been pulled is a flag set here, and a gate on the door that tests it."
    }
  },
  "required": [
    "key",
    "value"
  ],
  "title": "SetFlag",
  "type": "object"
}