LuaAPI/types/hex

From The Battle for Wesnoth Wiki
< LuaAPI‎ | types

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.

Fog and Shroud

  • hex.foggedboolean
  • hex.shroudedboolean

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_labeltext

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_labeltext

As above, but checks or affects global labels visible to everyone, instead of team labels.

  • hex.labeltext
  • hex.labellabel 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.terrainterrain 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_terrainterrain 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_terrainterrain 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.infoterrain info

Returns the full properties of the terrain on this hex.

Schedule

  • hex.time_of_daytime 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_timetime 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.

This page was last edited on 17 December 2023, at 22:26.