Egg
Based on game build 714014 | Last updated: 2026-03-05
Overview
This file defines three related prefabs—bird_egg, bird_egg_cooked, and rottenegg—that represent different states of a bird egg in the game. It uses a shared commonfn to set up common base properties (e.g., transform, animation, network, physics), then customizes behavior per state via dedicated constructor functions (defaultfn, cookedfn, rottenfn). Key interactions include edible nutrition, perishability with replacement items, cooking, and decomposition into usable fertilizer.
Usage example
-- Create a raw bird egg
local egg = Prefab("bird_egg", ...)
-- Access its components after spawning
local inst = SpawnPrefab("bird_egg")
inst.components.edible.hungervalue = 5
inst.components.perishable:StartPerishing()
Dependencies & tags
Components used: edible, cookable, perishable, stackable, bait, inspectable, inventoryitem, tradable, floater, fuel, fertilizer, fertilizerresearchable
Tags added: catfood, cookable, icebox_valid, cattoy, fertilizerresearchable
Tags checked: TheWorld.ismastersim
Properties
No public properties are defined directly in this file. All components rely on their own internal state.
Main functions
commonfn(anim, cookable)
- Description: Shared constructor for all egg prefabs. Sets up physics, animation, network, inventory, and core components (e.g., edible, perishable, stackable). Conditionally adds cookable behavior.
- Parameters:
anim(string) – Animation state to play ("idle","cooked","rotten").
cookable(boolean) – If true, adds thecookabletag and thecookablecomponent withproduct = "bird_egg_cooked". - Returns:
inst(Entity) – The constructed entity, or the entity without simulation components on the client. - Error states: None. Returns early on the client if
TheWorld.ismastersimis false.
defaultfn()
- Description: Constructs a pristine raw bird egg. Sets low nutritional values, medium perish time, and enables floater properties for visual floatation.
- Parameters: None.
- Returns:
inst(Entity) – The raw egg entity withtradable.rocktribute = 1. - Note: Overrides
healthvalueandsanityvalueto0aftercommonfn, and setshungervalue = TUNING.CALORIES_TINY.
cookedfn()
- Description: Constructs a cooked bird egg. Has higher hunger restoration than raw, faster perish rate, and replaces with
spoiled_food. - Parameters: None.
- Returns:
inst(Entity) – Cooked egg entity withfloaterscale and size adjusted for visual distinction. - Note: Sets
hungervalue = TUNING.CALORIES_SMALLandperishreplacement = "spoiled_food".
rottenfn()
- Description: Constructs a rotten egg prefab. Adds fertilizer functionality, fuel value, and small burnable behavior.
- Parameters: None.
- Returns:
inst(Entity) – Rotten egg entity withfertilizercomponent initialized using nutrient data fromFERTILIZER_DEFS.rottenegg. - Note: Adds a custom method
GetFertilizerKey(inst)and assignsfertilizerresearchablewith a research function.
Events & listeners
None identified. This file defines prefabs and their initialization logic but does not register event listeners or push events directly.