Carnivaldecor Lamp
Based on game build 714014 | Last updated: 2026-03-04
Overview
The carnivaldecor_lamp is a prefabricated structure that functions as a decorative lamp in the game world. It supports three activation methods: manual activation (via quick action), inserting a carnival_gametoken, and natural toggling via its activatable and trader components. When active, it emits light, plays ON animations, and automatically turns off after a configurable duration. It integrates with workable (hammered), lootdropper, carnivaldecor, and save/load systems, making it suitable for event-based decorations in the Summer Carnival minigame.
Usage example
local lamp = SpawnPrefab("carnivaldecor_lamp")
lamp.Transform:SetPosition(entity.Transform:GetWorldPosition())
lamp:DoTaskInTime(2, function()
-- Manually trigger activation
lamp.components.activatable:OnActivate(lamp)
end)
Dependencies & tags
Components used: inspectable, lootdropper, carnivaldecor, workable, trader, activatable, burnable, propagator, fueled, soundemitter, light, animstate, transform, network
Tags added: carnivaldecor, carnivallamp, structure, cattoyairborne
Tags checked: inactive (in AbleToAcceptTest)
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
shape | number | math.random(6) | Random integer (1–6) indicating the lamp's visual variant. Used in animation selection (e.g., "idle1_on"). |
turnofftask | Task? | nil | Active task scheduled to turn off the lamp after a duration. |
Main functions
EnableLight(inst, duration)
- Description: Turns the lamp ON, starts a delayed task to turn it OFF after
durationseconds, and resets any existing OFF task. - Parameters:
duration(number) — time in seconds before the lamp automatically turns off. - Returns: Nothing.
LightOn(inst)
- Description: Enables the lamp's light source, plays the "idle#_on" animation, and sets
activatable.inactivetofalse. - Parameters:
inst— the entity instance. - Returns: Nothing.
LightOff(inst)
- Description: Disables the lamp's light source, plays the "idle#_off" animation, sets
activatable.inactivetotrue, and cancels the OFF task if present. - Parameters:
inst— the entity instance. - Returns: Nothing.
OnActivate(inst, doer)
- Description: Handler for manual activation (e.g., via quick action). Calls
EnableLightwithTUNING.CARNIVALDECOR_LAMP_ACTIVATE_TIME. - Parameters:
doer(Entity) — the entity performing the activation. - Returns:
true
OnAcceptItem(inst, doer)
- Description: Handler for
trader.onaccept— called when a valid item is accepted (e.g., acarnival_gametoken). CallsEnableLightwithTUNING.CARNIVALDECOR_LAMP_TOKEN_TIME. - Parameters:
doer(Entity) — the entity inserting the item. - Returns:
true
AbleToAcceptTest(inst, item, giver)
- Description: Predicate function used by
traderto determine whether to accept an item. - Parameters:
item(Entity) — the item to evaluate.giver(Entity) — the source entity.
- Returns:
trueifitem.prefab == "carnival_gametoken"; otherwise returnsfalse, "CARNIVALGAME_INVALID_ITEM". - Error states: Does not currently enforce the
inactivetag check (line is commented out).
onhammered(inst, worker)
- Description: Callback for
workablewhen the lamp is hammered. Spawns a small collapse FX, drops loot, and removes the lamp entity. - Parameters:
worker(Entity) — the entity performing the hammering. - Returns: Nothing.
Events & listeners
- Listens to:
onbuilt— callsonbuilt(inst)to play the placement animation and sound. - Pushes: None directly. Relies on underlying components (
lootdropper,workable) for standard event propagation.