Skip to main content

Overview

pregame.lua is the most important file in Redux. It handles everything that happens before the game clock starts: the lobby phase, hero selection, skill selection, banning, draft arrays, contributor/patron loading, and the initial spawn of heroes. The file also bootstraps the entire scripting layer — it calls require for every other module and registers all Lua modifiers with LinkLuaModifier.

The Pregame class

Pregame is a Lua class defined with Valve’s class({}) helper:
All functionality is added as methods on this singleton. The class is instantiated and Pregame:init() is called from addon_game_mode.lua when the server first activates.

KV loading

Before Pregame:init() runs, the top level of pregame.lua populates GameRules.KVs with every KeyValues file the game needs:
Other modules access ability data through GameRules.KVs["npc_abilities"] or via util:getAbilityKV().

Modifier registration

All Lua-backed modifiers are registered at the top of pregame.lua before any unit can be given one:

Pregame:init()

Initialises all pregame state. Called once at game start.

Key instance fields

Vote option presets

Pregame:init() also populates self.optionVoteSettings with preset lambdas for common game-mode votes. For example:

Function reference

Bootstraps all pregame state, sets the loading phase, and dispatches contributor/patron data to clients. Called once by addon_game_mode.lua.
Transitions the game to the given phase constant (e.g. constants.PHASE_LOADING, constants.PHASE_SELECTION). Broadcasts the new phase to all clients via net tables.
Begins an async HTTP request to fetch historical player data (win rates, abandons) used for display in the pre-game UI.
Pushes contributor, patron, and Patreon feature lists loaded from KV files to the Panorama UI via CustomNetTables.
Writes key → value into self.optionStore and (unless noNetwork is true) broadcasts the change to all clients.
Handles a request from the Panorama ingame hero builder. Respawns the player’s hero with the new build when keys.ingamePicking is true.