egametang/ET · error · Exception
condition variable not registered: {variable}
Error message
condition variable not registered: {variable} What it means
Thrown by ConditionExprParser.ParseCompare when the variable name extracted from the expression is not found in ConditionVariableRegistry. The registry maps variable names to node types: all NumericType enum names are auto-registered to BTNumericCompare, plus any [ConditionVariable]-attributed BTCondition. An unknown variable means the name is misspelled, unregistered, or not a NumericType.
Source
Thrown at Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs:124
this.ReadVariable(variableToken.Text, out string ownerKey, out string variable, out bool hasOwnerKey);
string[] paramValues = this.ReadParams(out bool hasParams);
ConditionCompareOp op = this.ReadCompareOp();
ConditionToken valueToken = this.Expect(ConditionTokenType.Number);
int errorCode = this.defaultErrorCode;
if (this.Match(ConditionTokenType.Colon))
{
errorCode = this.ReadErrorCode();
}
ConditionVariableRegistry registry = ConditionVariableRegistry.Instance;
if (registry == null)
{
throw new Exception("condition variable registry is not initialized");
}
if (!registry.TryGetNodeType(variable, out Type nodeType))
{
throw new Exception($"condition variable not registered: {variable}");
}
BTCondition node = Activator.CreateInstance(nodeType) as BTCondition;
if (node == null)
{
throw new Exception($"condition variable node create error: {nodeType.FullName}");
}
node.Id = this.NextNodeId();
if (node is BTNumericCompare numericCompare)
{
if (hasParams)
{
this.SetParamsField(numericCompare, paramValues);
}
if (registry.TryGetNumericType(variable, out NumericType numericType))
{View on GitHub (pinned to 5cab01f7a8)
Solutions
- Check the variable name spelling in the expression against registered names (NumericType enum values and [ConditionVariable] names).
- If it is a numeric property, confirm the name matches a NumericType enum member exactly.
- If it is a custom node, add [ConditionVariable("Name")] to the BTCondition subclass so it registers at startup.
- Log ConditionVariableRegistry contents at startup to see all registered names for comparison.
Example fix
// before (expression cell) // Mana > 50 // 'Mana' is not a NumericType and no [ConditionVariable] // after // Mp > 50 // 'Mp' is an existing NumericType (matches the enum)
Defensive patterns
Strategy: validation
Validate before calling
// Before relying on an expression, confirm each variable resolves: ConditionVariableRegistry.Instance.TryGetNodeType(variable, out _); // false -> unregistered
Type guard
static bool IsRegisteredVariable(string v) =>
ConditionVariableRegistry.Instance != null &&
ConditionVariableRegistry.Instance.TryGetNodeType(v, out _); Prevention
- Keep an authoritative list of valid variable names (NumericType enum + [ConditionVariable] names).
- Add [ConditionVariable] to custom BTCondition nodes so they register.
- Validate expression variable references at config-import time.
When it happens
Trigger: An expression like 'Mana > 50' where 'Mana' is neither a NumericType enum value nor a [ConditionVariable("Mana")] node; a typo such as 'H' instead of 'HP'; referencing a numeric type that was removed from the NumericType enum.
Common situations: Typo in the variable name in the Luban/Excel cell; the variable's NumericType was renamed/removed; a custom condition node is missing its [ConditionVariable] attribute so it never registered.
Related errors
- condition variable reference invalid: {text}
- condition compare op expected, actual: {token.Text}
- condition number parse error: {text}
- condition token error at {this.index}: {c}
- condition variable node create error: {nodeType.FullName}
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/11e19fef108cfdec.
Report an issue: GitHub.