Arrays:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.10
(翻译(未完待续))
第1行: 第1行:
{{version|1.9}}
{{version|1.10}}
数组是《钢铁雄心IV》中用以存储变量的方式,变量既可以是{{ruby|'''数字形式'''|numerical data}}的,也可以是{{ruby|'''作用域'''|scope data}}形式的。


 数组 (Arrays)通常是储存数据的文件。 《钢铁雄心Ⅳ》 中,数 可以 存储定值 据和变值 数据。
 数组在{{ruby|'''指令'''|effects}} 发挥作用 并且{{ruby|'''触发器'''|trigger}}能够从中读取 据。指令既 可以 使 组迭代入其他指令,也能使其 数据 在自身内进行迭代


数组可以在游戏中出现一些效果,可以触发它们来检查它们。有些特殊的功能允许重复将同一个数组或者其中的部分数据用于其他的效果。


==  效果 ==
==  指令(Effects)==
{{SVersion|1.9}}
{{SVersion|1.10}}


=== 添加数组 ===
=== 添加 数组 (add_to_array)  ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>add_to_array = {
<pre>add_to_array = {
第17行: 第17行:
}
}
</pre>
</pre>
每当有一个变量出现,就会创造一个对应的数组对其进行储存。


创建一个 数组 并写入内容 。 
<name>是 数组 的名称,也是指令和触发器调用它的依据


<name>可以是 你想触发 的名称
<value> 是指数组的数据内容,它既可以是数字形式的(如1 或 var:my_num),也 可以是 作用域形式 (如GER 或 var:my_scope)。当然这些都是选填内容,如 不填则会将当前作用域填入此处。


<value> 是你要添加到 数组的数据 。它可以是定值 字(i.e. 1 or var:my_num) 或者一个范围 (i.e. GER or var:my_scope).这可以 己选择,如果不包括,那么可以把作用范围写入<value>
<index> 指数据内容应当被插入 数组的 哪个位置。{{ruby|'''缺省'''|default data}}(现普遍称'''默认''')情况下, 数据 内容会插入数组的最后端,其他情况下新 据内容会 动匹配到合适的位置。


<index> 是表示这个<value> 应被插入这个数组的位置。一般情况下会被插入这个数组的末端,否则这个数据会被移动来容纳新的<value
这部分的简便写法是:<code>add_to_array = { <name> = <value> }</code>


一个比较短的表达式: <code>add_to_array = { <name> = <value> }</code>
=== 从数组 移除 (remove_from_array) ===
 
{{SVersion|1.10}}
=== 从数组移除 ===
{{SVersion|1.9}}


<pre>remove_from_array = {
<pre>remove_from_array = {
   array = <name>
array = <name>
   value = <value>
value = <value>
   index = <index>
index = <index>
}
}
</pre>
</pre>
<name>是想要进行数据内容移除操作的数组名称


<name>是 从中 移除数据 的数组。
<value>是 要移除 数据 内容


<value> 是你想从这个数组中 移除的 值 如果有的话t).
<index> 移除 操作所选择 位置


<index>是你想从这 个数 组中移 的索引(index) (如果有的话).
如果value和index值都未定义或未分配内容,那么最后一 个数 据内容会被清


  如果没有确定<value> <index> ,那么最末尾的那个就会被移除
  这部分的简便写法是:<code>remove_from_array = { <name> = <value> }</code>


一个较短的表达式: <code>remove_from_array = { <name> = <value> }</code>


=== 清 数组 ===
=== 清 数组 (clear_array) ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>clear_array = <name></pre>
<pre>clear_array = <name></pre>


 清除指定数组中 所有数据
 清除指定数组中所有数据 内容


===  调整 数组 ===
===  重置 数组 规模(resize_array) ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>resize_array = {
<pre>resize_array = {
   array = <name>
array = <name>
   value = <value>
value = <value>
   size = <int>
size = <int>
}
}
</pre>
</pre>
重置特定数组规模


  调整指定 的数组 
  如果扩大已经声明过数据内容类型 的数组 规模,那么多出的位置将以空变量填满,如果没有声明过则缺省值为0。


<value>是写入这个 数组的 值。 如果 没有 指定 一个 ,那么会自动设为0
size属性指定了 数组的 新大小,如果缩小数组,则删除元素, 如果 扩大数组,则增加 指定值 的新元素。


<size> 用于写入新数据的大小, 删除或缩小数组中的数据,或者添加有指定的值的新数据
这部分的简便写法是: <code>resize_array = { <name> = <size> }</code>


一个较短的表达式: <code>resize_array = { <name> = <size> }</code>


=== 循环效果 ===
=== while_loop_effect ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>while_loop_effect = {
<pre>
   break = <string>
while_loop_effect = {
   limit = { <triggers> }
break = <string>
  
limit = { <triggers> }
   <effects>
<effects>
}
}
</pre>
</pre>


触发条件正确即触发效果。
Runs the effect as long as a trigger is true.


<break>填入一个临时的变量,可以设置为不为0的数以停止循环。默认是 <code>break</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_loop ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>for_each_loop = {
<pre>
   array = <name>
for_each_loop = {
   value = <string>
array = <name>
   index = <string>
value = <string>
   break = <string>
index = <string>
  
break = <string>
   <effects>
<effects>
}
}
</pre>
</pre>


给指定数组的每个数据执行循环。
Runs a loop for each element of the specified array.


<value>写入一个临时的变量,在循环时会储存当前的值。默认是 <code>v</code>.
The value attribute specifies a temp variable that stores the current value whilst iterating over the loop. By default this is <code>v</code>.


<index> 写入一个临时的变量,在循环时储存当前的顺序索引,默认是 <code>i</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>.


<break>填入一个临时的变量,可以设置为不为0的数以停止循环。默认是 <code>break</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.9}}
{{SVersion|1.10}}


<pre>for_each_scope_loop = {
<pre>
   array = <name>
for_each_scope_loop = {
   break = <string>
array = <name>
  
break = <string>
   <effects>
<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.


<break>填入一个临时的变量,可以设置为不为0的数以停止循环。默认是<code>break</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.


=== 数组中的随机范围 ===
=== random_scope_in_array ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>random_scope_in_array = {
<pre>
   array = <name>
random_scope_in_array = {
   break = <string>
array = <name>
   limit = { <triggers> }
break = <string>
  
limit = { <triggers> }
   <effects>
<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.


<break>填入一个临时的变量,可以设置为不为0的数以停止循环。默认是<code>break</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.


=== 添加临时数组 ===
=== add_to_temp_array ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<code>add_to_array (添加数组)</code>  一样,但是是在效果执行完后就过期的临时数组
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.9}}
{{SVersion|1.10}}


<code>remove_from_array(从数组中移除)</code> 一样,但是是在效果执行完后就过期的临时数组
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.9}}
{{SVersion|1.10}}


<code>clear_array (清除数组)</code> 一样,但是是在效果执行完后就过期的临时数组
Same as <code>clear_array </code> but for temporary arrays that expire once execution of the script is finished.


=== 调整临时数组 ===
=== resize_temp_array ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<code>rese_array(调整数组)</code>  一样,但是是在效果执行完后就过期的临时数组
Same as <code>resize_array</code> but for temporary arrays that expire once execution of the script is finished.


== 触发 ==
== Triggers ==
{{SVersion|1.9}}
{{SVersion|1.10}}


=== 在数组中 ===
=== is_in_array ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>is_in_array = {
<pre>
   array = <name>
is_in_array = {
   value = <value>
array = <name>
value = <value>
}
}
</pre>
</pre>


检查指定的指是否在指定的数组中
Checks if the specified value is in the specified array.


=== any_of ===
=== any_of ===
{{SVersion|1.9}}
{{SVersion|1.10}}


<pre>any_of = {
<pre>
   array = <name>
any_of = {
   value = <string>
array = <name>
   index = <string>
value = <string>
  
index = <string>
   <triggers>
<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.9}}
{{SVersion|1.10}}


<pre>all_of = {
<pre>
   array = <name>
all_of = {
   value = <string>
array = <name>
   index = <string>
value = <string>
  
index = <string>
   <triggers>
<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.9}}
{{SVersion|1.10}}


<pre>
<pre>
any_of_scopes = {
any_of_scopes = {
   array = <name>
array = <name>
  
   <triggers>
<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.9}}
{{SVersion|1.10}}


<pre>
<pre>
all_of_scopes = {
all_of_scopes = {
   array = <name>
array = <name>
  
   <triggers>
<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.9}}
{{SVersion|1.10}}


{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding]]
[[Category:Modding]]

2021年2月8日 (一) 22:17的版本

数组是《钢铁雄心IV》中用以存储变量的方式,变量既可以是数字形式numerical data的,也可以是作用域scope data形式的。

数组在指令effects中发挥作用,并且触发器trigger能够从中读取数据。指令既可以使数组迭代入其他指令,也能使其数据在自身内进行迭代。


指令(Effects)

添加到数组(add_to_array)

add_to_array = {
    array = <name>
    value = <value>
    index = <index>
}

每当有一个变量出现,就会创造一个对应的数组对其进行储存。

<name>是数组的名称,也是指令和触发器调用它的依据。

<value>是指数组的数据内容,它既可以是数字形式的(如1 或 var:my_num),也可以是作用域形式的(如GER 或 var:my_scope)。当然这些都是选填内容,如果不填则会将当前作用域填入此处。

<index>指数据内容应当被插入数组的哪个位置。缺省default data(现普遍称默认)情况下,数据内容会插入数组的最后端,其他情况下新数据内容会自动匹配到合适的位置。

这部分的简便写法是:add_to_array = { <name> = <value> }

从数组中移除(remove_from_array)

remove_from_array = {
	array = <name>
	value = <value>
	index = <index>
}

<name>是想要进行数据内容移除操作的数组名称

<value>是想要移除的数据内容

<index>指移除操作所选择的位置

如果value和index值都未定义或未分配内容,那么最后一个数据内容会被清除

这部分的简便写法是:remove_from_array = { <name> = <value> }


清空数组(clear_array)

clear_array = <name>

清除指定数组中所有数据内容

重置数组规模(resize_array)

resize_array = {
	array = <name>
	value = <value>
	size = <int>
}

重置特定数组规模

如果扩大已经声明过数据内容类型的数组规模,那么多出的位置将以空变量填满,如果没有声明过则缺省值为0。

size属性指定了数组的新大小,如果缩小数组,则删除元素,如果扩大数组,则增加指定值的新元素。

这部分的简便写法是: resize_array = { <name> = <size> }


while_loop_effect

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

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

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

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

Same as add_to_array but for temporary arrays that expire once execution of the script is finished.

remove_from_temp_array

Same as remove_from_array but for temporary arrays that expire once execution of the script is finished.

clear_temp_array

Same as clear_array but for temporary arrays that expire once execution of the script is finished.

resize_temp_array

Same as resize_array but for temporary arrays that expire once execution of the script is finished.

Triggers

is_in_array

is_in_array = {
	array = <name>
	value = <value>
}

Checks if the specified value is in the specified array.

any_of

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

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

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

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

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