The game's state: stage, hunt, version, screen, messages.
# game.stage () → string
Which screen the game is on.
Returns
string the current stage: menu_main, menu_hunt, menu_options, menu_more, menu_help, menu_about, menu_shop, loading, hunt, menu_privacy, privacy_terms, privacy_policy (or none)
# game.inHunt () → boolean
Whether a hunt is running.
Returns
boolean true while hunting (the hunter exists)
copy if game .inHunt() then world .spawnNear("trex" ) end
# game.apiVersion () → integer
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 (1 in this release)
copy if game .apiVersion() >= 2 then useNewThing() end
# game.timeScale (factor? ) → number
Slow motion or fast forward for the whole game (creatures, the hunter, animations, timers of the game).
Parameter Type
factor optional number 0.05 to 4; 1 = normal
copy keys .bind("V" , function () game .timeScale(game .timeScale() == 1 and 0.25 or 1 ) end )
# game.text (key , language? ) → string|nil
One of the game's texts in the current (or a given) language.
Parameter Type
keystring a key of the game's strings.csv, e.g. "STR_T_REX"
language optional string "en", "de", "fr", "es" ...
Returns
string|nil the text, nil when there is no such key
# game.setText (key , text )
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).
Parameter Type
keystring
textstring|nil the new text; nil = the original again
copy game .setText("STR_T_REX" , "Rexy" )
# game.screen () → number, number
The window size in UI units (the coordinates of draw.* and ui.window).
Returns
number width
number height
# game.paused () → boolean
Whether the hunt is paused.
Returns
boolean true while the game menu (pause) is open
# game.dt () → number
The game's time step of the last frame (0 while paused).
# game.shots () → integer, integer
The hunt's shooting statistics.
Returns
integer shots fired this hunt
integer shots that hit
# game.message (text , seconds? , color? )
Shows a short message at the bottom right (the same as ui.toast).
Parameter Type
textstring the message
seconds optional number how long it shows (default 4)
color optional Color text colour (default white)
copy game .message("A T-Rex is near!" , 5 , "orange" )
# game.project (x , y , z ) → number?, number?
hunt only
Where a world point appears on the screen, for labels and markers.
Parameter Type
xnumber world x
ynumber world y (height)
znumber world z
Returns
number? screen x (nothing when the point is behind the camera or not in a hunt)
number? screen y
copy local sx, sy = game .project(x, world .ground(x, z) + 300 , z)
if sx then draw .text(sx, sy, "X marks the spot" , "red" , 20 , "center" ) end