Worker
Overview
The Worker component tracks which actions an entity is capable of performing and the associated effectiveness level (e.g., speed or proficiency multiplier) for each action. It serves as a lightweight, data-driven interface for determining whether an entity can execute a given action and how efficiently it can perform it.
Dependencies & Tags
None identified.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
actions | table | {} | A dictionary mapping action names (strings) to numeric effectiveness values (e.g., 0.5, 1.0, 2.0). Absence of an action key implies the entity cannot perform that action. |
Main Functions
GetEffectiveness(action)
- Description: Returns the effectiveness value for a given action. Returns
0if the action is not registered. - Parameters:
action(string) — The name of the action to query.
SetAction(action, effectiveness)
- Description: Registers or updates the effectiveness level for a specific action. If
effectivenessis omitted ornil, defaults to1. - Parameters:
action(string) — The name of the action to configure.
effectiveness(number, optional) — A numeric value indicating how effectively the entity performs this action (e.g., 1.0 = baseline, 2.0 = double speed). Use0to disable or unregister.
CanDoAction(action)
- Description: Checks whether the entity is permitted to perform a given action. Returns
trueonly if the action exists as a key in theactionstable (regardless of its effectiveness value). - Parameters:
action(string) — The name of the action to check.
Events & Listeners
None.