objective_utils.lua¶
This script contains utility functions for typical tasks that need to be checked for objectives.
To make these function(s) available include this file at the beginning of a script via:
include "scripting/objective_utils.lua"
- check_for_buildings(plr, which[, region])¶
Checks if the number of buildings defined in which are found for the given player. If region is given, buildings are only searched on the corresponding fields. If more buildings or equal the number of requested buildings are found, this function returns
true
.Example usage:
check_for_buildings(wl.Game().players[1], {lumberjacks_hut=2, quarry=1})
- Parameters:
plr (
wl.game.Player
) – Player to check forwhich (
table
) – (name,count) pairs for buildings to check for.region (
array
ofwl.map.Field
.) – array of fields to check for the buildings See alsowl.map.Field.region()
- Returns:
true
if the requested buildings were found,false
otherwise