Wiki

effect · swap_ideas

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

swap 2 ideas. 
 Syntax: swap_idea = {
  remove_idea = <idea>
  add_idea = <idea>
  add_days = 10 #optional, will add/subtract duration for new idea that replaces the old one with duration
  days = 25 #optional, will set the duration for the new idea
}

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

swap_ideas 常用于国策链、决议或事件中替换具有时限的 idea,例如将"战时动员(初级)"升级为"战时动员(高级)",同时平滑衔接剩余天数,避免出现 idea 短暂消失的闪烁感。使用 add_days 可在旧 idea 剩余时长的基础上叠加或扣减新 idea 的持续时间,适合处理需要"继承进度"的临时加成。

# 将临时的初级工业动员替换为高级版本,并额外延长 30 天
country_event = {
    id = my_mod.5
    option = {
        name = my_mod.5.a
        swap_ideas = {
            remove_idea = basic_war_mobilization
            add_idea = advanced_war_mobilization
            add_days = 30
        }
    }
}

配合关系

  • [has_country_flag](/wiki/trigger/has_country_flag):在执行替换前检查国家标记,确保只有满足特定剧情条件的分支才触发 idea 升级,防止逻辑错乱。
  • [add_timed_idea](/wiki/effect/add_timed_idea):当需要新增一个全新的有时限 idea(而非替换已有的)时与 swap_ideas 分工使用,二者共同构成完整的临时 buff 管理体系。
  • [has_allowed_idea_with_traits](/wiki/trigger/has_allowed_idea_with_traits):在 trigger 块中预判目标 idea 是否满足装载条件,避免因 idea 不存在而导致脚本报错。
  • [add_days_remove](/wiki/effect/add_days_remove):若替换后还需要动态调整新 idea 的剩余天数,可在 swap_ideas 之后追加此命令进行精细修正。

常见坑

  1. 忘记旧 idea 必须实际存在于该国:若 remove_idea 指定的 idea 当前并未激活,脚本不会报硬错误但替换会静默失败,add_idea 的新 idea 也不会被添加——务必在外层用 [has_allowed_idea_with_traits](/wiki/trigger/has_allowed_idea_with_traits)has_country_flag 等条件守门。
  2. 混淆 add_daysdays 的语义add_days 是在旧 idea 剩余天数的基础上叠加days覆盖设置新 idea 的持续时间;若不清楚旧 idea 还剩多久就误用 add_days,可能导致新 idea 的有效期远超预期或立即过期。

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

swap_ideas is commonly used in focus trees, decisions, or events to replace timed ideas—for example, upgrading "War Mobilization (Basic)" to "War Mobilization (Advanced)" while smoothly carrying over the remaining duration and avoiding the flickering effect of an idea briefly disappearing. Using add_days allows you to extend or reduce the new idea's duration on top of the old idea's remaining time, making it ideal for handling temporary bonuses that need to "inherit progress."

# Replace a temporary basic war mobilization with the advanced version and extend it by an additional 30 days
country_event = {
    id = my_mod.5
    option = {
        name = my_mod.5.a
        swap_ideas = {
            remove_idea = basic_war_mobilization
            add_idea = advanced_war_mobilization
            add_days = 30
        }
    }
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): Check country flags before executing the swap to ensure only branches meeting specific story conditions trigger the idea upgrade, preventing logic conflicts.
  • [add_timed_idea](/wiki/effect/add_timed_idea): Use alongside swap_ideas when adding a completely new timed idea (rather than replacing an existing one), together forming a comprehensive temporary buff management system.
  • [has_allowed_idea_with_traits](/wiki/trigger/has_allowed_idea_with_traits): Pre-validate in the trigger block whether the target idea meets the loading conditions, avoiding script errors caused by the idea not existing.
  • [add_days_remove](/wiki/effect/add_days_remove): If you need to dynamically adjust the remaining duration of the new idea after the swap, append this command after swap_ideas for fine-tuning.

Common Pitfalls

  1. Forgetting that the old idea must actually exist on the country: If the idea specified in remove_idea is not currently active, the script will not throw a hard error but the swap will silently fail, and the new idea in add_idea will not be added either—always guard with conditions like [has_allowed_idea_with_traits](/wiki/trigger/has_allowed_idea_with_traits) or has_country_flag in the outer scope.
  2. Confusing the semantics of add_days and days: add_days stacks on top of the old idea's remaining duration, while days overwrites the new idea's duration; if you're unsure how much time the old idea has left and misuse add_days, the new idea's validity period may far exceed expectations or expire immediately.