Skip to main content

Lightbulb

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

Overview

The lightbulb prefab is an interactive item that functions as a portable light source, stackable inventory object, fuel, and consumable food. It integrates with multiple systems including lighting, fuel, edible, perishable, and Halloween event handling. It is pristined on creation and adds networked replication via AddNetwork(). Its behavior changes based on inventory state: light is disabled when held and enabled when dropped.

Usage example

local inst = SpawnPrefab("lightbulb")
inst.components.inventoryitem:PushToInventory(player)
-- When dropped by player, light automatically re-enables
inst.components.fuel.fuelvalue = TUNING.LARGE_FUEL -- adjust fuel value if needed

Dependencies & tags

Components used: stackable, tradable, vasedecoration, inspectable, fuel, edible, perishable, inventoryitem, halloweenmoonmutable
Tags added: lightbattery, vasedecoration, light

Properties

PropertyTypeDefault ValueDescription
pickupsoundstring"vegetation_firm"Sound played when picked up.
LightLight componentN/ALight emission settings (falloff, intensity, radius, colour, enabled state).
stackable.maxsizenumberTUNING.STACK_SIZE_SMALLITEMMaximum stack size.
fuel.fuelvaluenumberTUNING.MED_LARGE_FUELAmount of fuel this item provides.
fuel.fueltypeFUELTYPEFUELTYPE.CAVEFuel category used for matching against fuel sources.
edible.healthvaluenumberTUNING.HEALING_TINYHealth restored on consumption.
edible.hungervaluenumber0Hunger restored on consumption.
edible.foodtypeFOODTYPEFOODTYPE.VEGGIEFood classification for gameplay interactions.
perishable.perishtimenumberTUNING.PERISH_FASTTime until the item perishes.
perishable.onperishreplacementstring"spoiled_food"Prefab name to spawn on decay completion.

Main functions

This prefab does not define custom component methods; all functionality comes from attached components. Key configuration methods used during initialization include:

inst.components.inventoryitem:SetOnDroppedFn(fn)

  • Description: Assigns a callback that runs when the item is dropped from inventory.
  • Parameters: fn (function) — function taking inst as argument.
  • Returns: Nothing.

inst.components.inventoryitem:SetOnPutInInventoryFn(fn)

  • Description: Assigns a callback that runs when the item is placed into an inventory.
  • Parameters: fn (function) — function taking inst as argument.
  • Returns: Nothing.

inst.components.perishable:SetPerishTime(time)

  • Description: Sets the total time before the item perishes; initializes remaining time and restarts perishing task if active.
  • Parameters: time (number) — perish duration in seconds.
  • Returns: Nothing.

inst.components.perishable:StartPerishing()

  • Description: Starts the periodic task that tracks and decrements perish time.
  • Parameters: None.
  • Returns: Nothing.

inst.components.halloweenmoonmutable:SetPrefabMutated(prefab)

  • Description: Configures the prefab that replaces this item when mutated by the Halloween Moon.
  • Parameters: prefab (string) — prefab name to use on mutation ("lightflier" for this item).
  • Returns: Nothing.

Events & listeners

  • Listens to: None explicitly (event handling is delegated to components like inventoryitem, perishable, and halloweenmoonmutable).
  • Pushes: None directly (event emission is handled by attached components during lifecycle events).