Rules module

Module for the numbers the engine plays by.

These are the game's rules: a mechanic that no single item owns. An object's own numbers live on the object, as trx.objects.<name>.properties, and the player's own choices live in trx.config.

A rule lasts as long as the playthrough: it is saved with the game and restored with it, and a new game starts from the defaults. A level script states what its level wants, and states it again on every entry, so a level that wants the defaults back asks for them.

Properties

  • trx.rules.exposure.max (trx.game.Frames). How much warmth Lara holds, and what trx.lara.exposure_bar fills to. Warmth only moves in a room carrying the trx.rooms.Room.damaging flag, such as the cold water of Antarctica.
  • trx.rules.exposure.drain_land (integer). Warmth lost each frame in the cold, on land or wading.
  • trx.rules.exposure.drain_water (integer). Warmth lost each frame in the cold, underwater or at the surface.
  • trx.rules.exposure.recovery (integer). Warmth regained each frame once out of the cold.
  • trx.rules.exposure.damage (integer). Hit points lost each frame once the warmth has run out.
  • trx.rules.corpse.fade_speed (integer). How much of a body's coverage goes each frame, out of 255. It is taken away once nothing is left. 0 leaves it where it lies.
  • trx.rules.carrier.snap_to_sector (boolean). Whether an item a defeated enemy carried lands in the middle of the sector the enemy stood on, rather than at its feet. Quest items are left where they fall either way.
  • trx.rules.carrier.inherit_facing (boolean). Whether an item a defeated enemy carried turns to face the way the enemy did, rather than keeping the rotation the level gave it. This only reaches drops the level data places on the enemy; a drop the gameflow names always takes the enemy's facing.

Functions

  • trx.rules.list()
    Every rule there is, as dotted group.field keys, in no particular order.

    Returns: a list of string.

  • trx.rules.get(key)
    Reads a rule by its key, for code that does not know which one it wants.

    Parameters:

    • key (string). Dotted path, e.g. exposure.damage.

    Returns: any. Raises if no rule has that key.

  • trx.rules.set(key, value)
    Changes a rule by its key. A string is read as text, the way the console gives it; any other value is taken as the rule's own type.

    Parameters:

    • key (string). Dotted path, e.g. exposure.damage.
    • value (any). The value to write, of the type the rule declares.
  • trx.rules.reset([key])
    Puts a rule back to the value the engine ships with, or every rule when given no key. Happens on its own when a new game starts.

    Parameters:

    • key (string, optional). Dotted path.
  • trx.rules.format_value(key)
    How a rule's value reads as text, for showing it to the player.

    Parameters:

    • key (string). Dotted path.

    Returns: string. The text, ready to print.