小 (翻译(未完待续)) |
|||
第1行: | 第1行: | ||
{{version|1. | {{version|1.10}} | ||
数组是《钢铁雄心IV》中用以存储变量的方式,变量既可以是{{ruby|'''数字形式'''|numerical data}}的,也可以是{{ruby|'''作用域'''|scope data}}形式的。 | |||
数组 | 数组在{{ruby|'''指令'''|effects}} 中 发挥作用 , 并且{{ruby|'''触发器'''|trigger}}能够从中读取 数 据。指令既 可以 使 数 组迭代入其他指令,也能使其 数据 在自身内进行迭代 。 | ||
== | == 指令(Effects)== | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
=== 添加数组 === | === 添加 到 数组 (add_to_array) === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>add_to_array = { | <pre>add_to_array = { | ||
第17行: | 第17行: | ||
} | } | ||
</pre> | </pre> | ||
每当有一个变量出现,就会创造一个对应的数组对其进行储存。 | |||
<name>是 数组 的名称,也是指令和触发器调用它的依据 。 | |||
< | <value> 是指数组的数据内容,它既可以是数字形式的(如1 或 var:my_num),也 可以是 作用域形式 的 (如GER 或 var:my_scope)。当然这些都是选填内容,如 果 不填则会将当前作用域填入此处。 | ||
< | <index> 指数据内容应当被插入 数组的 哪个位置。{{ruby|'''缺省'''|default data}}(现普遍称'''默认''')情况下, 数据 内容会插入数组的最后端,其他情况下新 数 据内容会 自 动匹配到合适的位置。 | ||
< | 这部分的简便写法是:<code>add_to_array = { <name> = <value> }</code> | ||
=== 从数组 中 移除 (remove_from_array) === | |||
{{SVersion|1.10}} | |||
=== 从数组移除 === | |||
{{SVersion|1. | |||
<pre>remove_from_array = { | <pre>remove_from_array = { | ||
array = <name> | |||
value = <value> | |||
index = <index> | |||
} | } | ||
</pre> | </pre> | ||
<name>是想要进行数据内容移除操作的数组名称 | |||
< | <value>是 想 要移除 的 数据 内容 | ||
< | <index> 指 移除 操作所选择 的 位置 | ||
如果value和index值都未定义或未分配内容,那么最后一 个数 据内容会被清 除 | |||
这部分的简便写法是:<code>remove_from_array = { <name> = <value> }</code> | |||
=== 清 | === 清 空 数组 (clear_array) === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>clear_array = <name></pre> | <pre>clear_array = <name></pre> | ||
清除指定数组中 | 清除指定数组中所有数据 内容 | ||
=== | === 重置 数组 规模(resize_array) === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>resize_array = { | <pre>resize_array = { | ||
array = <name> | |||
value = <value> | |||
size = <int> | |||
} | } | ||
</pre> | </pre> | ||
重置特定数组规模 | |||
如果扩大已经声明过数据内容类型 的数组 规模,那么多出的位置将以空变量填满,如果没有声明过则缺省值为0。 | |||
size属性指定了 数组的 新大小,如果缩小数组,则删除元素, 如果 扩大数组,则增加 指定值 的新元素。 | |||
<size> | 这部分的简便写法是: <code>resize_array = { <name> = <size> }</code> | ||
=== | === while_loop_effect === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>while_loop_effect = { | <pre> | ||
while_loop_effect = { | |||
break = <string> | |||
limit = { <triggers> } | |||
<effects> | |||
} | } | ||
</pre> | </pre> | ||
Runs the effect as long as a trigger is true. | |||
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is <code>break</code>. | |||
Effects can be used within the loop to perform operations with the data within an array. | |||
=== | === for_each_loop === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>for_each_loop = { | <pre> | ||
for_each_loop = { | |||
array = <name> | |||
value = <string> | |||
index = <string> | |||
break = <string> | |||
<effects> | |||
} | } | ||
</pre> | </pre> | ||
Runs a loop for each element of the specified array. | |||
The value attribute specifies a temp variable that stores the current value whilst iterating over the loop. By default this is <code>v</code>. | |||
The index attribute specifies a temp variable that stores the current index whilst iterating over the loop. By default this is <code>i</code>. | |||
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is <code>break</code>. | |||
Effects can be used within the loop to perform operations with the data within an array. | |||
=== | === for_each_scope_loop === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>for_each_scope_loop = { | <pre> | ||
for_each_scope_loop = { | |||
array = <name> | |||
break = <string> | |||
<effects> | |||
} | } | ||
</pre> | </pre> | ||
Runs a loop for each element of the specified array and changes the current scope to the current element in each iteration. | |||
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is <code>break</code>. | |||
Effects can be used within the loop to perform operations with the data within an array. | |||
=== | === random_scope_in_array === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>random_scope_in_array = { | <pre> | ||
random_scope_in_array = { | |||
array = <name> | |||
break = <string> | |||
limit = { <triggers> } | |||
<effects> | |||
} | } | ||
</pre> | </pre> | ||
Runs a loop for each element of the specified array and changes the current scope to a random scope (out of the scopes within the array) that meet the triggers specified. | |||
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is <code>break</code>. | |||
Effects can be used within the loop to perform operations with the data within an array. | |||
=== | === add_to_temp_array === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
Same as <code>add_to_array</code> but for temporary arrays that expire once execution of the script is finished. | |||
=== | === remove_from_temp_array === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
Same as <code>remove_from_array</code> but for temporary arrays that expire once execution of the script is finished. | |||
=== | === clear_temp_array === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
Same as <code>clear_array </code> but for temporary arrays that expire once execution of the script is finished. | |||
=== | === resize_temp_array === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
Same as <code>resize_array</code> but for temporary arrays that expire once execution of the script is finished. | |||
== | == Triggers == | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
=== | === is_in_array === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>is_in_array = { | <pre> | ||
is_in_array = { | |||
array = <name> | |||
value = <value> | |||
} | } | ||
</pre> | </pre> | ||
Checks if the specified value is in the specified array. | |||
=== any_of === | === any_of === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>any_of = { | <pre> | ||
any_of = { | |||
array = <name> | |||
value = <string> | |||
index = <string> | |||
<triggers> | |||
} | } | ||
</pre> | </pre> | ||
Runs a loop on the specified array and checks the triggers against the current element. If any return true, the whole check returns true, otherwise returns false. | |||
=== all_of === | === all_of === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre>all_of = { | <pre> | ||
all_of = { | |||
array = <name> | |||
value = <string> | |||
index = <string> | |||
<triggers> | |||
} | } | ||
</pre> | </pre> | ||
Runs a loop on the specified array and checks the triggers against the current element. If any return false, the whole check returns false, otherwise returns true. | |||
=== | === any_of_scopes === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre> | <pre> | ||
any_of_scopes = { | any_of_scopes = { | ||
array = <name> | |||
<triggers> | |||
} | } | ||
</pre> | </pre> | ||
Runs a loop on the specified array and checks the triggers against the current element scope. If any return true, the whole check returns true, otherwise returns false. | |||
=== | === all_of_scopes === | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
<pre> | <pre> | ||
all_of_scopes = { | all_of_scopes = { | ||
array = <name> | |||
<triggers> | |||
} | } | ||
</pre> | </pre> | ||
Runs a loop on the specified array and checks the triggers against the current element scope. If any return false, the whole check returns false, otherwise returns true. | |||
== Additional information == | |||
{{SVersion|1.10}} | |||
You can set a variable equal to the number of elements in an array by using the following code: <code>set_variable = { var_name = array_name^num }</code> This example will set var_name to be equal to the number of elements in array_name. | |||
== | == Examples == | ||
{{SVersion|1. | {{SVersion|1.10}} | ||
{{Modding navbox}} | {{Modding navbox}} | ||
[[Category:Modding]] | [[Category:Modding]] |
2021年2月8日 (一) 22:17的版本
数组是《钢铁雄心IV》中用以存储变量的方式,变量既可以是
数组在
指令(Effects)
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
添加到数组(add_to_array)
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
add_to_array = { array = <name> value = <value> index = <index> }
每当有一个变量出现,就会创造一个对应的数组对其进行储存。
<name>是数组的名称,也是指令和触发器调用它的依据。
<value>是指数组的数据内容,它既可以是数字形式的(如1 或 var:my_num),也可以是作用域形式的(如GER 或 var:my_scope)。当然这些都是选填内容,如果不填则会将当前作用域填入此处。
<index>指数据内容应当被插入数组的哪个位置。
这部分的简便写法是:add_to_array = { <name> = <value> }
从数组中移除(remove_from_array)
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
remove_from_array = { array = <name> value = <value> index = <index> }
<name>是想要进行数据内容移除操作的数组名称
<value>是想要移除的数据内容
<index>指移除操作所选择的位置
如果value和index值都未定义或未分配内容,那么最后一个数据内容会被清除
这部分的简便写法是:remove_from_array = { <name> = <value> }
清空数组(clear_array)
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
clear_array = <name>
清除指定数组中所有数据内容
重置数组规模(resize_array)
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
resize_array = { array = <name> value = <value> size = <int> }
重置特定数组规模
如果扩大已经声明过数据内容类型的数组规模,那么多出的位置将以空变量填满,如果没有声明过则缺省值为0。
size属性指定了数组的新大小,如果缩小数组,则删除元素,如果扩大数组,则增加指定值的新元素。
这部分的简便写法是: resize_array = { <name> = <size> }
while_loop_effect
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
while_loop_effect = { break = <string> limit = { <triggers> } <effects> }
Runs the effect as long as a trigger is true.
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is break
.
Effects can be used within the loop to perform operations with the data within an array.
for_each_loop
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
for_each_loop = { array = <name> value = <string> index = <string> break = <string> <effects> }
Runs a loop for each element of the specified array.
The value attribute specifies a temp variable that stores the current value whilst iterating over the loop. By default this is v
.
The index attribute specifies a temp variable that stores the current index whilst iterating over the loop. By default this is i
.
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is break
.
Effects can be used within the loop to perform operations with the data within an array.
for_each_scope_loop
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
for_each_scope_loop = { array = <name> break = <string> <effects> }
Runs a loop for each element of the specified array and changes the current scope to the current element in each iteration.
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is break
.
Effects can be used within the loop to perform operations with the data within an array.
random_scope_in_array
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
random_scope_in_array = { array = <name> break = <string> limit = { <triggers> } <effects> }
Runs a loop for each element of the specified array and changes the current scope to a random scope (out of the scopes within the array) that meet the triggers specified.
The break attribute specifies a temp variable that can be set to non-0 to break the loop, ending iteration. By default this is break
.
Effects can be used within the loop to perform operations with the data within an array.
add_to_temp_array
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
Same as add_to_array
but for temporary arrays that expire once execution of the script is finished.
remove_from_temp_array
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
Same as remove_from_array
but for temporary arrays that expire once execution of the script is finished.
clear_temp_array
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
Same as clear_array
but for temporary arrays that expire once execution of the script is finished.
resize_temp_array
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
Same as resize_array
but for temporary arrays that expire once execution of the script is finished.
Triggers
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
is_in_array
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
is_in_array = { array = <name> value = <value> }
Checks if the specified value is in the specified array.
any_of
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
any_of = { array = <name> value = <string> index = <string> <triggers> }
Runs a loop on the specified array and checks the triggers against the current element. If any return true, the whole check returns true, otherwise returns false.
all_of
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
all_of = { array = <name> value = <string> index = <string> <triggers> }
Runs a loop on the specified array and checks the triggers against the current element. If any return false, the whole check returns false, otherwise returns true.
any_of_scopes
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
any_of_scopes = { array = <name> <triggers> }
Runs a loop on the specified array and checks the triggers against the current element scope. If any return true, the whole check returns true, otherwise returns false.
all_of_scopes
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
all_of_scopes = { array = <name> <triggers> }
Runs a loop on the specified array and checks the triggers against the current element scope. If any return false, the whole check returns false, otherwise returns true.
Additional information
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
You can set a variable equal to the number of elements in an array by using the following code: set_variable = { var_name = array_name^num }
This example will set var_name to be equal to the number of elements in array_name.
Examples
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.10。 |
文件 | 效果 • 条件 • 定义 • 修正 • 修正列表 • 作用域 • 本地化 • on action • 数据结构 (标记, 临时标记, 国家别名, 变量, 数组) |
脚本 | 成就修改 • AI修改 • AI focuses • 自治领修改 • 权力平衡修改 • 剧本/标签 (游戏规则)• 建筑修改 • 人物修改 • 修饰性TAG修改 • 国家创建 • 军队修改 • 决议制作 • 装备修改 • 事件修改 • Idea修改 • 意识形态修改 • 军工商修改 • 国策制作 • 资源修改 • Scripted GUI • 科技制作 • 单位修改 |
地图 | 地图 • 省份 • 补给区域 • 战略区域 |
图形图像 | 界面 • 图形资产 • 实体模型 • 后期特效 • 离子效果 • 字体 |
装饰性 | 肖像 • 命名列表 • 音乐 • 音效 |
其他 | 控制台指令 • 故障排除 • 模组结构 • 成就代码分析 • Mod相关 • Nudger修改 |