Skip to main content

Moonstormover Lightning

Based on game build 714014 | Last updated: 2026-03-08

Overview

MoonstormOver_Lightning is a UI widget responsible for rendering lightning visual and audio effects during Moonstorms. It is instantiated with an owner entity (typically the HUD or a screen controller) and listens for stormlevel events to activate/deactivate. When active, it schedules random lightning strikes via a countdown timer, playing randomized animations and sound effects with positional offset.

Usage example

-- Typically used internally by the Moonstorm HUD system.
-- Example instantiation (not usually called directly by modders):
local lightning = MoonstormOver_Lightning(owner, dustlayer)
-- The component automatically listens for "stormlevel" events on `owner`
-- and activates/deactivates based on storm intensity.

Dependencies & tags

Components used: None (uses UIAnim, Widget, and global systems TheNet, TheFocalPoint.SoundEmitter) Tags: None identified

Properties

PropertyTypeDefault ValueDescription
ownerEntity?nilThe entity that owns this widget (used for listening to stormlevel events).
lightningUIAnimThe child UIAnim widget that renders the lightning animation.
activebooleanfalseWhether the lightning effect is currently scheduled to fire.
next_timenumbermath.random()*20Seconds remaining until the next lightning strike (client-side timer).
minscalenumber0.9Minimum supported scale (hardcoded for art constraints).
maxscalenumber1.20625Maximum scale (derived from camera range [15, 50], default 30).

Main functions

Activate(level)

  • Description: Activates or deactivates the lightning effect based on storm intensity. If level > 0 and currently inactive, starts the update loop. If level <= 0 and active, stops the update loop.
  • Parameters: level (number) — Current Moonstorm intensity level. Positive values activate the effect.
  • Returns: Nothing.

OnUpdate(dt)

  • Description: Handles the periodic countdown and rendering of lightning strikes. Runs every frame while active. Decrements next_time each frame; when it reaches 0, plays a randomized animation, emits sound, and schedules the next strike.
  • Parameters: dt (number) — Delta time in seconds since the last frame.
  • Returns: Nothing.
  • Error states: Exits early if TheNet:IsServerPaused() returns true.

Events & listeners

  • Listens to: stormlevel (on owner) — triggers Activate(level) when storm level changes.
  • Pushes: None.