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.
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)One of the fifteen meshes Lara is built from.
trx.lara.Mesh.HIPS = 0trx.lara.Mesh.THIGH_L = 1trx.lara.Mesh.CALF_L = 2trx.lara.Mesh.FOOT_L = 3trx.lara.Mesh.THIGH_R = 4trx.lara.Mesh.CALF_R = 5trx.lara.Mesh.FOOT_R = 6trx.lara.Mesh.TORSO = 7trx.lara.Mesh.UARM_R = 8trx.lara.Mesh.LARM_R = 9trx.lara.Mesh.HAND_R = 10trx.lara.Mesh.UARM_L = 11trx.lara.Mesh.LARM_L = 12trx.lara.Mesh.HAND_L = 13trx.lara.Mesh.HEAD = 14A 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 = 0trx.lara.ExtraMesh.TR1_BRAID_COMBAT_HEAD = 1trx.lara.ExtraMesh.TR1_BRAID_DEFAULT_TORSO = 2trx.lara.ExtraMesh.TR1_BRAID_MAULED_TORSO = 3trx.lara.ExtraMesh.TR1_BRAID_GOLD_HEAD = 4trx.lara.ExtraMesh.TR1_BRAID_GOLD_TORSO = 5trx.lara.ExtraMesh.DAGGER_HAND = 6trx.lara.ExtraMesh.DAGGER_HIPS = 7trx.lara.ExtraMesh.OAR = 8trx.lara.ExtraMesh.SPANNER = 9trx.lara.ExtraMesh.DRINK_CAN = 10trx.lara.ExtraMesh.GLASSES_OPAQUE = 11trx.lara.ExtraMesh.GLASSES_TRANSPARENT = 12trx.lara.ExtraMesh.CROWBAR = 13trx.lara.ExtraMesh.WOODEN_TORCH = 14trx.lara.ExtraMesh.BINOCULARS = 15trx.lara.ExtraMesh.HOOK_AND_POLE = 16trx.lara.ExtraMesh.DETONATOR = 17trx.lara.ExtraMesh.SHOVEL = 18trx.lara.ExtraMesh.JERRYCAN = 19trx.lara.ExtraMesh.SANDBAG = 20trx.lara.ExtraMesh.WATERSKIN = 21Where Lara is with respect to water.
trx.lara.WaterState.ABOVE_WATER = 0trx.lara.WaterState.UNDERWATER = 1trx.lara.WaterState.SURFACE = 2trx.lara.WaterState.CHEAT = 3trx.lara.WaterState.WADE = 4What Lara's hands are doing.
trx.lara.GunState.ARMLESS = 0trx.lara.GunState.HANDS_BUSY = 1trx.lara.GunState.DRAW = 2trx.lara.GunState.UNDRAW = 3trx.lara.GunState.READY = 4trx.lara.GunState.SPECIAL = 5Lara'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)trx.lara.set_extra_equipment(mesh, extra_mesh)
Hangs an extra mesh on one of Lara's own, replacing the mesh there.
Parameters:
mesh (trx.lara.Mesh). Which of Lara's meshes.extra_mesh (trx.lara.ExtraMesh). The mesh to hang on it.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:
pos (trx.math.Vec3). World position.room_num (trx.rooms.Num, optional). Without it, the room is found from the position.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:
mesh (trx.lara.Mesh). Which of Lara's meshes.object (trx.catalog.Id). The object to take a mesh from. Raises if this level does not carry it.mesh_num (trx.objects.MeshNum). Which of that object's meshes.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:
mesh (trx.lara.Mesh). Which of Lara's meshes.trx.lara.clear_equipment(mesh)
Takes the extra mesh back off, leaving Lara's own.
Parameters:
mesh (trx.lara.Mesh). Which of Lara's meshes.