Scripted effects are a way of reducing necessary code duplication. They work like a macro, and can take particular values to help significantly reduce the amount of code that must be created.
腳本化指令是一種減少必要的代碼重複的方式。它們的工作方式就像宏指令,而且可以採取特定參數來幫助顯著減少必須創建的代碼。
Scripted effects are defined in /Crusader Kings III/common/scripted_effects.
腳本化指令在/Crusader Kings III/common/scripted_effects中定義。
Below is an example of a scripted effect:
如下是一個腳本化指令的例子:
mana_power_increase = {
if = {
limit = {
NOT = { exists = var magic_power }
}
set_variable = {
name = magic_power
value = 0
}
}
change_variable = { name = magic_power add = $MAGIC_POWER$ }
}
This scripted effect will increase a variable in a scope by the integer value that corresponds to $MAGIC_POWER$. This effect is invoked by the following example found in a lifestyle_perk.
這一腳本化指令將會使作為作用域的變量增加一定的整數數值,這一數值與$MAGIC_POWER$等同。在lifestyle_perk找到的一個例子中,這一指令被調用了。
mana_power_increase = {
MAGIC_POWER = 5
}
As should be pretty clear, mana_power_increase is a basic function designed to change a single variable so long as the trigger conditions are met. Each invocation merely requires defining the value MAGIC_POWER which will be the value that is added to the variable.
很明顯的是,mana_power_increase是個設計好的基本函數,只要達到觸發條件,它就可以改變單個變量。每一次調用都僅需要定義參數MAGIC_POWER,這將是被增加到變量中的數值。
An important feature of scripted effects are that the values that can be passed to the scripted effect from the invocation are string values. If you pass a string, you can use this to create a dynamic function that will apply different modifiers or execute different effects without using large case statements.
腳本化指令的一個重要特點就是字符串也可以被輸入到調用的指令化腳本的參數中。如果你輸入了字符串,你可以用它來創建一個動態函數,不使用大量的case語句就能應用不同的修正或執行不同的指令。
| 文檔 | Effects • 觸發器 • 修正 • 作用域 • 變量 • 數據類型 • 本地化 • 可定製的本地化 |
| 腳本 | AI • 劇本 • 角色 • 效果指令 • 內閣 • 文化 • 決議 • 宗族 • 事件 • 政體 • 歷史 • 地產 • 生活方式 • 軍隊 • 宗教 • Story cycles • 頭銜 • 特質 |
| 地圖 | 地圖 • 地形 |
| 圖形 | 3D模型 • Exporters • 界面 • Coat of arms • Graphical assets • Fonts • Particles • Shaders • Unit models |
| 音頻 | Music • Sound |
| 其他 | 控制台指令 • 校驗碼 • 模組結構 • Troubleshooting |