effect · round_temp_variable
Definition
- Supported scope:
any - Supported target:
none
Description
Rounds a temporary variable
Example: round_temp_variable = num_dogs
round_temp_variableanynoneRounds a temporary variable
Example: round_temp_variable = num_dogs
Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.
round_temp_variable is commonly used in economic, population, or combat calculation scenarios. When you obtain a decimal temporary variable through multiplication or division operations, rounding it to an integer is necessary for subsequent assignment or display purposes. For example, when calculating the average number of factories for a country or allocating resource points proportionally, you typically need to perform the calculation first and then round to avoid floating-point precision issues contaminating subsequent logic.
# Calculate average factory count and round
set_temp_variable = { avg_factories = total_factories }
divide_temp_variable = { avg_factories = num_states }
round_temp_variable = avg_factories
add_to_variable = { final_output = avg_factories }
[divide_temp_variable](/wiki/effect/divide_temp_variable): Division operations almost inevitably produce decimals, making it the direct predecessor step before rounding. These two are virtually inseparable.[multiply_temp_variable](/wiki/effect/multiply_temp_variable): Multiplication and percentage conversions likewise introduce decimals. After calculation, use round_temp_variable to finalize and ensure integer results.[set_temp_variable](/wiki/effect/set_temp_variable): Initialize or assign temporary variables with it first, then perform operations, and finally employ round_temp_variable to round the result, forming a complete variable processing workflow.[check_variable](/wiki/trigger/check_variable): After rounding, you typically need to compare and evaluate results in triggers. check_variable is the standard method for reading temporary variable values.round_temp_variable only works on temp_variable (temporary variables). If you need to round regular variables, use [round_variable](/wiki/effect/round_variable) instead. Mixing them will cause script errors or silent failures.