{"record":{"id":"11e19fef108cfdec","repo":"egametang/ET","slug":"condition-variable-not-registered-variable","errorCode":null,"errorMessage":"condition variable not registered: {variable}","messagePattern":"condition variable not registered: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs","lineNumber":124,"sourceCode":"            this.ReadVariable(variableToken.Text, out string ownerKey, out string variable, out bool hasOwnerKey);\n            string[] paramValues = this.ReadParams(out bool hasParams);\n            ConditionCompareOp op = this.ReadCompareOp();\n            ConditionToken valueToken = this.Expect(ConditionTokenType.Number);\n            int errorCode = this.defaultErrorCode;\n            if (this.Match(ConditionTokenType.Colon))\n            {\n                errorCode = this.ReadErrorCode();\n            }\n\n            ConditionVariableRegistry registry = ConditionVariableRegistry.Instance;\n            if (registry == null)\n            {\n                throw new Exception(\"condition variable registry is not initialized\");\n            }\n\n            if (!registry.TryGetNodeType(variable, out Type nodeType))\n            {\n                throw new Exception($\"condition variable not registered: {variable}\");\n            }\n\n            BTCondition node = Activator.CreateInstance(nodeType) as BTCondition;\n            if (node == null)\n            {\n                throw new Exception($\"condition variable node create error: {nodeType.FullName}\");\n            }\n\n            node.Id = this.NextNodeId();\n            if (node is BTNumericCompare numericCompare)\n            {\n                if (hasParams)\n                {\n                    this.SetParamsField(numericCompare, paramValues);\n                }\n\n                if (registry.TryGetNumericType(variable, out NumericType numericType))\n                {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs#L106-L142","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (expression cell)\n//   Mana > 50     // 'Mana' is not a NumericType and no [ConditionVariable]\n// after\n//   Mp > 50        // 'Mp' is an existing NumericType (matches the enum)","handlingStrategy":"validation","validationCode":"// Before relying on an expression, confirm each variable resolves:\nConditionVariableRegistry.Instance.TryGetNodeType(variable, out _); // false -> unregistered","typeGuard":"static bool IsRegisteredVariable(string v) =>\n    ConditionVariableRegistry.Instance != null &&\n    ConditionVariableRegistry.Instance.TryGetNodeType(v, out _);","tryCatchPattern":null,"preventionTips":["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."],"tags":["conditionexpr","parser","registry","variable","config","csharp","unity"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}