Furnituredecortaker
Based on game build 714014 | Last updated: 2026-03-03
Overview
FurnitureDecorTaker handles the logic for accepting, attaching, and removing decorative items placed on furniture entities (e.g., lamps on desks). It ensures proper tag management (furnituredecortaker, hasfurnituredecoritem) and coordinates with furnituredecor and inventoryitem components to manage item ownership and placement state. The component supports event callbacks, save/load persistence, and network synchronization.
Usage example
local inst = CreateEntity()
inst:AddComponent("furnituredecortaker")
-- Optional: Set custom acceptance logic and callbacks
inst.components.furnituredecortaker.abletoaccepttest = function(inst, item, giver) return item:HasTag("lamp") end
inst.components.furnituredecortaker.ondecorgiven = function(inst, item, giver) print("Decoration placed!") end
inst.components.furnituredecortaker.ondecortaken = function(inst, item) print("Decoration removed!") end
-- Accept a decorative item
inst.components.furnituredecortaker:AcceptDecor(lamp_entity, player_entity)
Dependencies & tags
Components used: furnituredecor, inventoryitem, stackable
Tags: Adds furnituredecortaker when the component is active; adds hasfurnituredecoritem when a decoration is present.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
enabled | boolean | true | Whether the entity can accept new decorative items. |
decor_item | Entity or nil | nil | The current decorative item attached to this entity, or nil if none. |
abletoaccepttest | Function or nil | nil | Optional callback: (inst, item, giver) → boolean to override acceptance logic. |
ondecorgiven | Function or nil | nil | Optional callback: (inst, item, giver) fired when an item is placed. |
ondecortaken | Function or nil | nil | Optional callback: (inst, item) fired when an item is removed or taken. |
Main functions
SetEnabled(enabled)
- Description: Enables or disables acceptance of new decorative items. Automatically manages the
furnituredecortakertag. - Parameters:
enabled(boolean) — whether to allow accepting decorations. - Returns: Nothing.
AbleToAcceptDecor(item, giver)
- Description: Checks if the entity can currently accept the given decorative item. Honors the
enabledstate and optionalabletoaccepttestcallback. - Parameters:
item(Entity) — the proposed decorative item.giver(Entity) — the entity giving/placing the item (may benil).
- Returns:
trueif the item can be accepted, otherwisefalse. - Error states: Returns
falseifitemisnilorenabledisfalse.
AcceptDecor(item, giver)
- Description: Accepts and attaches a decorative item. Removes the item from its previous owner, sets up callbacks for removal/pickup events, and notifies connected systems via
furnituredecor:PutOnFurniture. - Parameters:
item(Entity) — the decorative item to attach.giver(Entity) — the entity providing the item (may benil).
- Returns:
true. - Error states: Returns early (no action) if
AbleToAcceptDecorwould returnfalse. Handles stackable items by converting to their base unit if necessary.
TakeItem()
- Description: Removes the current decorative item, restores the entity to an
enabledstate, cleans up event listeners, and notifies connected systems viafurnituredecor:TakeOffFurniture. - Parameters: None.
- Returns: The removed decorative item (Entity), or
nilif no item was attached.
OnSave()
- Description: Serializes the GUID of the attached decorative item for saving to disk.
- Parameters: None.
- Returns:
{item_guid = GUID}, ornilif no decorative item is attached.
LoadPostPass(ents, data)
- Description: Reattaches a previously saved decorative item after world load, by retrieving the entity from
entsusing the stored GUID. - Parameters:
ents(table) — mapping of GUIDs to entity data.data(table) — must containitem_guid.
- Returns: Nothing.
GetDebugString()
- Description: Returns a human-readable string for debugging UI (e.g., in entity inspection tools).
- Parameters: None.
- Returns:
"Can Take: True"or"Can Take: False"based onenabled.
Events & listeners
- Listens to:
onremove(ondecor_item) — triggers_on_decor_item_removedwhen the item is destroyed.onpickup(ondecor_item) — triggers_on_decor_item_picked_upwhen the item is picked up.
- Pushes:
- None directly. Callbacks (
ondecorgiven,ondecortaken) are invoked as side effects ofAcceptDecorandTakeItem.
- None directly. Callbacks (