The unit object: Difference between revisions

From Scenario League Wiki
Jump to navigationJump to search
(Added unit.owner)
m (Added to category lua resources)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
[[Category: Resources]]
[[Category:Lua Resources]]
Back To [[TOTPP Functions]]
Back To [[TOTPP Functions]]


Line 63: Line 63:
<code>unit.owner -> tribe</code>
<code>unit.owner -> tribe</code>


Returns the city's owner.
Returns the unit's owner.





Latest revision as of 20:10, 26 January 2019

Back To TOTPP Functions


id (get)

unit.id -> integer

Returns the unit's id.


type (get)

unit.type -> unittype

Returns the unit's type.


location (get)

unit.location -> tile

Returns the unit's location.


homeCity (get/set)

unit.homeCity -> city

Returns the unit's home city, or `nil` if it doesn't have one.


damage (get/set)

unit.damage -> integer

Returns the damage taken by the unit in hitpoints.


hitpoints (get)

unit.hitpoints -> integer

Returns the number of hitpoints left. It is defined as unit.type.hitpoints - unit.damage.


moveSpent (get/set)

unit.moveSpent -> integer

Returns the number of moves spent by the unit.


order (get/set)

unit.order -> integer

Returns the current order of the unit.


owner (get/set)

unit.owner -> tribe

Returns the unit's owner.


carriedBy (get)

unit.carriedBy -> unit

Returns the carrying unit if this unit is currently on board, `nil` otherwise.


attributes (get/set)

unit.attributes -> integer

Returns the attributes of the unit (bitmask).


veteran (get/set)

unit.veteran -> boolean

Returns the veteran status of the unit.


gotoTile (get/set)

unit.gotoTile -> tile

Returns the tile the unit is moving to under the goto order, or `nil` if it doesn't have the goto order.


activate

unit:activate()

Activates a unit, clearing its orders, and, if it has a human owner and movement points left, selects it on the map.


teleport

unit:teleport(tile) Alias for `civ.teleportUnit(unit, tile)`.