Arrays

本页面所适用的版本可能已经过时,最后更新于1.9


数组(Arrays)通常是储存数据的文件。在《钢铁雄心Ⅳ》中,数组可以存储定值数据和变值数据。

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

效果

添加数组

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

创建一个数组并写入内容。

<name>可以是你想触发的效果的名称

<value>是你要添加到数组的数据。它可以是定值数字(i.e. 1 or var:my_num) 或者一个范围 (i.e. GER or var:my_scope).这可以自己选择,如果不包括,那么可以把作用范围写入<value>

<index>是表示这个<value>应被插入这个数组的位置。一般情况下会被插入这个数组的末端,否则这个数据会被移动来容纳新的<value>

一个比较短的表达式: add_to_array = { <name> = <value> }

从数组移除

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

<name>是你要从中移除数据的数组。

<value>是你想从这个数组中移除的值 如果有的话t).

<index>是你想从这个数组中移除的索引(index) (如果有的话).

如果没有确定<value>或<index>,那么最末尾的那个就会被移除

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

clear_array

clear_array = <name>

Clears all data from the specified array.

resize_array

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

Resizes the specified array.

The value attribute sets any empty elements to the specified value if expanding the array. Defaults to 0 if not specified.

The size attribute specifies the new size of the array, removing elements if shrinking the array, or adding new elements with the specified value if expanding it.

A short form can be used: 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.

Examples