Play Commonfn
Based on game build 714014 | Last updated: 2026-03-10
Overview
play_commonfn is a utility module containing shared helper functions used during scripted play sequences and cinematic events in Don't Starve Together. These functions manage actor positioning, visual effects (FX), costume/mask swaps, sound playback, and coordination with the game's stategraph and locomotion systems. It is typically invoked by higher-level play/script systems rather than being attached as a component.
Usage example
local fns = require "play_commonfn"
-- Position actors around a center entity (e.g., a stage)
fns.findpositions(center_inst, {
roles = {"ACTOR1", "ACTOR2"},
positions = {ACTOR1 = 1, ACTOR2 = 2},
duration = 1.0
}, cast)
-- Trigger mask blinking effect
fns.maskflash(center_inst, {line = {...}, time = 0.5}, cast)
-- Swap actor costumes dynamically
fns.swapmask(center_inst, {
roles = {"ACTOR1"},
mask = "mask_waxwell",
body = "costume_summer"
}, cast)
Dependencies & tags
Components used: stageactingprop, inventory, locomotor, rider, skinner, talker, health, sleeper, revivablecorpse, container, stackable, Physics, AnimState, Transform, SoundEmitter, Follower.
Tags: Checks for player, equipmentmodel, ignoretalking, debuffed, buffed, away; not responsible for adding/removing tags.
Properties
No public properties.
Main functions
callbirds(inst, line, cast)
- Description: Instructs birds (
BIRD1,BIRD2) to enter the stage and adds the narrator to the cast. Used to initiate a bird performance sequence. - Parameters:
inst(entity) — The center entity (typically the stage/narrator).line(table) — Script line data (unused directly, but may contain timing hints).cast(table | nil) — Map of costume names to cast data ({castmember = entity}). May benil.
- Returns: Nothing.
- Error states: Does nothing if
castisnilor stageactingprop is missing.
exitbirds(inst, line, cast)
- Description: Signals birds to exit the stage (sets
exited_stage = true) after a short delay. - Parameters:
- Same as
callbirds.
- Same as
- Returns: Nothing.
actorscurtsey(inst, line, cast)
- Description: Instructs all actors in the cast to perform a curtsy with randomized timing.
- Parameters: Same as
callbirds. - Returns: Nothing.
actorsbow(inst, line, cast)
- Description: Instructs all actors in the cast to perform a bow with randomized timing.
- Parameters: Same as
callbirds. - Returns: Nothing.
do_mask_blink(inst, line, cast)
- Description: Spawns and attaches
mask_halfwit_fxto each actor’s head (used for mask blinking effects). - Parameters: Same as
callbirds. - Returns: Nothing.
marionetteon(inst, line, cast)
- Description: Spawns a timed
marionette_appear_fxon each non-bird/narrator actor to simulate marionette control activation. - Parameters: Same as
callbirds. - Returns: Nothing.
marionetteoff(inst, line, cast)
- Description: Spawns a timed
marionette_disappear_fxon each non-bird/narrator actor to simulate marionette control deactivation. - Parameters: Same as
callbirds. - Returns: Nothing.
startbgmusic(inst, line, cast)
- Description: Sets background music type based on
line.musictype. Ifmusictypeis missing, defaults to1. - Parameters: Same as
callbirds. - Returns: Nothing.
stopbgmusic(inst, line, cast)
- Description: Sets background music type to
0(off). - Parameters: Same as
callbirds. - Returns: Nothing.
stageon(inst)
- Description: Forces the narrator’s stategraph into the
"narrator_on"state. - Parameters:
inst(entity) — The narrator entity.
- Returns: Nothing.
stageoff(inst)
- Description: Forces the narrator’s stategraph into the
"narrator_off"state. - Parameters: Same as
stageon. - Returns: Nothing.
stinger(inst, line)
- Description: Triggers a stinger sound/state transition in the narrator’s stategraph, passing
line.soundas the state parameter. - Parameters:
inst(entity) — The narrator entity.line(table) — Must containsound(string).
- Returns: Nothing.
findlucy(player)
- Description: Locates a
lucyitem on or in the player’s inventory (including overflow and open containers). - Parameters:
player(entity) — Player entity.
- Returns:
lucyitem entity ornil.
lucytalk(inst, line, cast)
- Description: If
line.lucytestspecifies a costume in the cast, locateslucyfor that actor and has it speakline.lineusing itstalkercomponent. - Parameters: Same as
callbirds. - Returns: Nothing.
maskflash(inst, line, cast)
- Description: Applies a bloom and pulsing color overlay to each actor’s hat (
swap_hatsymbol) using a periodic task, then clears the effect afterline.timeseconds. - Parameters: Same as
callbirds. - Returns: Nothing.
enableblackout(inst)
- Description: Finds all players within
25units ofinstthat have a_blackoutproperty and activates it. Tracks them ininst.blackoutviewers. - Parameters:
inst(entity) — The blackout source.
- Returns: Nothing.
disableblackout(inst)
- Description: Disables
_blackoutfor all players previously recorded ininst.blackoutviewers. - Parameters: Same as
enableblackout. - Returns: Nothing.
waxwelldancer(inst, line, cast)
- Description: Spawns a
shadowdancerentity, positions it relative toinstusingline.thetaandline.radius, copies the caster’s skins, and schedules its quickdespawn afterline.time. - Parameters: Same as
callbirds. - Returns: Nothing.
crowdcomment(inst, line, cast)
- Description: Finds nearby players who are not in the current cast and match one of
line.prefabs, then has one randomly chosen actor performline.animand speakline.line. - Parameters: Same as
callbirds. - Returns: Nothing.
isplayercostume(costume)
- Description: Returns
trueifcostumeis not one of the reserved names ("BIRD1","BIRD2","NARRATOR"). - Parameters:
costume(string) — A costume label.
- Returns:
boolean.
swapmask(inst, line, cast)
- Description: Equips new masks and/or clothing items (
line.mask,line.body) for each actor listed inline.roles, replacing their existing items. - Parameters: Same as
callbirds. - Returns: Nothing.
findpositions(inst, line, cast)
- Description: Calculates target positions for each actor based on
line.positions, using a predefinedPOSITIONStable. Useslocomotor:GoToPointif available; otherwise teleports with animation. - Parameters: Same as
callbirds. - Returns: Nothing.
override_with_chalice(inst, line, cast)
- Description: Overrides the
ghostly_elixirs_swapsymbol on each actor’sAnimStateto display thechalice_swapmodel. - Parameters: Same as
callbirds. - Returns: Nothing.
clear_chalice_symbol(inst, line, cast)
- Description: Clears the chalice symbol override on each actor.
- Parameters: Same as
callbirds. - Returns: Nothing.
override_with_dagger(inst, line, cast)
- Description: Overrides the
swap_objectsymbol tovault_daggerand showsARM_carry/hidesARM_normalon each actor. - Parameters: Same as
callbirds. - Returns: Nothing.
clear_dagger_symbol(inst, line, cast)
- Description: Clears the dagger override and restores the previous
swap_objectsymbol; toggles arm animations back. - Parameters: Same as
callbirds. - Returns: Nothing.
do_emote_fx(inst, line, cast)
- Description: Spawns
emote_fx, parents it to each actor, and attaches it to either"emotefx"or"headbase"depending on theequipmentmodeltag. - Parameters: Same as
callbirds. - Returns: Nothing.
play_sound_with_delay_fn_constructor(delay, sound_name)
- Description: Returns a callable function that, when invoked with
(inst, line, cast), playssound_nameon all actors afterdelayseconds. - Parameters:
delay(number) — Delay in seconds.sound_name(string) — Sound event name.
- Returns:
function(inst, line, cast)— A function suitable for use in play scripts.
apply_vault_dagger(inst, line, cast)
- Description: Applies a symbol override to
vault_dagger01for all actors in the cast. - Parameters: Same as
callbirds. - Returns: Nothing.
Events & listeners
- Listens to: Uses
inst:DoTaskInTimeandinst:DoPeriodicTaskfor delayed tasks; does not registerListenForEventhandlers itself. - Pushes: Pushes events via actor entities (e.g.,
"acting","arrive","dance","perform_do_next_line"); does not push events itself directly.