Halloweenpotionmoon
Overview
This component implements the behavior of a Halloween potion item in Don't Starve Together. When used, it attempts to mutate a target entity that possesses the halloweenmoonmutable component, calls an optional user-defined callback, and finally consumes the potion by removing it from the game.
Dependencies & Tags
The component does not add or remove any tags or components on its host entity. It interacts with the following external components on target or self entities:
halloweenmoonmutable(on target)inventoryitem(on target)stackable(on self)
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil (passed to constructor) | Reference to the entity the component is attached to (i.e., the potion item). |
onusefn | function or nil | nil | Optional callback function set via SetOnUseFn, invoked after attempting the mutation. Signature: fn(inst, doer, target, success, transformed_inst, container). |
Main Functions
SetOnUseFn(fn)
- Description: Assigns an optional callback function to be executed when the potion is used. This allows modders to inject custom logic (e.g., sound, particle, or state changes) after the mutation attempt.
- Parameters:
fn(function): A function to call on use. Must accept six arguments:(potion_inst, doer, target, success, transformed_inst, container).
Use(doer, target)
- Description: Executes the core potion behavior. Attempts to mutate the target if it has the
halloweenmoonmutablecomponent. Invokes theonusefncallback (if set), and removes the potion (either by decrementing stack count or fully destroying it). - Parameters:
doer(Entity): The entity performing the action (e.g., a player).target(Entityornil): The entity targeted for mutation. May benil.
Events & Listeners
None identified.