Lara module

Module for reading and nudging Lara's own state.

Her position, room and hit points are not here: she is an item like any other and they live on it, as trx.lara.item.

Properties

  • trx.lara.item (trx.items.Item). Lara's own item, or nil outside a level. Her position, room and hit points are read and written there. (read-only)
  • trx.lara.target (trx.items.Item). The item Lara's guns are locked onto, or nil if she has none. (read-only)
  • trx.lara.outfit (string). The outfit Lara is wearing, by name, as defined in cfg/outfits.json5.
  • trx.lara.holsters_visible (boolean). Whether Lara's holsters are drawn on her hips.
  • trx.lara.is_flying (boolean). Whether Lara is in the fly-mode cheat. Setting it enters or leaves fly mode.
  • trx.lara.is_wet (boolean). Whether Lara is still shedding droplets after a swim. trx.lara.dry clears it. (read-only)
  • trx.lara.has_pistol_weapon (boolean). Whether Lara is carrying a pistol-class weapon, which is what decides whether she has holsters to show at all. (read-only)

Enums

  • trx.lara.Mesh

    One of the fifteen meshes Lara is built from.

    • trx.lara.Mesh.HIPS = 0
      Hips, the mesh the rest hang off.
    • trx.lara.Mesh.THIGH_L = 1
      Left thigh.
    • trx.lara.Mesh.CALF_L = 2
      Left calf.
    • trx.lara.Mesh.FOOT_L = 3
      Left foot.
    • trx.lara.Mesh.THIGH_R = 4
      Right thigh.
    • trx.lara.Mesh.CALF_R = 5
      Right calf.
    • trx.lara.Mesh.FOOT_R = 6
      Right foot.
    • trx.lara.Mesh.TORSO = 7
      Torso.
    • trx.lara.Mesh.UARM_R = 8
      Right upper arm.
    • trx.lara.Mesh.LARM_R = 9
      Right lower arm.
    • trx.lara.Mesh.HAND_R = 10
      Right hand.
    • trx.lara.Mesh.UARM_L = 11
      Left upper arm.
    • trx.lara.Mesh.LARM_L = 12
      Left lower arm.
    • trx.lara.Mesh.HAND_L = 13
      Left hand.
    • trx.lara.Mesh.HEAD = 14
      Head.
  • trx.lara.ExtraMesh

    A mesh Lara can carry on top of one of her own - the dagger in Home Sweet Home, the oar in a boat.

    • trx.lara.ExtraMesh.TR1_BRAID_DEFAULT_HEAD = 0
      Braided head, out of combat.
    • trx.lara.ExtraMesh.TR1_BRAID_COMBAT_HEAD = 1
      Braided head, in combat.
    • trx.lara.ExtraMesh.TR1_BRAID_DEFAULT_TORSO = 2
      Braided torso.
    • trx.lara.ExtraMesh.TR1_BRAID_MAULED_TORSO = 3
      Braided torso, mauled.
    • trx.lara.ExtraMesh.TR1_BRAID_GOLD_HEAD = 4
      Braided head, gold.
    • trx.lara.ExtraMesh.TR1_BRAID_GOLD_TORSO = 5
      Braided torso, gold.
    • trx.lara.ExtraMesh.DAGGER_HAND = 6
      Dagger, in hand.
    • trx.lara.ExtraMesh.DAGGER_HIPS = 7
      Dagger, sheathed at the hips.
    • trx.lara.ExtraMesh.OAR = 8
      Oar.
    • trx.lara.ExtraMesh.SPANNER = 9
      Spanner.
    • trx.lara.ExtraMesh.DRINK_CAN = 10
      Drink can.
    • trx.lara.ExtraMesh.GLASSES_OPAQUE = 11
      Sunglasses.
    • trx.lara.ExtraMesh.GLASSES_TRANSPARENT = 12
      Sunglasses, transparent lenses.
    • trx.lara.ExtraMesh.CROWBAR = 13
      Crowbar.
    • trx.lara.ExtraMesh.WOODEN_TORCH = 14
      Wooden torch.
    • trx.lara.ExtraMesh.BINOCULARS = 15
      Binoculars.
    • trx.lara.ExtraMesh.HOOK_AND_POLE = 16
      Hook and pole.
    • trx.lara.ExtraMesh.DETONATOR = 17
      Detonator.
    • trx.lara.ExtraMesh.SHOVEL = 18
      Shovel.
    • trx.lara.ExtraMesh.JERRYCAN = 19
      Jerrycan.
    • trx.lara.ExtraMesh.SANDBAG = 20
      Sandbag.
    • trx.lara.ExtraMesh.WATERSKIN = 21
      Waterskin.
  • trx.lara.WaterState

    Where Lara is with respect to water.

    • trx.lara.WaterState.ABOVE_WATER = 0
      On dry land.
    • trx.lara.WaterState.UNDERWATER = 1
      Under the surface.
    • trx.lara.WaterState.SURFACE = 2
      Swimming at the surface.
    • trx.lara.WaterState.CHEAT = 3
      Flying, as the fly cheat leaves her.
    • trx.lara.WaterState.WADE = 4
      Wading, feet still on the floor.
  • trx.lara.GunState

    What Lara's hands are doing.

    • trx.lara.GunState.ARMLESS = 0
      Empty-handed.
    • trx.lara.GunState.HANDS_BUSY = 1
      Hands full, so nothing can be drawn.
    • trx.lara.GunState.DRAW = 2
      Drawing a weapon.
    • trx.lara.GunState.UNDRAW = 3
      Putting one away.
    • trx.lara.GunState.READY = 4
      Armed, weapon out.
    • trx.lara.GunState.SPECIAL = 5
      In a scripted sequence.

Structures

  • trx.lara.Lara

    Lara's own state, reachable straight off trx.lara.

    Handles are live references: if the underlying object is destroyed, using the handle raises an error rather than silently reading an unrelated one.

    Properties:

    • air_bar: integer. Air remaining underwater, out of 1800. Runs down while she is under.
    • death_timer: trx.game.Frames. How long Lara has been dead. (read-only)
    • dive_timer: trx.game.Frames. How long Lara has been diving. (read-only)
    • electric: integer. How badly Lara is being electrocuted, and 0 when she is not.
    • equipped_gun: trx.catalog.weapons. The weapon Lara is holding. (read-only)
    • exposure_bar: integer. Warmth remaining in the cold, out of trx.rules.exposure.max. Only moves in a level whose rooms carry the trx.rooms.Room.damaging flag.
    • extra_anim: boolean. Whether a scripted animation is driving Lara rather than her own state machine. (read-only)
    • gun_status: trx.lara.GunState. What Lara's hands are doing. (read-only)
    • hit_direction: integer. Which way the last hit came from, or -1 if she has not been hit. (read-only)
    • is_burning: boolean. Whether Lara is on fire. Setting it lights her or puts her out.
    • is_climbing: boolean. Whether Lara is on a climbable wall. (read-only)
    • is_crouched: boolean. Whether Lara is crouching. (read-only)
    • poison: integer. How poisoned Lara is, and 0 when she is not.
    • poison_target: integer. The poison reservoir that drains into trx.lara.poison over time. TR4 only.
    • pose_count: trx.game.Frames. How long Lara has stood still, which is what starts an idle animation. (read-only)
    • requested_gun: trx.catalog.weapons. The weapon Lara is drawing, while she is drawing it. (read-only)
    • sprint_timer: integer. Sprint left in her legs.
    • water_status: trx.lara.WaterState. Where Lara is with respect to water. (read-only)

Functions

  • trx.lara.set_extra_equipment(mesh, extra_mesh)
    Hangs an extra mesh on one of Lara's own, replacing the mesh there.

    Parameters:

    Example:

    trx.lara.set_extra_equipment(trx.lara.Mesh.HAND_R, trx.lara.ExtraMesh.OAR)
    
  • trx.lara.teleport(pos, [room_num])
    Moves Lara to a world position, putting her down on the floor there. She is taken off any vehicle, her weapons are put away and the camera follows her over.

    The position is nudged into valid room geometry, so a spot inside a wall lands her beside it rather than in it. Somewhere with no floor within reach moves nothing.

    Parameters:

    Returns: boolean. Whether she was moved.

    Example:

    trx.lara.teleport(trx.items.query:of_object("wolf"):first().pos)
    
  • trx.lara.cure_poison()
    Cures Lara's poisoning. Not the same as writing 0 to trx.lara.poison: the poison has a target as well as a current value, and clearing only the value lets it climb back.

  • trx.lara.extinguish()
    Puts Lara's fire out, and stops her being electrocuted with it.

  • trx.lara.dry()
    Dries Lara off, clearing the wetness that sheds droplets after she leaves water.

  • trx.lara.set_mesh(mesh, object, mesh_num)
    Puts another object's mesh on one of Lara's own, in place of whatever her outfit gives her there.

    It outlives an outfit change, because applying an outfit reads it, which is what lets a level dress her from its own geometry rather than from the outfit. Her head is the exception: a combat or speech face replaces it directly, and takes it back from an override with it.

    The override is dropped when the level ends, along with the meshes it could name.

    Parameters:

    Example:

    -- the torso young Lara wears before she picks up her backpack
    trx.lara.set_mesh(trx.lara.Mesh.TORSO, trx.catalog.objects.lara_skin, 7)
    
  • trx.lara.clear_mesh(mesh)
    Takes the override back off, leaving the mesh Lara's outfit gives her.

    Parameters:

  • trx.lara.clear_equipment(mesh)
    Takes the extra mesh back off, leaving Lara's own.

    Parameters: