Difference between revisions of "LuaAPI/types/hex"
(Categorize) |
(→Labels: Fix incorrect word) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 30: | Line 30: | ||
* ''hex''.'''label''' ↔ ''text'' | * ''hex''.'''label''' ↔ ''text'' | ||
+ | * ''hex''.'''label''' ← ''label info'' | ||
When reading, this returns a team label if it exists on the hex, and otherwise returns a global label. When writing, it usually places a global label, but if you assign a WML table that specifies side or team, it will place a team label for that team. | When reading, this returns a team label if it exists on the hex, and otherwise returns a global label. When writing, it usually places a global label, but if you assign a WML table that specifies side or team, it will place a team label for that team. | ||
Line 35: | Line 36: | ||
* ''hex'':'''label_for'''(''side'') → ''label info'' | * ''hex'':'''label_for'''(''side'') → ''label info'' | ||
− | Get the team label for the | + | Get the team label for the specified side on this hex; or if passed nil, return a global label. If there is no label, this will return nil. |
=== Terrain === | === Terrain === | ||
Line 41: | Line 42: | ||
* ''hex''.'''terrain''' ↔ ''terrain code'' | * ''hex''.'''terrain''' ↔ ''terrain code'' | ||
− | Check or replace the terrain on this hex. When assigning, you can use the special '''wesnoth.map.replace''' functions to control exactly how the terrain is overwritten (see [[../map|the documentation of the map object]] | + | Check or replace the terrain on this hex. When assigning, you can use the special '''wesnoth.map.replace''' functions to control exactly how the terrain is overwritten (see [[../map|the documentation of the map object]] for more details). |
* ''hex''.'''base_terrain''' ↔ ''terrain code'' | * ''hex''.'''base_terrain''' ↔ ''terrain code'' |
Latest revision as of 22:26, 17 December 2023
A hex reference is a location-like object that contains attributes and methods pertaining to a specific hex on the map. Since it's a location-like object, it has x and y keys, and to maintain compatibility with older code, the coordinates may also be read as [1] and [2]. If you assign the coordinates, the reference will instantly point to a new hex.
Contents
Fog and Shroud
- hex.fogged ↔ boolean
- hex.shrouded ↔ boolean
Returns a boolean value indicating whether the hex is under fog or shroud from the perspective of the current side. Can also be used to place or clear fog or shroud on the specified hex. Fog placed by this method is always multiturn fog.
- hex:fogged_for(side) → boolean
- hex:shrouded_for(side) → boolean
Returns a boolean value indicating whether the hex is under fog or shroud from the perspective of the specified side.
- hex:set_fogged(side, boolean)
- hex:set_shrouded(side, boolean)
Place or clear fog or shroud for the specified side on this hex. Fog placed by this method is always multiturn fog.
Labels
- hex.team_label ↔ text
Place or clear a team label on the current hex (a label visible by all members of the current side's team). You can assign either a string or a WML table containing label properties.
- hex.global_label ↔ text
As above, but checks or affects global labels visible to everyone, instead of team labels.
- hex.label ↔ text
- hex.label ← label info
When reading, this returns a team label if it exists on the hex, and otherwise returns a global label. When writing, it usually places a global label, but if you assign a WML table that specifies side or team, it will place a team label for that team.
- hex:label_for(side) → label info
Get the team label for the specified side on this hex; or if passed nil, return a global label. If there is no label, this will return nil.
Terrain
- hex.terrain ↔ terrain code
Check or replace the terrain on this hex. When assigning, you can use the special wesnoth.map.replace functions to control exactly how the terrain is overwritten (see the documentation of the map object for more details).
- hex.base_terrain ↔ terrain code
Check or replace the base terrain on this hex. When assigning, this only affects the base terrain, and if that would produce an invalid combination, it will be ignored.
- hex.overlay_terrain ↔ terrain code
Check or replace the overlay terrain on this hex. When assigning, this only affects the overlay terrain, and if that would produce an invalid combination, it will be ignored. You can assign an empty string to clear the overlay.
- hex.info → terrain info
Returns the full properties of the terrain on this hex.
Schedule
- hex.time_of_day → time info
Returns the base time of day info for the current hex, accounting for time areas. This does not include illuminate effects from units, nor lighting effects from specific terrains.
- hex.illuminated_time → time info
Returns the modified time of day info for the current hex, accounting for time areas. This includes illuminate effects from units and lighting effects from specific terrains.
Filters
- hex:matches(location filter) → boolean
Test whether the current hex matches a filter.