Appearance
sdk.cave_action_graph
Deterministic checkpoint action graph. Documents contain data only: custom behavior is resolved by registered callback name, never by executing strings.
lua
local M = require("sdk.cave_action_graph")Constants
Lua 5.4 has no enums — these are integer (or string) fields on the module.
| Name | Value | Summary |
|---|---|---|
Graph | Graph | Cave-action graph class. |
from_plan
function · from_plan(plan)
Prefer an explicit caveActionGraph / hunt.actionGraph. Otherwise collect hunt.checkpoints that already carry actions, branches, or a label.
from_checkpoints
function · from_checkpoints(checkpoints)
Build a linear graph from a checkpoint list, filling next when the author omitted it. Terminal nodes stay unlinked.
validate
function · validate(definition, opts)
Compile + schema-check. Mutates action.type to the lowercased kind, forbids raw code, and requires every next/branch/on_* label to exist. Sets graph._compiled and graph.labels on success.
compile
function · compile(definition, opts) return M.validate(definition, opts)
Alias of validate. Hosts that say "compile" share the same object.
register
function · register(name, fn)
Install a named callback used by action.type=callback / condition kind=callback. Documents store the name, never the function.
unregister
function · unregister(name)
Drop a registered callback. Returns whether the name existed.
new
function · new(definition, opts)
Construct a Graph from a compiled or raw definition. owner_name is unique per instance so two graphs do not coalesce each other's tickets.