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).

Functions

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

Species of the registry.

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}
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.

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}

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

Maps of the registry.

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

# 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" 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.

ParameterType
kindstring
idstring
Returns
integer-1 = unknown

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

Sets a licence price.

ParameterType
kindstring
idstring
priceinteger
Returns
boolean

# content.ammoPrice(weapon) → integer

A weapon's ammunition price.

ParameterType
weaponstring
Returns
integer

# content.setAmmoPrice(weapon, price) → boolean

Sets it.

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