actor
An actor reference is returned when you spawn an actor and is available to the actor’s own behaviour. Use its methods with a colon, such as actor:snapshot(). A reference stops working after the callback that gave it to you finishes.
actor:snapshot
Section titled “actor:snapshot”Read a copy of an actor’s current state.
Signature: actor:snapshot()
Returns: A copy with the fighter snapshot fields plus id, definition, team, target_id, age_frames and lifetime_frames; nil, error after the actor ended.
When: The callback that obtained the actor
local view = actor:snapshot()if view then sf2.log.info(view.id .. " team=" .. view.team .. " x=" .. view.position.x)endteam is "player" or "opponent". target_id is "player", "opponent", an actor ID or absent. To use an actor later, keep its ID and fetch it again with fighter:actors; keeping the reference itself is an error.
actor:change_form
Section titled “actor:change_form”Turn a living actor into a different character, while it stays the same actor.
Signature: local request = actor:change_form(character)
Parameters
| Parameter | Type | Required |
|---|---|---|
character |
WarriorHandle |
Required |
Returns: A receipt whose status starts as "queued" and becomes "applied" or "failed" (with an error).
When: Active offline, non-raid combat callbacks; not on_actor_end
local transform = { state = { lifetime = "round", fields = { requested = { type = "boolean", default = false }, } }, on_tick = function(self, fighter) if not self.state.requested then self.state.requested = true fighter.actor:change_form(alternate) -- alternate: a registered fighter end end,}The change happens after the current step. The actor keeps its ID, team, owner, behavior state, age and health percentage (it is not healed). The new character supplies body, equipment, moves and tactic; AI memory starts fresh and an attack in progress does not continue. No spawn or end event is sent. Death, removal or round end cancels a pending change.
Inside the actor’s own behavior, fighter:change_form does the same thing.
actor:change_health
Section titled “actor:change_health”Damage (negative) or heal (positive) the actor’s own health.
Signature: actor:change_health(amount)
Parameters
| Parameter | Type | Required |
|---|---|---|
amount |
number |
Required |
Returns: true, nil if queued, or false, error if invalid.
When: The callback that obtained the actor
local view = actor:snapshot()if view then actor:change_health(-view.max_health) endCreates no attacker and calls no hit callback. An actor reaching zero health ends with a died event.
actor:move_by
Section titled “actor:move_by”Push the actor sideways, up or down by a set distance without changing its animation.
Signature: actor:move_by(x, y, z?)
Parameters
| Parameter | Type | Required |
|---|---|---|
x |
number |
Required |
y |
number |
Required |
z |
number? |
Required |
Returns: true, nil if queued, or false, error if rejected.
When: The callback that obtained the actor
local ok, error = actor:move_by(10, 0)if not ok then sf2.log.warn(error) endA one-time shift applied after the step’s collision work, not a speed or pathfinding. The arena’s limits still apply.
actor:play_move
Section titled “actor:play_move”Make the actor play a registered move, using its own rig and equipment.
Signature: actor:play_move(move)
Parameters
| Parameter | Type | Required |
|---|---|---|
move |
MoveHandle |
Required |
Returns: A receipt with status ("queued", "applied" or "failed") and an error on failure.
When: The callback that gave you the actor
local receipt = actor:play_move(strike) -- strike from sf2.moves.registerWorks like fighter:play_move. The move starts after the step’s collision work, one request per actor per step. The receipt fails if the actor’s rig or equipment cannot play the move, or it dies or is removed first.
actor:remove
Section titled “actor:remove”Dismiss an actor and remove its weapon children.
Signature: actor:remove()
Returns: true, nil if queued, or false, error if already unavailable.
When: The callback that obtained the actor
for _, actor in ipairs(fighter:actors() or {}) do actor:remove() endThe actor becomes unavailable immediately. A removed event appears later in fighter:actor_events.
actor:set_target
Section titled “actor:set_target”Choose which enemy this actor attacks, or return to automatic selection.
Signature: actor:set_target(target)
Parameters
| Parameter | Type | Required |
|---|---|---|
target |
"player"|"opponent"|"nearest"|Actor |
Required |
Returns: true, nil if accepted, or false, error for a friendly, defeated, self or unavailable target.
When: The callback that gave you both actors
local actors = fighter:actors() or {}if #actors == 2 then actors[1]:set_target(actors[2]) end-- or actor:set_target("opponent") / actor:set_target("nearest")Valid targets are "player", "opponent", "nearest" or a live actor from this mod fetched in this callback. Automatic selection picks the closest living enemy. A chosen target stays while valid, and a change waits until the current attack finishes.