Skip to main content

Crumbs

Based on game build 714014 | Last updated: 2026-03-04

Overview

crumbs is a lightweight inventory item prefab representing food crumbs—typically used as bait for pets (e.g., beefalos) or as a minimal food source. It inherits from standard food mechanics via the edible component, supports stacking, and features full perish behavior via perishable. It is automatically removed upon spoiling.

The prefab integrates with multiple core systems: inventoryitem (for carrying), stackable (for stacking limit), bait (for pet attraction), and tradable/inspectable (for trade UI and inspection). It also implements burn and propagation properties and supports haunt mechanics.

Usage example

-- Example of spawning and configuring crumbs programmatically
local inst = SpawnPrefab("crumbs")
inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM
inst.components.edible.foodtype = FOODTYPE.GOODIES
inst.components.edible.healthvalue = 0
inst.components.edible.hungervalue = 1
inst.components.perishable:SetPerishTime(TUNING.PERISH_ONE_DAY)
inst.components.perishable:StartPerishing()

Dependencies & tags

Components used: inventoryitem, stackable, edible, bait, tradable, inspectable, perishable
Tags: catfood, crumbs

Properties

PropertyTypeDefault ValueDescription
stackable.maxsizenumberTUNING.STACK_SIZE_SMALLITEMMaximum stack size for the item.
edible.foodtypeFOODTYPEFOODTYPE.GOODIESIndicates the type of food (goodies).
edible.healthvaluenumber0Health restored per consumption.
edible.hungervaluenumber1Hunger restored per consumption.
perishable.perishtimenumberTUNING.PERISH_ONE_DAYTime (in seconds) until item spoils.
perishable.perishremainingtimenumberTime remaining until spoilage (updated automatically).

Main functions

inst.Remove()

  • Description: Removes the item instance from the world. Called automatically when the item perishes (via SetOnPerishFn).
  • Parameters: None.
  • Returns: Nothing.
  • Error states: None—safe to call directly or via perish callback.

Events & listeners

  • Pushes: onperish — implicitly via the perishable component’s internal handling (though not directly referenced in this file, the perish flow triggers component events).
  • Listens to: None explicitly in crumbs.lua; event handling is delegated to components like perishable.