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:
Pregame:init() is called from addon_game_mode.lua when the server first activates.
KV loading
BeforePregame:init() runs, the top level of pregame.lua populates GameRules.KVs with every KeyValues file the game needs:
GameRules.KVs["npc_abilities"] or via util:getAbilityKV().
Modifier registration
All Lua-backed modifiers are registered at the top ofpregame.lua before any unit can be given one:
Pregame:init()
Initialises all pregame state. Called once at game start.
Key instance fields
| Field | Type | Description |
|---|---|---|
optionStore | table | Per-session option overrides |
selectedHeroes | table | Maps playerID → heroName |
selectedPlayerAttr | table | Maps playerID → primary attribute |
selectedSkills | table | Maps playerID → {abilityName, ...} |
selectedRandomBuilds | table | Builds generated for random picks |
bannedAbilities | table | Set of banned ability names |
bannedHeroes | table | Set of banned hero names |
usedBans | table | Number of bans used per player |
isReady | table | Maps playerID → bool |
useDraftArrays | bool | Whether the draft whitelist is active |
maxDraftHeroes | number | Max heroes offered in a draft (default 30) |
spawnedHeroesFor | table | Player IDs whose heroes have already spawned |
Vote option presets
Pregame:init() also populates self.optionVoteSettings with preset lambdas for common game-mode votes. For example:
Function reference
Pregame:init()
Pregame:init()
Bootstraps all pregame state, sets the loading phase, and dispatches contributor/patron data to clients. Called once by
addon_game_mode.lua.Pregame:setPhase(phase)
Pregame:setPhase(phase)
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.Pregame:preparePlayerDataFetch()
Pregame:preparePlayerDataFetch()
Begins an async HTTP request to fetch historical player data (win rates, abandons) used for display in the pre-game UI.
Pregame:sendContributors() / sendPatrons() / sendPatreonFeatures()
Pregame:sendContributors() / sendPatrons() / sendPatreonFeatures()
Pushes contributor, patron, and Patreon feature lists loaded from KV files to the Panorama UI via
CustomNetTables.Pregame:setOption(key, value, noNetwork)
Pregame:setOption(key, value, noNetwork)
Writes
key → value into self.optionStore and (unless noNetwork is true) broadcasts the change to all clients.Pregame:onIngameBuilder(type, keys)
Pregame:onIngameBuilder(type, keys)
Handles a request from the Panorama ingame hero builder. Respawns the player’s hero with the new build when
keys.ingamePicking is true.
