Hands-On Usage
debug_math_expr is primarily used during mod development and debugging. It lets authors inspect the computed result of complex math expressions in real time via tooltip hover, making it easy to verify that variable arithmetic behaves as expected. Because it always returns true inside a trigger block, it can be safely embedded anywhere in a condition chain without affecting game logic.
# Debugging a variable expression with addition and clamping inside a decision's available block
available = {
debug_math_expr = {
value = var:my_resource_var
add = 20
clamp = { min = 0 max = 100 }
}
check_variable = { var:my_resource_var > 10 }
}
Synergy
- check_variable: The most common pairing. Use
debug_math_expr to print intermediate values in the tooltip, then use check_variable for the actual condition check — making it easy to compare the theoretical value against the decision threshold.
- log: In debug mode, writes information to the log file simultaneously. Combining this with
debug_math_expr leaves debug traces in both the UI tooltip and the log at the same time.
- is_debug: Wrap the entire debug block in an
if condition using is_debug to ensure debug_math_expr only fires in debug mode, preventing it from cluttering player tooltips in a public release.
- set_temp_variable: On the effect side, store the result of a complex calculation in a temporary variable, then use
debug_math_expr on the trigger side to verify that the temporary variable's final value falls within the expected range.
Common Pitfalls
- Mistaking it for a real condition check:
debug_math_expr always returns true regardless of the expression's result. It cannot replace check_variable to implement logic like "only pass when the computed value meets a condition" — using it that way will cause the condition to pass unconditionally.
- Leaving it in release builds without
is_debug wrapping: This trigger displays raw internal values in every player's tooltip. If a bare debug_math_expr is left in a publicly released mod, players will see internal debug numbers, degrading the experience and potentially exposing the mod's internal variable structure.