player

The hunter: position, view, health, items.

Functions that read return nothing outside a hunt (player.pos() gives no values); functions that change the hunter raise an error outside a hunt: check game.inHunt() first. Yaw is the game's heading in degrees: 0 looks along -z, 90 along +x, 180 along +z, 270 along -x (on the game's own map: east, south, west, north); creatures use the same yaw.

Functions

# player.exists() → boolean

Whether the hunter exists.

Returns
booleantrue in a hunt

# player.pos() → number, number, number

hunt only

The hunter's position.

Returns
numberx
numbery (the ground under him)
numberz
local x, y, z = player.pos()

# player.setPos(x, y, z)

hunt only

Moves the hunter. player.setPos(x, z) puts him on the ground there.

ParameterType
xnumber
ynumberheight; with two arguments (x, z) he stands on the ground
znumber

# player.teleport(x, z)

hunt only

Moves the hunter to x, z on the ground.

ParameterType
xnumber
znumber

# player.yaw() → number

hunt only

Where the hunter looks (the heading).

Returns
numberdegrees 0-360

# player.setYaw(yaw)

hunt only

Turns the hunter.

ParameterType
yawnumberdegrees

# player.pitch() → number

hunt only

How far up or down he looks.

Returns
numberdegrees, + up / - down

# player.setPitch(pitch)

hunt only

Tilts the view.

ParameterType
pitchnumberdegrees (-89 to 89)

# player.forward() → number, number

hunt only

The unit direction he looks along, on the ground.

Returns
numberdx
numberdz
local dx, dz = player.forward()
local x, _, z = player.pos()
world.spawn("velociraptor", x + dx * 3000, z + dz * 3000)

# player.health() → number

hunt only

The hunter's health.

Returns
numbercurrent health

# player.setHealth(health)

hunt only

Sets his health (he dies only by the game's own causes).

ParameterType
healthnumberabove 0, at most player.maxHealth()

# player.maxHealth() → number

The hunter's full health.

Returns
number

# player.alive() → boolean

Whether the hunter is alive (false outside a hunt).

Returns
boolean

# player.weapon() → integer

The current weapon.

Returns
integerthe weapon slot in hand, -1 = none

# player.ammo(slot?) → integer?, integer?

A weapon's ammunition; nothing outside a hunt, without a weapon in hand, or for the photo camera.

ParameterType
slot optionalintegera weapon slot (default: the one in hand)
Returns
integer?the ammunition left (what the HUD shows)
integer?the rounds loaded
local total, loaded = player.ammo()
if total then draw.text(20, 20, loaded .. " / " .. total) end

# player.aim(distance?) → string?, number?, number?, number?, Creature?

hunt only

What is under the crosshair: a ray from the hunter's eyes along his view.

ParameterType
distance optionalnumberhow far to look (default 20000)
Returns
string?"terrain", "water", "object" or "creature" (nothing when nothing is hit)
number?x of the point hit
number?y
number?z
Creature?the creature hit
local kind, x, y, z, c = player.aim()
if c then draw.text(20, 60, "Target: " .. c.name, "white", 20) end

# player.eye() → number, number, number

hunt only

Where the hunter's eyes (the camera) are.

Returns
numberx
numbery
numberz

# player.credits() → integer

The player's credits (the hunt menu's money).

Returns
integer

# player.addCredits(n) → integer

Gives or takes credits (kept with the game's save): rewards, shops, bets.

ParameterType
nintegercredits to give; negative takes (not below 0)
Returns
integerthe new amount
on("kill", function(e) if e.byHunter then player.addCredits(25) end end)

# player.camouflage(on?) → boolean

hunt only

The camouflage item: creatures see the hunter worse.

ParameterType
on optionalbooleanswitch it on / off
Returns
booleanwhether it is on

# player.scent(on?) → boolean

hunt only

The cover-scent item: creatures smell the hunter worse.

ParameterType
on optionalbooleanswitch it on / off
Returns
booleanwhether it is on