Skip to content

Courage.World#

require("Courage.World") exposes the C CrWorldApi to Luau. The same table is available as require("Courage.Game").world.

API#

Function Returns Description
World.current_stage() string? Current start stage name (dComIfGp_getStartStageName)
World.current_layer() number Current stage layer (dComIfG_play_c::getLayerNo(0))
World.warp(stage, spawn, room, layer?) (none) Calls dComIfGp_setNextStage. Optional layer parameter (defaults to -1).
World.project(x, y, z) sx, sy, sz, visible Project 3D world position to 2D screen space. visible is true when the point is in front of the camera.
World.viewport() width, height Current viewport dimensions in pixels.
World.has_control() boolean true when the player has full game control (not paused, no event, no stage transition).
local World = require("Courage.World")

local stage = World.current_stage()
local layer = World.current_layer()
-- Warp to F_SP103 spawn 0 room 0 (defaults to layer -1)
World.warp("F_SP103", 0, 0)
-- Warp specifying the layer
World.warp("F_SP103", 0, 0, 2)
import * as World from "Courage.World"

const stage = World.current_stage()
const layer = World.current_layer()
// Warp to F_SP103 spawn 0 room 0 (defaults to layer -1)
World.warp("F_SP103", 0, 0)
// Warp specifying the layer
World.warp("F_SP103", 0, 0, 2)

World.project(x, y, z) -> sx, sy, sz, visible#

Projects a 3D world-space position to 2D screen-space coordinates using the current view matrix. Returns four values: the projected X, Y, Z coordinates plus a boolean that is true when the point is in front of the camera (viewspace Z < 0).

local World = require("Courage.World")

local sx, sy, sz, visible = World.project(linkX, linkY, linkZ)
if visible then
    -- draw a marker at (sx, sy) on screen
end
import * as World from "Courage.World"

const [sx, sy, sz, visible] = World.project(linkX, linkY, linkZ)
if (visible) {
    // draw a marker at (sx, sy) on screen
}

World.viewport() -> width, height#

Returns the current viewport dimensions in pixels as two numbers.

local w, h = World.viewport()
const [w, h] = World.viewport()

World.has_control() -> boolean#

Returns true when the game is in normal play: not paused, no menu open, no stage transition, no cutscene running.

local World = require("Courage.World")

function MyMod:tick()
    if not World.has_control() then return end
    -- mod logic here
end
import * as World from "Courage.World"

MyMod.tick = function () {
    if (!World.has_control()) return
    -- mod logic here
}

For accurate per-frame stage tracking during gameplay (chest lookups, region checks), prefer Courage.Hooks.trackStageName, which hooks daAlink_c::checkStageName.

Stage codes such as F_SP103 are on the Maps and Exits tabs of the TP Ultimate Spreadsheet.