Script values are functions that calculate a value, based on a number of conditions.
Script values are not stored anywhere, they are temporary and exist only when a script calls them. However, they can be displayed in UI, which seems to calculates them on every frame.
They are placed in common/script_values
, in a .txt file.
A basic script value (also "svalue"), looks like this:
my_value = { value = country_population multiply = 10 add = 20 }
To use an svalue in a script, simply write its name, like this add_treasury = my_value
The scope of an svalue depends on where from script it is called. If you are in a country scope, the svalue will also be in a country scope, meaning it will expect country triggers and effects. The svalue above cannot be called for a territory or character, for example.
Svalue accepts effects, and a function like add
can be used inside them to change the svalue.
Important: make sure you are using an effect and not a trigger for this. Every_
or random_
functions are effects, while any_
is a trigger. Example:
cities_in_state = { value = 0 every_state_province = { limit = { has_province_rank = city } add = 1 } }
We can have multipe effects and if statements:
slaves_needed = { value = 20 if = { limit = { has_city_status = no } add = -5 } if = { limit = { terrain = farmland } add = -2 } }
Script values can call each other. They can use values from variables (with var:variable_name) and variables can be set to them, to save a value permanently.
Changes to script values reload instantly if you started the game in debug_mode, but some triggers may break after a reload, like terrain
or pop_type
. Restart the game if a script value doesn't seem to work properly while its syntax looks to be correct.
文檔 | 效果指令 • 觸發條件 • 修正列表 • 作用域 • 變量 • 數據類型 • 本地化 • 可自定義的本地化 |
腳本 | AI • 建築 • 宣戰理由 • 人物 • 人物互動 • 戰術 • 國家 • 文化 • 決議 • Defines • 經濟政策 • 事件 • 淵源 • 政府 • 總督政策 • 理念 • 修正 • 軍事傳統 • 官職 • 行動 • 派系 • 價格 • 人口 • 宗教 • 省份 • Script Values • Scripted Modifiers • 附屬國類型 • 科技 • 商品 • 特質 • 單位 |
地圖 | 地圖 • 地形 • 地圖定位器 |
圖形 | 3D模型 • 界面 • 盾徽 • 圖形資產 • 字體 • 粒子效果 • 著色器 • 單位模型 |
音頻 | 音樂 • 音效 |
其他 | 控制台命令 • 校驗和 • 模組結構 • 錯誤調試 |