Wiki

trigger · free_building_slots

Definition

  • Supported scope:STATE
  • Supported target:none

Description

checks building for available construction levels 
free_building_slots = { 
	building = building_type 
	size > 5 
	include_locked = yes # Optional - only to be used for buildings using Shared Slots. 
	province = 42 #will check province buildings if specified 
}

实战 · 配合 · 坑

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

实战用法

free_building_slots 常用于 mod 中限制某项决议或事件的触发条件——例如只有当某州拥有足够的空闲建筑槽时,才允许玩家触发"扩建工业计划"之类的决策。它也适合用在 available 块中,防止建筑队列已满时仍能触发施工类 effect,从而避免建造被静默忽略。

# 示例:某州有 3 个以上空闲普通建筑槽时才允许触发决议
available = {
    free_building_slots = {
        building = industrial_complex
        size > 3
    }
}

配合关系

  • [non_damaged_building_level](/wiki/trigger/non_damaged_building_level):先用它确认当前建筑等级,再用 free_building_slots 判断剩余可用槽,两者组合可精确描述"已建多少、还能建多少"的双重门槛。
  • [add_building_construction](/wiki/effect/add_building_construction):触发条件满足后,紧接着用它将建筑加入施工队列,是最直接的"条件→施工"配对。
  • [has_state_category](/wiki/trigger/has_state_category):与 free_building_slots 搭配可进一步将条件限定在特定州等级(如城市州、农村州),避免在基础槽位极少的小州触发高消耗建造决策。
  • [add_extra_state_shared_building_slots](/wiki/effect/add_extra_state_shared_building_slots):当 free_building_slots 检测到共享槽不足时,可通过此 effect 先扩充槽位再施工,include_locked = yes 参数正是为这种共享槽场景而设计的。

常见坑

  1. 忽略 include_locked 的适用范围include_locked = yes 仅对使用共享槽(Shared Slots)的建筑类型有意义,若对普通独立槽建筑(如 arms_factory)加上此参数,不会报错但也不会产生任何额外效果,容易造成逻辑误判。
  2. 漏写 building 字段导致脚本报错或行为异常building 是必填字段,不少新手只写 size > X 而省略建筑类型,这会导致游戏无法确定检查哪种建筑槽,轻则触发器永远返回 false,重则游戏启动时报出脚本错误。

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

free_building_slots is commonly used in mods to restrict the trigger conditions for certain decisions or events—for example, only allowing players to activate a "Industrial Expansion Plan" decision when a state has sufficient free building slots. It also works well in available blocks to prevent construction-type effects from being triggered when the build queue is full, thereby avoiding silent construction failures.

# Example: Allow decision trigger only when a state has more than 3 free general building slots
available = {
    free_building_slots = {
        building = industrial_complex
        size > 3
    }
}

Synergy

  • [non_damaged_building_level](/wiki/trigger/non_damaged_building_level): Use it first to confirm the current building level, then use free_building_slots to check remaining available slots. The combination of both allows precise description of the dual threshold "how much has been built, how much can still be built."
  • [add_building_construction](/wiki/effect/add_building_construction): Once trigger conditions are met, use it immediately afterward to add buildings to the construction queue. This is the most direct "condition → construction" pairing.
  • [has_state_category](/wiki/trigger/has_state_category): When combined with free_building_slots, it further restricts conditions to specific state categories (such as urban states or rural states), preventing high-consumption construction decisions from being triggered in small states with minimal base slots.
  • [add_extra_state_shared_building_slots](/wiki/effect/add_extra_state_shared_building_slots): When free_building_slots detects insufficient shared slots, this effect can expand the slots before construction. The include_locked = yes parameter is specifically designed for such shared slot scenarios.

Common Pitfalls

  1. Ignoring the applicable scope of include_locked: include_locked = yes only has meaning for building types that use Shared Slots. If this parameter is added to standard independent slot buildings (such as arms_factory), it will not cause an error but will produce no additional effect either, easily leading to logic errors.
  2. Omitting the building field causing script errors or abnormal behavior: building is a required field. Many newcomers write only size > X while omitting the building type, which prevents the game from determining which type of building slot to check. At minimum, the trigger always returns false; at worst, the game throws a script error on startup.