Ghostlyelixir
Based on game build 714014 | Last updated: 2026-03-03
Overview
Ghostlyelixir is a component that enables an entity to act as a ghostly elixir item—consumable by players or other entities to trigger specific gameplay effects. It integrates with the ghostlyelixirable and stackable components to determine the recipient and manage item consumption. The component is typically attached to elixir prefabs and ensures proper cleanup after use.
Usage example
local inst = SpawnPrefab("ghostlyelixir")
inst.components.ghostlyelixir.doapplyelixerfn = function(elixir, doer, target)
-- Custom effect logic here
return true
end
-- Later, during inventory interaction:
inst.components.ghostlyelixir:Apply(player, player)
Dependencies & tags
Components used: inventoryitem, stackable, ghostlyelixirable
Tags: Adds ghostlyelixir on instantiation; removes ghostlyelixir on removal from entity.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
doapplyelixerfn | function | nil | Optional callback function (elixir, doer, target) -> (boolean success, string? reason) defining custom application logic. |
Main functions
Apply(doer, target)
- Description: Attempts to apply the elixir's effect to the specified target. Delegates final recipient determination to
ghostlyelixirable:GetApplyToTarget(), invokesdoapplyelixerfnif defined, and consumes the elixir upon success. - Parameters:
doer(Entity) - The entity performing the application (e.g., a player).
target(Entity) - The intended recipient; if the target has theelixir_drinkertag, the true owner is resolved viainventoryitem.owner. - Returns:
boolean success–trueif the elixir was applied and consumed;falseotherwise.
string? reason– (optional) A localizable string explaining failure, if returned bydoapplyelixerfn. - Error states: Returns
falseiftargetlacksinventoryitem.ownerwhenelixir_drinkeris present, or ifdoapplyelixerfnisnilor returnsfalse.
OnRemoveFromEntity()
- Description: Cleans up the
ghostlyelixirtag when the component is removed from its entity. - Parameters: None.
- Returns: Nothing.
Events & listeners
None identified.