Skip to main content

Sanityauraadjuster

Overview

The SanityAuraAdjuster component provides a mechanism to dynamically modify sanity aura behavior (e.g., aura strength, radius, or effect) by invoking a user-defined function every second. It is typically attached to entities that need to respond to changes in nearby player presence or other dynamic conditions, updating their sanity aura characteristics in real time.

Dependencies & Tags

  • Dependencies: None (does not require other components to function).
  • Tags: None added or removed.

Properties

PropertyTypeDefault ValueDescription
instEntity(passed to constructor)Reference to the entity the component is attached to.
adjustmentfnfunction?nilOptional callback function that performs sanity aura adjustments; must accept (entity, current_players_table) and return an updated players_table.
playerstable{}Internal list of players currently considered by the adjustment function.

Main Functions

StartTask()

  • Description: Begins a periodic task (running once per second) that calls the adjustmentfn (if set), allowing ongoing dynamic updates to sanity aura behavior.
  • Parameters: None.

StopTask()

  • Description: Cancels and clears the periodic task, halting all future sanity aura adjustment updates.
  • Parameters: None.

SetAdjustmentFn(fn)

  • Description: Assigns the callback function responsible for computing and returning updated sanity aura parameters based on the entity and current player list.
  • Parameters:
    fn (function) — A function with signature fn(inst, players) that returns a table of players (typically for tracking purposes); the function is expected to apply side effects (e.g., modifying inst.components.sanityAura or similar) internally.

Events & Listeners

None.