Module for what a level keeps count of: what Lara has found in it, and how much there was to find.
The module is the level being played, so trx.stats.pickups.count is what
she has picked up in it. Any other level's counters are reached the same way
through trx.game.Level.stats. At the title screen there is no level, and
everything here reads nil.
The secret's number, as the player counts them. Counted from 1.
One thing a level is counted on, which is one row of the statistics screen.
raw is max plus
unobtainable: the game flow can declare part of a level
out of reach, and what it writes off is left out of what counts towards
completion while still being in the level.
Handles are live references: if the underlying object is destroyed, using the handle raises an error rather than silently reading an unrelated one.
Properties:
count: integer. How many of them Lara has. The secrets cannot be set this way: they are held one by one, so trx.stats.give_secret and trx.stats.take_secret are how they change.max: integer. How many of them count towards completing the level. (read-only)raw: integer. How many of them the level holds, obtainable or not. (read-only)unobtainable: integer. How many of them the game flow declares out of reach, and so must not be held against the player. (read-only)What one level keeps count of. The counters are the level's own and can be written, which is what a script correcting or seeding them wants.
Handles are live references: if the underlying object is destroyed, using the handle raises an error rather than silently reading an unrelated one.
Properties:
ammo_hits: integer. How many of them hit something.ammo_used: integer. How many rounds Lara has fired.deaths: integer. How many times Lara has died. Unlike the rest, this is not cleared when the level is entered again: a death stays with the level it happened on.distance_travelled: trx.math.Distance. How far Lara has travelled.medipacks_used: number. How many medipacks Lara has used, a small one counting as half of one.timer: trx.game.Frames. How long the level has been played.Computed properties (derived, not stored on the object):
allies_hurt: boolean. Whether Lara has turned on an ally in this level.crystals: trx.stats.Category. The save crystals, where the game has them.kills: trx.stats.Category. The enemies the level counts, allies among them.max_ally_kills: integer. How many of kills.max are allies. The statistics screen holds them against the player only once allies_hurt, so a screen written in Lua wants to do the same: max_enemy_kills, and these as well once she has turned on one.max_enemy_kills: integer. How many of kills.max are enemies rather than allies.pickups: trx.stats.Category. The items lying in the level for Lara to take.secrets: trx.stats.Category. The level's secrets. Which ones Lara holds is secret_list.Methods:
stats:give_secret(secret_num)
Marks a secret as found, as walking into its trigger would.
Parameters:
secret_num (trx.stats.SecretNum).Returns: boolean. false if the level has no such secret, or Lara already has it.
stats:secret_list()
The level's secrets, in order.
Returns: a list of table. The secrets, one by one.
Each entry:
num (trx.stats.SecretNum). Which secret it is.found (boolean). Whether Lara has it.icon (integer, optional). Which secret glyph draws it, as \\{secret N} names one, or nil for a secret that is a place to reach rather than an item to pick up.stats:take_secret(secret_num)
Takes a secret back, leaving it to be found again.
Parameters:
secret_num (trx.stats.SecretNum).Returns: boolean. false if the level has no such secret, or Lara does not have it.
trx.stats.secret_list()
Asks trx.stats.Stats:secret_list of the level being played. Where none is
being played, the list is empty.
Returns: a list of table. The secrets, one by one.
Each entry:
num (trx.stats.SecretNum). Which secret it is.found (boolean). Whether Lara has it.icon (integer, optional). Which secret glyph draws it, as \\{secret N} names one, or nil for a secret that is a place to reach rather than an item to pick up.Example:
for _, secret in ipairs(trx.stats.secret_list()) do
trx.log.info(secret.num .. ": " .. tostring(secret.found))
end
trx.stats.give_secret(secret_num)
Asks trx.stats.Stats:give_secret of the level being played.
Parameters:
secret_num (trx.stats.SecretNum).Returns: boolean. false if no level is being played, the level has no such secret, or Lara already has it.
Example:
trx.stats.give_secret(1)
trx.stats.take_secret(secret_num)
Asks trx.stats.Stats:take_secret of the level being played.
Parameters:
secret_num (trx.stats.SecretNum).Returns: boolean. false if no level is being played, the level has no such secret, or Lara does not have it.
trx.stats.has_crystals()
Whether any level of the game holds a save crystal.
Returns: boolean. True where one does.