Skip to content

Courage.Player#

require("Courage.Player") exposes save and position data via CrPlayerApi. Also available as require("Courage.Game").player.

API#

Function Returns Description
get_hearts() number Current life (in quarter hearts)
set_hearts(n) (none) Set current life
get_max_hearts() number Max life capacity
set_max_hearts(n) (none) Set max life capacity
get_magic() number Current magic
set_magic(n) (none) Set current magic
get_max_magic() number Max magic capacity
get_rupees() number Current rupee count
set_rupees(n) (none) Set rupee count
get_max_rupees() number Wallet capacity
get_position() x, y, z World coordinates (three numbers)
actor() lightuserdata? Pointer to the active player actor (daAlink_c*)
attention() lightuserdata? Pointer to player's target attention manager
combat_state() table? Table containing current combat state and target info
facing() table? Table containing movement speed and orientation angles
local Player = require("Courage.Player")

local hearts = Player.get_hearts()
Player.set_rupees(500)
Player.set_max_hearts(20) -- 20 quarter-hearts
local x, y, z = Player.get_position()
import * as Player from "Courage.Player"

const hearts = Player.get_hearts()
Player.set_rupees(500)
Player.set_max_hearts(20)
const [x, y, z] = Player.get_position()

Player combat and movement queries#

Player.actor() (returns lightuserdata or nil)#

Returns a raw native pointer to the active Link actor instance (daAlink_c*). Can be passed to Hook.View("daAlink_c", ptr) or Courage.Attach.

Player.attention() (returns lightuserdata or nil)#

Returns a raw native pointer to Link's target attention manager.

Player.combat_state() (returns table or nil)#

Returns a snapshot table of combat parameters, or nil if player is unavailable.

Field Type Description
sword_equipped boolean True if Link has a sword drawn
sword_available boolean True if a sword can be drawn
item_equipped boolean True if an item is actively held
equip_item integer Equipped item ID
proc_id integer Active process ID
locked_on boolean True if Z-targeting an actor
lock_type integer Target lock-on type index
target_is_enemy boolean True if current Z-target is an enemy
enemy_near boolean True if enemies are nearby
enemy_dist number Distance to nearest enemy in units
target lightuserdata? Native pointer to targeted actor

Player.facing() (returns table or nil)#

Returns a table with player movement and orientation parameters:

Field Type Description
angle_y integer Shape yaw angle
move_angle_y integer Current movement direction angle
speed number Current movement speed
is_wolf boolean True if Link is in Wolf form