MrxTaskState
Module: mrxtaskstate.lua
Overview
The MrxTaskState module defines the enumeration for task states used by the whole mission/task framework. It provides functions to validate a state and to turn one into a human-readable name. Every taskβs current state (stored as _nState on the task) is one of these four values β see MrxTask, which reads/writes them via _GetState/_SetState and defaults an unset state to _knLatent.
Inheritance
- Inherits from:
none β base/utility module - Imports:
none
Instance pattern
This is a stateless utility module (no per-instance tables). It does not track any state; it only defines constants and helper functions.
Functions
_knLatent (constant)
Represents the latent task state. Value: 0.
_knActive (constant)
Represents the active task state. Value: 1.
_knCompleted (constant)
Represents the completed task state. Value: 2.
_knCancelled (constant)
Represents the cancelled task state. Value: 3.
IsValidState(nState)
Checks if a given task state is valid.
- Parameters:
nState(number) β The task state to validate. - Returns:
booleanβ True if the state is valid, false otherwise.
GetStateDisplayName(nState)
Retrieves the display name for a given task state.
- Parameters:
nState(number) β The task state to get the display name for. - Returns:
stringβ The display name of the task state. - Side Effects: Asserts if the state is unknown.
Events
This module does not listen for or fire any engine events.
Notes for modders
- Reference the states as
MrxTaskState._knLatent/._knActive/._knCompleted/._knCancelledrather than hard-coding0/1/2/3β the numeric values are an implementation detail. GetStateDisplayNamereturns the lowercase strings"latent","active","completed","cancelled"; these are what show up inMrxTaskβsDebug.Printfstate-change logs.GetStateDisplayNameasserts on any value not in the enum, so only pass it a validated state.