Salet core

The Salet class; the only instance of this class is automatically available as window.salet.

An instance of Character class, the game's playable character. Every property in this class that can be serialized (i.e. not functions) gets in the save.

Globally Unique ID of the game, arbitrary string. Manages the save slot. You must redefine this property in your game, or you'll be sharing the save slot with other games (and that will break all of these games).

Use UUIDs to avoid collisions.

Game version, arbitrary string. It corresponds to the save slot too (each new version gets a new slot).

Automatic save flag.

If true, then Salet would save the game when entering every room that has canSave = true. true by default.

Automatic load flag.

If true, then Salet would automatically load the saved game on page load. If you set this to false it's implied you have your own interface to load the game, also see loadGame.

It's useful for all sorts of intro menus, where you don't want to continue right where the player left the game.

An instance of the Random class.

Time in seconds spent since start of the game. A floating point number.

A date in seconds when the game started. A floating point number, read as Unix time.

A regular expression that controls which links are considered internal.

By default, a link is internal when it consists only of Latin letters, digits, dash and underscore signs: room or room.action or ./action.

ID of the current room, where the player is right now.

The flag that shows if Salet is in the interactive mode.

If it's true, the game is going on right now; if false, the game is loading (non-interactive mode). In non-interactive mode, all visual animations are skipped.

A system object; a stack of links that are not parsed yet.

A system object; all data to save. Contains the RNG seed seed, a sequence of visited links sequence, a sequence of visited rooms path and save time saveTime.

A system object; instance of the SaletView class.

ID of the room the player starts in, start by default

A system object; keeps all the game rooms.

A system property for all the game timers.

The function called at the start of the game.

It's convenient to redefine in your game to initialize the game state. (You also can do that in the on-entering callback enter of the starting room)

The function called when the player enters any room. It's called before the enter handler of the new room.

Argument 1: old room's ID

Argument 2: new room's ID

The function called when the player enters any room. It's called after the enter handler of the new room.

Argument 1: old room's ID

Argument 2: new room's ID

The function called before any action in any room.

If it returns true then the action is considered consumed and the room's handler won't act.

Argument 1: room's ID

Argument 2: action ID

The function called after any action in any room.

Argument 1: room's ID

Argument 2: action ID

The function called when the player exits any room before the exit handler of the old room is called.

Argument 1: old room's ID

Argument 2: new room's ID

Системная функция, которая собирает список комнат по указанному тегу и фильтрует его по размеру. Вызывается при создании автосписков неявного выбора.

Argument 1: тег для фильтра

Argument 2: максимальная длина списка на выходе

Returns a room (SaletRoom) where the player is.

Aliases: here

Returns ID of the save.

A system function; link handler.

Argument 1: link target

Moved the player to another room. An alias for processClick.

Argument: room ID

A system function; processes one link.

Argument 1: link target

A system function; processes one link.

Argument 1: link target

Returns the player to N rooms back. It's not an UNDO command, but rather a "go where I've been" command.

N = 1 is the current room.

Argument: number of rooms to go back, 2 by default

A system function; movement between rooms.

Argument 1: new room ID

Argument 2: forced movement flag (passed to the handlers), false by default

Shows a warning "do you really want to erase the save?" If the player agrees, erases the save and restarts the game.

Argument: forced erase flag (skips the warning), false by default.

Returns an array of rooms having the specified tag.

Argument: tag to search.

Saves the game.

Loads the game from the save data.

Argument: save data

Function that returns the save data.

A system function that initializes Salet and begins the game. Calls the init function, loads the game if the save is found and autoload is on.

An alias for getCurrentRoom

Returns true if the player visited the specified room at least once.

Argument: room ID

This function adds a timer in the game.

Timer is a text or a function that will be called after several steps. Step is every click (in-game action).

A timer can be repeatable (called every step number of steps) or one-time (is removed after the first call).

Argument 1: timer name, mandatory

Argument 2: timer action, mandatory. Can be a string or a function. The value returned by the function is appended to the game text.

Argument 3: repeatable flag, false by default.

Аргумент 4: number of steps, 1 by default.

The function drops the specified timer. This action cannot be undone.

Argument: timer name

Resets the specified timer.

Argument: timer name

A system function that checks and calls all game timers.

Called after every click in the game.

  • en/api/core.txt
  • Last modified: 2021/01/24 10:42
  • by 127.0.0.1