Skip to main content

Acorn

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

Overview

The acorn prefab is a reusable item that allows players to plant deciduous trees. When deployed, it spawns an acorn_sapling, waits for it to grow, and has a chance to pacify a nearby monster tree (e.g., a Bee Tree or Man Rabbit Tree) by temporarily halting its aggressive behavior. It functions as a seed with decay properties and can be cooked into acorn_cooked, which has similar food value but faster spoilage.

The acorn integrates with multiple core systems: deployment (tree planting), perishability (spoiling), composting (brown matter), and entity behavior control (monster pacification).

Usage example

-- Spawn a pristine acorn and deploy it at position `pt`
local acorn = SpawnPrefab("acorn")
acorn.Transform:SetPosition(pt.x, pt.y, pt.z)
acorn.components.deployable:OnDeploy(pt)

-- After planting, the acorn is consumed and spawns a sapling
-- If a monster tree is found in range, it will be pacified for a short time

Dependencies & tags

Components used: cookable, tradable, perishable, edible, stackable, inspectable, inventoryitem, deployable, winter_treeseed, forcecompostable, burnable, propagator, hauntable

Tags added: deployedplant, icebox_valid, cattoy, show_spoilage, treeseed, cookable

Properties

PropertyTypeDefault ValueDescription
components.cookable.productstring"acorn_cooked"The prefab name produced when cooked.
components.perishable.perishtimenumberTUNING.PERISH_PRESERVEDTime in seconds before spoiling (pristine acorn).
components.perishable.onperishreplacementstring"spoiled_food"Prefab spawned upon spoiling.
components.edible.healthvaluenumberTUNING.HEALING_TINYHealth restored per consumption.
components.edible.hungervaluenumberTUNING.CALORIES_TINYHunger restored per consumption.
components.edible.foodtypeFOODTYPEFOODTYPE.RAWFood classification (changes to SEEDS when cooked).
components.stackable.maxsizenumberTUNING.STACK_SIZE_SMALLITEMMaximum stack size.
components.deployable.modeDEPLOYMODEDEPLOYMODE.PLANTDeployment behavior type.
components.winter_treeseed.winter_treestring"winter_deciduoustree"Tree prefab to spawn when planted in winter.

Main functions

ondeploy(inst, pt)

  • Description: Called when the acorn is deployed (e.g., via right-click placement). Spawns a sapling, plays a sound, and attempts to pacify the nearest visible monster tree within radius TUNING.DECID_MONSTER_ACORN_CHILL_RADIUS. The acorn is consumed in the process.
  • Parameters:
    inst (Entity) — the acorn instance being deployed.
    pt (Vector3) — target position for planting.
  • Returns: Nothing.
  • Error states: Returns early if deployment fails (e.g., due to stackable:Get() returning nil). The pacification logic respects burn state and stump tags.

OnLoad(inst, data)

  • Description: Restoration function used during world load. If saved data includes growtime, it immediately plants the tree without waiting for sapling growth.
  • Parameters:
    inst (Entity) — the acorn instance being loaded.
    data (table or nil) — serialized data with optional data.growtime (number).
  • Returns: Nothing.

Events & listeners

  • Listens to: None explicitly registered.
  • Pushes: None. Event interactions occur via external components (deployable.ondeploy is invoked by the deploy system, not pushed by this entity).