Wiki

trigger · can_construct_building

Definition

  • Supported scope:STATE
  • Supported target:none

Description

Checks if the country (as ROOT) and state in scope can build a building in the state.
ex:
GER = {
	65 = {
		can_construct_building = land_facility
	}
}

实战 · 配合 · 坑

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

实战用法

can_construct_building 常用于决策或焦点的 available 块中,在玩家准备触发建造相关奖励前,预先验证目标州和国家是否满足建造条件,避免脚本执行后出现无效建造。例如在一个"工业化计划"决策里,只有当某州真正可建造工厂时才允许玩家点击:

available = {
    GER = {
        65 = {
            can_construct_building = industrial_complex
        }
    }
}

配合关系

  • [free_building_slots](/wiki/trigger/free_building_slots):与 can_construct_building 配合,进一步确认目标州剩余建筑槽位足够,双重保险防止建造失败。
  • [add_building_construction](/wiki/effect/add_building_construction):通常作为满足 can_construct_building 条件后的 effect 执行体,负责真正将建造任务加入队列。
  • [is_owned_and_controlled_by](/wiki/trigger/is_owned_and_controlled_by):建造类操作往往要求该州既被目标国拥有又受其控制,与本 trigger 搭配确保前提完整。
  • [has_state_category](/wiki/trigger/has_state_category):不同州类别决定可建槽数上限,配合使用可筛选出具备建造潜力的高级别州。

常见坑

  1. Scope 写错层级:本 trigger 必须在 STATE scope 内调用,外层还需要切换到对应国家 scope(作为 ROOT)。新手常直接在国家 scope 下写 can_construct_building,导致游戏报错或条件永远不触发,务必按官方示例先切国家再嵌套州 scope。
  2. 混淆 trigger 与 effectcan_construct_building 只做判断,不会真正开始建造。有玩家误以为条件成立后建筑会自动入队,实际必须在 effect 块中额外调用 add_building_construction 才能产生建造行为。

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

can_construct_building is commonly used within the available block of decisions or focuses to pre-validate whether the target state and country meet the construction requirements before triggering building-related rewards, preventing invalid construction after script execution. For example, in an "Industrialization Plan" decision, players are only allowed to click if the state truly permits factory construction:

available = {
    GER = {
        65 = {
            can_construct_building = industrial_complex
        }
    }
}

Synergy

  • [free_building_slots](/wiki/trigger/free_building_slots): Works in conjunction with can_construct_building to further confirm that the target state has sufficient remaining building slots, providing dual insurance against construction failure.
  • [add_building_construction](/wiki/effect/add_building_construction): Typically serves as the effect execution body after can_construct_building conditions are met, responsible for actually queuing the construction task.
  • [is_owned_and_controlled_by](/wiki/trigger/is_owned_and_controlled_by): Construction operations often require the state to be both owned and controlled by the target country; pairing with this trigger ensures complete prerequisites.
  • [has_state_category](/wiki/trigger/has_state_category): Different state categories determine the upper limit of available building slots; combined use filters for high-tier states with construction potential.

Common Pitfalls

  1. Incorrect Scope Nesting: This trigger must be called within STATE scope, with an outer layer switching to the corresponding country scope (as ROOT). Beginners often write can_construct_building directly under country scope, causing game errors or conditions that never fire. Always follow official examples by switching to the country scope first, then nesting the state scope.
  2. Confusing Trigger and Effect: can_construct_building only performs validation; it does not actually start construction. Some players mistakenly believe that once conditions are met, buildings automatically queue, but in reality you must additionally call add_building_construction within the effect block to produce construction behavior.