Beacon
Module: beacon.lua
Overview
The Beacon module represents a beacon object in the game world. It is responsible for playing animations and sound cues when the beacon is activated or deactivated.
Inheritance
- Inherits from: none β base/utility module
- Imports: none
Instance pattern
Not the Inheritable/setmetatable/tInstance per-uGuid pattern β thereβs no Create/Awake, no prototype table. Instead itβs a plain module-level table tEvents, initialized once by Init() and keyed directly by uGuid, holding just the one timer-event handle per active beacon (tEvents[uGuid] = Event.Create(...), cleared in OnDeactivate). Lightweight per-object state without the class-factory machinery.
Functions
Init()
Initializes the tEvents table if it hasnβt been initialized yet. This function runs once when the module is loaded.
OnActivate(uGuid, args)
Called when the beacon object is activated by the engine. It plays a material animation and sets up a timer event to play a sound cue after 1 second.
OnDeactivate(uGuid, args)
Called when the beacon object is deactivated by the engine. It stops the material animation and the sound cue, deletes the timer event, and clears the corresponding entry in the tEvents table.
Events
OnActivate(uGuid, args)/OnDeactivate(uGuid, args)are engine-invoked lifecycle hooks (notEvent.*subscriptions) β called directly by the engine when the beacon object activates/deactivates.- Creates:
Event.TimerRelative(1-second one-shot) insideOnActivate, whose callback isSound.CueSound(an engine API call, not a self-defined function) β plays thewpn_bomb_timer_01_armedcue. The handle is stored intEvents[uGuid]and deleted viaEvent.DeleteinOnDeactivate. - Fires: none
Module constants & tunables
- Material animation:
"global_weapon_beacon"β started (looping,true) inOnActivateviaObject.PlayMaterialAnimation, stopped inOnDeactivateviaObject.StopMaterialAnimation. Swap this string to change the beaconβs visual pulse. - Sound cue:
"wpn_bomb_timer_01_armed"β cued viaSound.CueSound1 second after activation, stopped viaSound.StopSoundon deactivate. - Arm delay: the
Event.TimerRelativefires after1second (inline literal, not a named constant).
Notes for modders
- Both real levers are the two template strings above: the visual (
"global_weapon_beacon") and the audio ("wpn_bomb_timer_01_armed"). Change either to re-skin the beacon without touching its logic. OnActivateandOnDeactivateare engine lifecycle hooks (see Object and Sound for the primitives used) β the engine pairs them, so if you overrideOnActivateremember to also stop the animation/sound and delete the timer inOnDeactivateor the beacon will keep pulsing/beeping after it despawns.