Hands-On Usage
get_highest_scored_country_temp is commonly used in diplomatic AI decisions or event logic when you need to identify the "highest-scoring" candidate from multiple options—for example, automatically selecting the most threatening rival, the most suitable ally, or a trade partner. Unlike get_highest_scored_country (the persistent variable version), this effect stores the result in a temporary variable, making it suitable for short-term use within a single event or effect block that can be discarded afterwards without polluting save data.
# In a country event, find the highest-scoring ally candidate and send them a diplomatic event
country_event = {
id = my_mod.1
immediate = {
get_highest_scored_country_temp = {
scorer = my_alliance_scorer
var = best_ally_candidate
}
var:best_ally_candidate = {
country_event = { id = my_mod.2 }
}
}
}
Synergy
[get_sorted_scored_countries_temp](/wiki/effect/get_sorted_scored_countries_temp): Use alongside this command when you need to retrieve a ranked list of multiple candidate countries (rather than just the highest score). Both share the same scorer framework and are logically complementary.
[get_highest_scored_country_temp](/wiki/trigger/get_highest_scored_country_temp): Read the value of the same-named temporary variable on the trigger side to validate whether the resulting country meets certain conditions, enabling a two-stage "select then verify" logic.
[get_sorted_scored_countries_temp](/wiki/trigger/get_sorted_scored_countries_temp): Part of the same temporary variable system as this effect; check sorting results within trigger blocks, often paired with this command for further filtering.
[every_other_country](/wiki/effect/every_other_country): The scoring targets in a scorer are typically provided by iteration effects; every_other_country is the most common scope pairing when building the candidate pool for a scorer.
Common Pitfalls
- Forgetting that scorer must be pre-defined: The scorer id referenced in the
scorer field must be separately registered in common/country_scorers/. If misspelled or the file is missing, the game won't report an error but the result variable will remain empty. Subsequent scope switches on that variable will fail silently, making it extremely difficult to debug.
- Temporary variables don't persist across events: The
_temp suffix means the variable only exists for the duration of the current effect execution frame and cannot be read in another independently-triggered event or on_action. Beginners often mistakenly assume that once a value is stored in a variable, it can be referenced at any later time—in reality, you must use the result within the same execution block immediately.