LuaAPI/types
Race
This represents a possible unit race. It has the following attributes:
- race.description → translatable string
The description of the race, for showing to players.
- race.name → translatable string
- race.plural_name → translatable string
The name of the race, for showing to players.
- race.num_traits → number
The number of random traits given to units of this race.
- race.ignore_global_traits → boolean
Whether this race can receive the global traits.
- race.undead_variation → string
The variation to transform this race to if killed by a plague attack.
- race.traits → trait list
The traits available to this race. Includes global traits if available. You can access specific traits by their ID, and the full trait definition is included.
- race.male_name_gen → name generator
- race.female_name_gen' → name generator
The name generators for this race. These are callable userdatas that return a random name each time.
- race.__cfg → config
The entire race definition as raw WML.
Unit Type
This represents a type of unit in the game, rather than a specific instance of a unit. It has the following attributes:
- unit_type.name → translatable string
The name of the unit type, for displaying to the player.
- unit_type.id → string
The unit's ID.
- unit_type.race → string
The ID of the unit's race. To get the actual race object, use this to look it up in wesnoth.races.
- unit_type.image → image string
- unit_type.icon → image string
- unit_type.profile → image string
- unit_type.small_profile → image string
Various images used to represent the unit.
- unit_type.max_hitpoints → number
- unit_type.max_moves → number
- unit_type.max_experience → number
- unit_type.cost → number
- unit_type.level → number
- unit_type.recall_cost → number
Various stats of the unit type.
- unit_type.advances_to → list of strings
A list of unit type IDs that this unit can advance to.
- unit_type.advances_from → list of strings
A list of unit type IDs that can advance to this unit.
- unit_type.traits → table
A table of the traits that this unit type can get. The key is the trait ID and the value is the trait's full definition as a config.
- unit_type.abilities → list of strings
A list of abilities that this unit type possesses. This is only the abilities' IDs, not their full definition.
- unit_type.attacks → attack list
A list of weapons that this unit type possesses. This list can be indexed as an array, but you can also look up an attack by its ID (name field). Each attack is a weapon userdata.
- unit_type.variations → variation list
Returns a list of unit type userdata representing possible variations of this unit, including gender variations. You can look up specific variations by their ID. Male and female variations have the ID male or female.
- unit_type.__cfg → config
Returns the full unit type definition as raw WML. This can be used if you need something that's not directly supported.
Weapon
This represents a single attack on a unit or unit type; it can also exist as an orphaned attack not attached to either a unit or unit type. It has the following attributes:
- weapon.read_only → boolean
Indicates whether you can write to the attributes of this attack. It will be true when getting an attack from a unit type userdata.
- weapon.description → translatable string
The attack's name, for displaying to the player.
- weapon.name →; string
The attack's ID.
- weapon.type → string
The attack's damage type.
- weapon.icon → image string
The attack's icon.
- weapon.range → number
- weapon.number → number
- weapon.movement_used → number
Basic stats of the attack.
- weapon.attack_weight → number
- weapon.defense_weight → number
The attack's weighting values.
- weapon.'accuracy → number
- weapon.parry → number
The defense modifications of the attack.
- weapon.'specials → list of configs
The special abilities of this attack.
- weapon.__cfg → config
The entire attack as raw WML