Skip to content
Lemonymous edited this page Jul 6, 2023 · 7 revisions

Board

This page describes functions of Board that have been added or changed as part of modding API.

  • For a page about the Board class as defined in vanilla version of the game, see [Vanilla] Board
  • For a page about the Board class functions added by the memedit, see Board.

Table of Contents

 

Board

 

GetHighlighted

Signature: Point GetHighlighted()

Returns the current tile being highlighted by the mouse cursor. Returns nil if no tile is highlighted.

 

IsHighlighted

Signature: boolean IsHighlighted(Point)

Argument name Type Description
loc Point The tile we want to check

Returns true if the specified tile is currently highlighted by the mouse cursor. false otherwise.

 

GetSelectedPawn

Signature: Pawn GetSelectedPawn()

Returns the currently selected pawn on this board, or nil is no pawn is selected.

 

GetSelectedPawnId

Signature: int GetSelectedPawnId()

Returns the currently selected pawn's id on this board, or nil is no pawn is selected.

 

IsMissionBoard

Signature: boolean IsMissionBoard(table)

Argument name Type Description
mission table Optional argument. If provided, the function will check whether this instance is the board used in the specified mission. Defaults to currently active mission.

Returns true if this Board is the main board used in the specified mission. false otherwise, or when no mission is currently active.

 

IsTipImage

Signature: boolean IsTipImage()

Returns true if this board is part of a tip image. false otherwise.

 

MovePawnsFromTile

Signature: table MovePawnsFromTile(Point)

Argument name Type Description
loc Point The location to move the pawns from

Moves all pawns on the specified tile off the board. Returns a list of all pawns that have been moved, in reverse order in which they have been placed on the tile

Use in conjunction with RestorePawnsToTile

Example:

local loc = Point(2,2)
local fx = SkillEffect()
fx:AddScript(string.format([[
	local loc = %s
	local pawnstack = Board:MovePawnsFromTile(loc)

	Board:DamageSpace(SpaceDamage(loc, 1))
	-- Tile will be damaged, but no pawns will be harmed

	Board:RestorePawnsToTile(loc, pawnstack)
]], loc:GetLuaString()))

Board:AddEffect(fx)

 

RestorePawnsToTile

Signature: void RestorePawnsToTile(Point, table)

Argument name Type Description
loc Point The location to restore the pawns to
pawnStack table List of all pawns that have been moved using MovePawnsFromTile

Restores all pawns in the list to the specified location, honoring the order in which they've been placed originally.

Use in conjunction with MovePawnsFromTile

 

SetFire

Signature: void SetFire(Point, boolean)

Argument name Type Description
loc Point The tile that will be affected
fire boolean Whether the tile should be set on fire, or extinguished

Sets the specified tile on fire if the second argument is true, or extinguishes it if it is false. Extinguishing the tile does not remove the Fire status from pawns standing on the tile.

 

SetShield

Signature: void SetShield(Point, boolean)

Argument name Type Description
loc Point The tile that will be affected
shield boolean Whether the tile should be shielded, or unshielded

Adds a shield to any pawn, building or mountain on the specified tile if the second argument is true, or removes any shield if it is false.

 

ipairs

Board points can be iterated using regular Lua ipairs like so:

for index, point in ipairs(Board) do
    LOG(index, point)
end

Points are iterated by x-coordinate first and then by y-coordinate, so Point(0,0) will be first, then Point(1,0), etc. then upon reaching the edge of the board will continue at Point(0,1), Point(1,1) etc.

 

GetTiles

Signature: PointList GetTiles(function)

Argument name Type Description
predicateFn function Predicate function taking a point and returning a boolean value. Optional.

Returns a PointList of all points in the board if predicateFn is nil, or all points in the board that return true for predicateFn, if it is provided. Uses ipairs under the hood.

Example:

-- Grab all tiles in the Board
local allTiles = Board:GetTiles()

-- Grab all tiles that are on fire
local tilesOnFire = Board:GetTiles(function(p)
    return Board:IsFire(p)
end)

 

GetTile

Signature: Point GetTile(function)

Argument name Type Description
predicateFn function Predicate function taking a point and returning a boolean value.

Returns the first point in the board for which predicateFn returns true. Returns nil if no points match. Uses ipairs under the hood.

Clone this wiki locally