Hands-On Usage
find_lowest_in_array is commonly used in scenarios requiring identification of the minimum value from a set of numbers—for example, locating the country index with the lowest industrial output in a multi-nation competition system, or pinpointing the cell with the least stock in a resource allocation mod. Below is a simple example that finds the lowest value in a resource_pool array and records its index:
find_lowest_in_array = {
array = resource_pool
value = min_val # Lowest value stored in temp variable min_val
index = min_idx # Corresponding index stored in temp variable min_idx
}
# Afterwards, min_val / min_idx can be used for subsequent checks or operations
Synergy
[add_to_array](/wiki/effect/add_to_array) / [add_to_temp_array](/wiki/effect/add_to_temp_array): Populate the array with data before invoking this command; this is the most common prerequisite step for constructing the target array.
[find_highest_in_array](/wiki/effect/find_highest_in_array): Typically used in pairs—find the lowest value first, then the highest, thereby obtaining the value range for normalization or comparative analysis.
[check_variable](/wiki/trigger/check_variable): After finding the lowest value, use this trigger to apply conditional logic to min_val, determining subsequent branching logic.
[set_temp_variable](/wiki/effect/set_temp_variable): Manually initialize helper variables outside loops and combine them with this command's results for further arithmetic operations (such as computing the difference between mean and minimum).
Common Pitfalls
- Overlooking default variable name conflicts: When
value and index fields are left unspecified, they default to v and i respectively, which are also the default iteration variable names in nested for_each_loop / while_loop_effect blocks. Mixing these will cause the outer loop's v/i to be overwritten by this command, resulting in hard-to-trace logic errors—it is strongly recommended to always explicitly specify semantically meaningful variable names.
- Invoking on empty arrays: If the array contains zero elements at execution time, the command's behavior is undefined and result variables may retain stale values from the previous run. It is good practice to first confirm the array is non-empty using
[collection_size](/wiki/trigger/collection_size) or [check_variable](/wiki/trigger/check_variable).