Goatmilk
Based on game build 722832 | Last updated: 2026-04-28
Overview
goatmilk.lua registers a spawnable food item entity that players can obtain from domesticated beefalo. The prefab's fn() constructor builds the physics body, attaches animation state, and adds client-side components. Server-side gameplay components (edible, perishable, stackable, tradable, inventoryitem, inspectable) are attached only on the master simulation. The prefab is referenced by its name "goatmilk" and instantiated with SpawnPrefab("goatmilk").
Usage example
-- Spawn goatmilk at world origin:
local inst = SpawnPrefab("goatmilk")
inst.Transform:SetPosition(0, 0, 0)
-- Access edible component values:
local health = inst.components.edible.healthvalue
local hunger = inst.components.edible.hungervalue
-- Check perishable state:
local perish_pct = inst.components.perishable:GetPerishPercent()
-- Stack with other goatmilk items:
inst.components.stackable:Add(5)
Dependencies & tags
External dependencies:
MakeInventoryPhysics-- applies physics and floatable behavior for inventory itemsMakeInventoryFloatable-- enables water floating with specified buoyancy parametersMakeHauntableLaunch-- makes item react to ghost haunt actions
Components used:
edible-- provides health, hunger, sanity, and charge values when consumedperishable-- handles spoilage over time with replacement on perishstackable-- allows stacking up to TUNING.STACK_SIZE_SMALLITEMtradable-- enables trading with other playersinspectable-- allows player inspectioninventoryitem-- enables pickup and inventory storage
Tags:
catfood-- added in fn(); marks item as valid food for catsfooddrink-- added in fn(); categorizes item as drinkable food
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
assets | table | {Asset("ANIM", "anim/goatmilk.zip")} | Array of asset entries listing animation files loaded with this prefab. |
prefabs | table | {"spoiled_food"} | Array of dependent prefab names that must be loaded; spawned when this item perishes. |
Main functions
fn()
- Description: Prefab constructor function. Creates the entity, builds transform and anim state, sets default animation to "idle", applies inventory physics, adds tags, and makes the item floatable. On master simulation, attaches gameplay components (edible, perishable, stackable, tradable, inspectable, inventoryitem) and configures their properties from TUNING constants. Returns
instfor framework processing. - Parameters: None
- Returns: entity instance
- Error states: None — runs on every host with master-side logic guarded by
TheWorld.ismastersimcheck.
Events & listeners
None identified.