Wiki

effect · force_update_map_mode

Definition

  • Supported scope:any
  • Supported target:any

Description

force rebuilds map mode. no tooltip generated.
force_update_map_mode = { 
  limit = { always = yes } # limit to check against player
  mapmode = scripted_map_mode_name

Hands-On Notes

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.

Hands-On Usage

force_update_map_mode is primarily used in mods that implement custom scripted map modes. It forces a refresh of the map display when certain variables or states change, ensuring players see the latest coloring results. For example, in a mod that tracks sphere of influence, trigger a refresh whenever a country joins or leaves a faction:

country_event = {
    id = my_mod.1
    hidden_effect = {
        force_update_map_mode = {
            mapmode = my_influence_map_mode
        }
    }
}

Synergy

  • [hidden_effect](/wiki/effect/hidden_effect): force_update_map_mode itself produces no tooltip and is typically wrapped in hidden_effect to avoid extraneous blank tooltip lines appearing in event options.
  • [set_variable](/wiki/effect/set_variable): Custom map modes often rely on variables to drive coloring logic; calling this effect immediately after modifying a variable ensures visual synchronization.
  • [if](/wiki/effect/if): Combined with conditional checks, only execute the refresh if the current map mode is indeed the target scripted map mode, avoiding unnecessary rebuild overhead.
  • [has_global_flag](/wiki/trigger/has_global_flag): Use global flags to determine whether a mod feature is activated before deciding whether to trigger map refresh, commonly used in protective logic during mod initialization.

Common Pitfalls

  1. Incorrect mapmode field: Must use the exact name as defined in scripted_map_modes. Typos or using vanilla map mode IDs will silently fail—the map won't refresh and no error is reported, making debugging difficult.
  2. Excessive frequent calls: Unconditionally calling this in daily on_actions or tight loops causes continuous map mode rebuilding, resulting in noticeable performance degradation. Use [if](/wiki/effect/if) or flag conditions to control call timing, triggering only when data actually changes.