The game's state: which game, stage, hunt, version, screen, messages.
Two games, one API. The PC port runs Carnivores: Dinosaur Hunter HD and Carnivores: Ice Age; each is its own copy
of the game, and game.id() tells a mod which one it runs in. A mod runs in a game only when its mod.json lists that
game in "games" (Mod folders). Every function, event and field is the same in both;
what differs is the game's content: the species (ids and type numbers, see the
species tables), the maps (game.area() 0-6 in Dinosaur Hunter, 0-4 in Ice Age), the texts
(STR_* keys) and the content registry's built-ins.
Which game the mod runs in. Each game is its own copy of the program, so this never changes while a mod runs. Use it to pick species and texts in a mod made for both games.
Returns
string
"dinohunter" (Carnivores: Dinosaur Hunter HD) or "iceage" (Carnivores: Ice Age)
local boss = game.id() == "iceage"and"mammoth"or"trex"world.spawnNear(boss, 6000)
The version of this API. It grows by one with every release that adds to it; nothing is removed. A mod that needs newer functions says so in mod.json ("api": 2); older games then show why it does not run.
Returns
integer
the modding API's version (3 in this release)
ifgame.apiVersion() >= 2thenprint("running in " .. game.id()) end
Replaces one of the game's texts (menus, messages, names). Texts the game shows from now on use it; menus already built show it the next time they are made. Letters outside Latin-1 become ? (the game's fonts lack them).
The definition changes the scripts made (species, weapons, weather, rules, overrides ...), each with the value before the first change and the mods that made it. They are undone when the scripts unload.
Returns
table
{what, original, mods}...
for _, c in ipairs(game.changes()) doprint(c.what, c.original, table.concat(c.mods, ", ")) end