population

Where and when species live: counts, places, herds and packs, respawns (since API 3).

A population rule says where and when a species lives on the maps: how many (groups x group size), where (zones, near water, ground height, slope, away from the hunter's start), when (the hunt's time of day, maps), as herds or packs, whether it respawns during the hunt and up to which cap, and whether it adds to the game's own placement or replaces it for that species. Rules come from a mod's populations.json, zones.json and spawns/*.json (read again for every hunt) or from population.add; both take the same fields, listed in the guide: Zones, populations, herds and packs. Species are given by id (world.spawn's ids, content packs' too).

A rule added in main.lua takes part from the next hunt on; one added during a hunt places its creatures at once. Reloading the scripts keeps the creatures of a rule the mod adds again (none are placed twice).

Functions

# population.add(def) → string

since API 3

Adds a population rule (or replaces the rule with that id).

ParameterType
deftablethe rule: id, species, areas / maps, time, chance, groups, size (or count), herd / pack / group, where, mode, respawn, cap, speciesCap, territory, avoid (the guide has them all)
Returns
stringits id
population.add{id = "lake_herds", species = "parasaurolophus", time = "dawn", groups = {2, 3},
               herd = {size = {4, 7}, formation = "loose"}, where = {nearWater = 2500},
               respawn = {delay = 120}, cap = 15}

# population.remove(id) → boolean

since API 3

Removes a rule (its creatures stay).

ParameterType
idstring
Returns
boolean

# population.list() → table

since API 3

Every rule, with what it does in this hunt.

Returns
tablea list of {id, species, mod, active, living, target, cap, replace, respawned}

# population.get(id) → table|nil

since API 3

One rule.

ParameterType
idstring
Returns
table|nilas population.list's entries

# population.members(id) → table

hunt only since API 3

The rule's living creatures.

ParameterType
idstring
Returns
tablea list of Creature

# population.count(id) → integer

since API 3

How many of the rule's creatures live.

ParameterType
idstring
Returns
integer

# population.spawn(id, groups?) → integer

hunt only since API 3

Places groups of a rule now (where its rule says; respecting its caps).

ParameterType
idstring
groups optionalintegerdefault 1
Returns
integercreatures placed