Scarecrow
Based on game build 714014 | Last updated: 2026-03-07
Overview
The scarecrow prefab is a static structure used for decoration and interaction. It supports physical interaction via hammering, burning, and dressing-up (via wardrobe component), and includes networking support for client-server synchronization. It utilizes several core components (playeravatardata, lootdropper, workable, wardrobe, burnable, skinner, inspectable) to enable dynamic behavior such as face changes, clothing state persistence, and loot generation upon destruction or burning. It is typically placed using the MakePlacer helper and deployed with a smart radius.
Usage example
local scarecrow = SpawnPrefab("scarecrow")
scarecrow.Transform:SetPosition(x, y, z)
scarecrow.components.wardrobe.ondressupfn = function(inst, cb)
-- custom dressup logic
inst.components.wardrobe:Enable(false)
cb()
end
Dependencies & tags
Components used: playeravatardata, lootdropper, workable, wardrobe, burnable, skinner, inspectable, soundemitter, animstate, transform, minimapentity, network
Tags: structure, scarecrow, NOCLICK (temporarily added during dressing transformation), burnt (added when burnt), fire (used internally to alter face animation)
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
face | number | 1 | Current face index; incremented/changed by ChangeFace. Used to select which texture variant to display via OverrideSymbol. |
_dressuptask | Task | nil | Task handle for dressing-up animation duration. Used to track state and cancel ongoing transformations. |
Main functions
ChangeFace(inst, prefix)
- Description: Changes the scarecrow's facial texture by selecting a random variant from predefined sets (
hit,scary,screaming) based on theprefix. If the scarecrow has thefiretag, it forces thescreamingset. - Parameters:
inst(Entity) — the scarecrow entity instance.prefix(string, optional) — animation prefix:"hit","scary", or"screaming". Defaults to"scary".
- Returns: Nothing.
- Error states: None; always sets
inst.faceand updates theswap_scarecrow_facesymbol.
onhammered(inst)
- Description: Called when the scarecrow is fully hammered (i.e.,
workabletask completes). Drops loot, spawns acollapse_bigFX entity, and removes the scarecrow entity. - Parameters:
inst(Entity) — the scarecrow entity instance.
- Returns: Nothing.
onhit(inst)
- Description: Called when the scarecrow is partially hammered (each work step). Plays the
"hit"animation and triggers a face change to"hit"if not dressing up or burnt. - Parameters:
inst(Entity) — the scarecrow entity instance.
- Returns: Nothing.
- Error states: No-op if
IsDressingUp(inst)istrueorinst:HasTag("burnt")istrue.
onbuilt(inst)
- Description: Called after the scarecrow is placed via crafting/building. Plays
"place"animation, queues"idle", and plays the crafting sound. - Parameters:
inst(Entity) — the scarecrow entity instance.
- Returns: Nothing.
ondressup(inst, cb)
- Description: Initiates the dressing-up transformation sequence. Disables
wardrobe, addsNOCLICK, plays"transform"animation, queues"idle", and sets a delayed callback toontransformend. - Parameters:
inst(Entity) — the scarecrow entity instance.cb(function, optional) — optional callback executed after transformation starts.
- Returns: Nothing.
- Error states: No-op if
inst:HasTag("burnt")istrue.
ondressedup(inst, data)
- Description: Records the dresser’s name and clothing/skin data into the scarecrow's
playeravatardatacomponent for display persistence. - Parameters:
inst(Entity) — the scarecrow entity instance.data(table) — containsdoer,skins, etc., passed by thedressedupevent.
- Returns: Nothing.
- Error states: No-op if
inst:HasTag("burnt")istrue.
onsave(inst, data)
- Description: Saves burning state to the world save data.
- Parameters:
inst(Entity) — the scarecrow entity instance.data(table) — save table to mutate.
- Returns: Nothing.
onload(inst, data)
- Description: Loads saved state and re-applies player data if not burnt. If burnt, triggers
onburntto restore burnt state. - Parameters:
inst(Entity) — the scarecrow entity instance.data(table, optional) — loaded save data.
- Returns: Nothing.
Events & listeners
- Listens to:
"onbuilt"— triggersonbuilt."dressedup"— triggersondressedup.
- Pushes: None directly.
- Callback hooks:
inst.OnEntityWake→ChangeFaceinst.OnSave→onsaveinst.OnLoad→onload