Bottler
Overview
The Bottler component provides a generic framework for items that can "bottle" other entities. Its primary responsibility is to hold a custom callback function that defines the specific logic for the bottling action. When its Bottle method is called, it verifies the target has the canbebottled tag and then executes this callback, making it a flexible system for defining various bottling behaviors.
Dependencies & Tags
None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | inst | A reference to the entity instance to which this component is attached. |
onbottlefn | function | nil | The callback function to execute when a valid target is bottled. |
Main Functions
SetOnBottleFn(fn)
- Description: Sets or replaces the callback function that is executed when the
Bottlemethod is called. This function defines the specific outcome of the bottling action. - Parameters:
fn(function): The function to be called. It will receive the bottler's entity instance, the target entity, and the action's doer as arguments.
Bottle(target, doer)
- Description: Attempts to perform the bottling action on a given target. If an
onbottlefnhas been set and the target is valid and has thecanbebottledtag, the function is executed. - Parameters:
target(Entity): The entity to be bottled.doer(Entity): The entity performing the bottling action.