content

Species, weapons, maps, prices, rules and licences at run time; script AIs.

The run-time side of Content packs: the same registry and the same fields. Kinds are "species", "weapon", "map" (and "rules" for content.define). Equipment items (content.equipment) are the hunt menu's option buttons, also from content packs.

Functions

# content.species(id?) → table|nil

Species of the registry. price is the licence price the menu shows: after the rules' priceScale (as content.price).

ParameterType
id optionalSpeciesone species (default: all)
Returns
table|nilinfo, or a list of them: {id, type, name, ai, file, mod, builtin, scripted, hunt, hidden, price, unlocked, health, mass, size, radius, score, smell, hearing, sight, scaleMin, scaleRange, huntable, predator, flying, maps, spawnWeight, icon, iconColor, info}
for _, s in ipairs(content.species()) do if s.hunt then print(s.id, s.price) end end

# content.weapons(id?) → table|nil

Weapons of the registry. price and ammoPrice are what the menu shows: after the rules' priceScale / ammoScale.

ParameterType
id optionalstring
Returns
table|nil{id, type, slot, base, file, name, mod, builtin, hidden, price, ammoPrice, unlocked, power, precision, pellets, loudness, rate, ammo, magazine, aimFov, aimTime, icon, iconColor, info}

# content.maps(id?) → table|nil

Maps of the registry. price: after the rules' priceScale.

ParameterType
id optionalstring
Returns
table|nil{id, terrain, name, difficulty, mod, builtin, hidden, price, unlocked, times, residents, huntable, icon, iconColor, info}

# content.currentMap() → string|nil

The map of the hunt being played.

Returns
string|nil

# content.weaponInSlot(slot) → string|nil

The weapon the hunter has in a slot this hunt.

ParameterType
slotinteger
Returns
string|nil

# content.rules() → table

The economy and hunt rules.

Returns
table{scoreMultiplier, unlicensedScore, comboBonus, flyerCredits, speciesPriceScale, weaponPriceScale, mapPriceScale, ammoScale, maxSpecies}

# content.define(kind, fields) → string|nil

Adds or changes an entry at run time (new ones appear in the hunt menu).

ParameterType
kindstring"species", "weapon", "map", "equipment" or "rules"
fieldstablethe fields of the content pack JSON
Returns
string|nilthe entry's id, or nil and an error
content.define("species", {id = "night_raptor", copy = "velociraptor", name = "Night Raptor", health = 12, price = 300})
content.define("rules", {priceScale = 0.5})

# content.price(kind, id) → integer

A licence price as the menu shows it: after the rules' priceScale.

ParameterType
kindstring
idstring
Returns
integer-1 = unknown

# content.setPrice(kind, id, price) → boolean

Sets a licence price: the entry's own price, before the rules' priceScale (as price in its JSON).

ParameterType
kindstring
idstring
priceinteger
Returns
boolean

# content.ammoPrice(weapon) → integer

A weapon's ammunition price, after the rules' ammoScale.

ParameterType
weaponstring
Returns
integer

# content.setAmmoPrice(weapon, price) → boolean

Sets it (before ammoScale).

ParameterType
weaponstring
priceinteger
Returns
boolean

# content.balance(key) → number

One of the game's balance values.

ParameterType
keystringa balance value of the game, e.g. "RESUPPLIES_COST"
Returns
number

# content.setBalance(key, value) → boolean

Sets a balance value.

ParameterType
keystring
valuenumber
Returns
boolean

# content.unlocked(kind, id) → boolean

Whether the player owns the licence.

ParameterType
kindstring
idstring
Returns
boolean

# content.unlock(kind, id, on?)

Gives (or takes) a licence.

ParameterType
kindstring
idstring
on optionalbooleandefault true

# content.drive(species, fn)

Replaces the AI of every creature of a species with your function, every frame. Move and animate the creature there (c:move, c.yaw, c.anim, c:animate(e.dt)).

ParameterType
speciesSpecies
fnfunction|nilfn(e) with e.creature, e.dt; nil = the game's AI again
content.drive("gallimimus", function(e)
  local c = e.creature
  c.yaw = c.yaw + 90 * e.dt   -- they run in circles
  c:move(600 * e.dt)
  c:animate(e.dt)
end)

# content.reload()

Reads every enabled mod's content packs again.

# content.report() → string

A report of the registry.

Returns
stringone line per entry and the mods that set it

# content.aiNames() → table

The species whose AI a new species can use.

Returns
tablespecies ids

# content.equipment(id?) → table|nil

since API 3

Equipment of the registry: the game's camouflage, cover_scent, tranquilizer and radar, and the mods' items. on: switched on in the hunt menu; equipped: on in the hunt being played.

ParameterType
id optionalstringone item (default: all)
Returns
table|nil{id, name, info, icon, mod, builtin, hidden, price, scoreBonus, sight, smell, radar, tranquilizer, default, order, on, equipped}
for _, e in ipairs(content.equipment()) do print(e.id, e.on, e.price) end

# content.equipped(id) → boolean

since API 3

Whether the item is on in the hunt being played (false outside hunts and in observer mode): the place for effects of your own.

ParameterType
idstringan equipment id
Returns
boolean
on("hunt_start", function()
  if content.equipped("night_goggles") then nightVision(true) end
end)

# content.setEquipment(id, on) → boolean

since API 3

Switches an item in the hunt menu (for the next hunt).

ParameterType
idstring
onboolean
Returns
booleantrue when it is so now