Canary Poisoned
Based on game build 714014 | Last updated: 2026-03-04
Overview
canary_poisoned is a prefab representing a poisoned canary creature. It is a non-player entity that enters a "struggling" state, cannot be picked up by players while alive or dead, and begins spoiling (perishing) only after being placed in an inventory. It uses the SGcanarypoisoned state graph and integrates with the health, inventoryitem, perishable, lootdropper, and hauntable components to simulate its behavior in the game world.
Usage example
This prefab is instantiated automatically via the Prefab system. Typical usage involves spawning it as part of game logic (e.g., after a player consumes contaminated food), where it automatically handles spoilage, loot dropping, and pickup restrictions.
-- Spawn example (not usually needed directly)
local inst = TheWorld:PushWorldEntity("canary_poisoned")
-- The entity is pre-configured by its constructor (`fn`)
-- and starts with 48% spoilage, no loot yet, and pickup disabled.
Dependencies & tags
Components used: lootdropper, inventoryitem, health, combat, inspectable, hauntable, perishable
Tags added: bird, canary, smallcreature, small_livestock, show_spoilage, sickness, untrappable
Properties
No public properties are defined in the constructor. All configuration is done via component method calls.
Main functions
The constructor defines only private helper functions (PreventPickup, AllowPickup, OnPutInInventory, OnDropped). These are used as callbacks by inventoryitem:
PreventPickup(inst)
- Description: Disables pickup for the entity by setting
canbepickeduptofalse. Typically called ondeathorfreezeevents. - Parameters:
inst(Entity) — The canary entity instance. - Returns: Nothing.
AllowPickup(inst)
- Description: Enables pickup only if the entity is not in the
nopickupstate tag and is not dead. Called onunfreezeevents. - Parameters:
inst(Entity) — The canary entity instance. - Returns: Nothing.
OnPutInInventory(inst)
- Description: Starts the spoilage timer when the canary is placed into a player's inventory.
- Parameters:
inst(Entity) — The canary entity instance. - Returns: Nothing.
OnDropped(inst)
- Description: Stops spoilage and transitions the canary to the
"dropped"state if it is not dead. Prevents further spoilage while on the ground. - Parameters:
inst(Entity) — The canary entity instance. - Returns: Nothing.
Events & listeners
- Listens to:
death— triggersPreventPickupto disable pickup. - Listens to:
freeze— triggersPreventPickupto disable pickup while frozen. - Listens to:
unfreeze— triggersAllowPickupto re-enable pickup if conditions are met. - Pushes: None directly. Event emission is handled by attached components (e.g.,
perishablefiresperishchange,healthfiresdeath), but this prefab does not register custom listeners for those events.