版本 Diff 差异对比
条目:变量 · 对比历史版本与当前版本间的真实 Wikitext 差异
+125 行新增-124 行移除
历史基准版本Rev #49598
/* 可导出变量 */
自由之民2018-11-08 15:42:35
当前最新版本Rev #91350
/* 可导出变量 */
Augustu-2022-06-10 17:37:49
Wikitext 语法逐行变动
当前版本新增历史版本移除
- {{version|1.23}}{{需要翻译|en=Variables}}
+ {{version|1.23}}
+ {{N|变量|Variable}},(在欧陆风云4中)是那些与特定的国家或省份相关联的持久值。
- '''变量'''(Variables),(在欧陆风云4中)是那些与特定的国家或省份相关联的持久值。
+ 基本上,变量只能用于脚本中的判断,而不能直接把运算结果赋值到游戏中。
- == 使用变量 ==
+ ==使用变量==
{{SVersion|1.23}}
变量能运算在 ''国家'' 和 ''省份'' 作用域,而且能在 ''效果'' 和 ''触发'' 两种上下文,尽管指令和条件在两种上下文用法迥异。
例如,如果我们想要跟踪一个事件对某个国家发生的次数,我们应该要用个变量。
'''注意1:''' 变量所能保存的浮点数有最大值。数值超过 2,147,484 将会溢出为负数。
'''注意2:''' 变量不能作为右侧参数使用(譬如在一个效果段落中),除非用于宗教和文化(见下文 ''[[#事件域值]]'' 段落)。这一点极大限制了变量的灵活性,当然,也从反面提高了Mod的健壮性。
- === 设置变量 ===
+ ===设置变量===
要关联一个变量和一个国家(或者省份),你首先需要设置这个变量。
<pre>
set_variable = {
which = myCountingVariable
value = 0
}
</pre>
- 典型地你会想要在一个设置事件里这么做,比如一个只在游戏开始时发生一次的事件。 You can do this fairly easily by using the '''on_startup''' on action and an event that checks for '''has_country_flag''' and sets it in the ''immediate'' section.
+ 典型地你会想要在一个设置事件里这么做,比如一个只在游戏开始时发生一次的事件。你能相当容易地这么做,通过使用 '''on_startup''' 在活动(action)和检查 '''has_country_flag''' 的事件,并且在 ''immediate'' 段落中设置它。
- === 递增变量 ===
- Having set your variable, you can now use the variable operation effects. So, in this theoretical event, we would add the following to the ''immediate'' section:
+ ===递增变量===
+ 设置完你的变量,你现在能使用该变量运算效果。这样,在这个假设的事件中,我们可以添加下列代码到 ''immediate'' 段落:
<pre>
immediate = {
change_variable = {
which = myCountingVariable
value = 1
}
}
</pre>
- This increments the '''myCountingVariable''' by 1. Variables are floats, meaning you can increment with non-integer values as well.
+ 这会把 '''myCountingVariable''' 增加1。变量是浮点数,意味着你也能用非整数值做加法。
- All of the variable operation effects are:
+ 所有变量运算效果:
<pre>
- change_variable # Add
- subtract_variable # Subtract
- divide_variable # Divide
- multiply_variable # Multiply
+ change_variable # 加法
+ subtract_variable # 减法
+ divide_variable # 除法
+ multiply_variable # 乘法
</pre>
- === 检查变量 ===
- Now we can track this event's occurrence, we now want to execute a different event when the variable reaches 5. To do this, we will have to utilise the variable comparison triggers in the event's trigger section.
+ ===检查变量===
+ 现在我们能跟踪这个事件的发生,当变量达到5时我们想要执行一个不同的事件。要做到这个,我们必须在事件的触发段落运用变量比较触发器。
- Here is how you would check the variable value is 5 and more:
+ 这里是你该如何检查变量值是5或者更多:
<pre>
check_variable = {
which = myCountingVariable
value = 5
}
</pre>
- To check if the variable is '''exactly''' 5, you'll want to include another inverted ''check_variable'':
+ 要检查变量是否 '''精确地''' 是5,你得要包含另一个反向的 ''check_variable'':
<pre>
check_variable = {
which = myCountingVariable
value = 5
}
NOT = {
check_variable = {
which = myCountingVariable
value = 6
}
}
</pre>
- === 本地化变量 ===
+ ===本地化变量===
我们能本地化变量,这样它就显示为我们定义的字符串,而不是变量脚本名。
<pre>
- myCountingVariable: \"My Counting Variable\"
+ myCountingVariable: "My Counting Variable"
</pre>
- In a different event, we may want to display this variable to the player in the event description. To do so, you can include the following localisation command:
+ 在一个不同的事件,我们可能想要给玩家在事件描述中显示这个变量。要这么做,你能包含下列本地化命令:
<pre>
- event_desc: \"[Root.myCountingVariable.GetName] [Root.myCountingVariable.GetValue]\"
+ event_desc: "[Root.myCountingVariable.GetName] [Root.myCountingVariable.GetValue]"
</pre>
- The ''Root'' here refers to the ''ROOT'' scope of the event. The localisation commands here use the ''myCountingVariable'' associated with ''ROOT'' and display the localised string (with GetName) and the current value for ''ROOT'' (with GetValue).
+ 这里的 ''Root'' 引用该事件的 ''ROOT'' 作用域。这里的本地化命令使用 ''myCountingVariable'' 与 ''ROOT'' 相关联,并且显示本地字符串(用GetName)和 ''ROOT'' 的当前值(用GetValue)。
- == 导出到变量 ==
- 变量能被导出的内部值填充(能用内部数值给变量赋值)。这意味着游戏数值诸如 ''monthly_income'' 能被导出到一个变量并且以各种方式使用。此外,变量可以与其他变量进行比较,which is very useful when they contain exported values, allowing for comparison that may otherwise not be possible.
+ ==导出到变量==
+ 变量能被导出的内部值填充(能用内部数值给变量赋值)。这意味着游戏数值诸如 ''monthly_income'' 能被导出到一个变量并且以各种方式使用。此外,变量可以与其他变量进行比较,当它们包含导出的值时那相当有用,允许比较其它方法不可能的数据。
- Let's say we want to make an event that gifts money depending on the country's monthly income but doesn't exceed the country's treasury. To do this we first need to export two variables in the event's ''immediate'' section:
+ 比如说我们想要做一个事件,花钱送礼依据该国的月收入,但是不超过该国的国库。要做这个我们先要导出两个变量在这个事件的 ''immediate'' 段落:
<pre>
export_to_variable = {
which = moneyToGive
value = monthly_income
who = ROOT
}
export_to_variable = {
which = moneyAvailable
value = treasury
who = ROOT
}
</pre>
然后我们想把国家的收入乘上六倍达到我们的礼物数额:
<pre>
multiply_variable = {
which = moneyToGive
value = 6
}
</pre>
为了确保礼物的规模不会大于国家的国库,我们要限制礼物规模到国家的当前国库数额,如果礼物规模比它更大的话:
<pre>
if = {
limit = {
- # Is moneyToGive greater than moneyAvailable
+ # 是 moneyToGive 比 moneyAvailable 更大吗
check_variable = {
which = moneyToGive
which = moneyAvailable
}
}
- # Set moneyToGive to moneyAvailable's value, as moneyToGive was greater than moneyAvailable
+ # 设置 moneyToGive 为 moneyAvailable 的值,因为 moneyToGive 比 moneyAvailable 更大
set_variable = {
which = moneyToGive
which = moneyAvailable
}
}
</pre>
然后在事件选项添加成比例的 ''add_treasury'',根据 ''moneyToGive'' 值:
<pre>
option = {
if = {
limit = {
NOT = { check_variable = { which = moneyToGive value = 25 } }
}
add_treasury = -10
FRA = { add_treasury = 10 }
}
if = {
limit = {
check_variable = { which = money_to_give value = 25 }
NOT = { check_variable = { which = moneyToGive value = 50 } }
}
add_treasury = -25
FRA = { add_treasury = 25 }
}
if = {
limit = {
check_variable = { which = money_to_give value = 50 }
NOT = { check_variable = { which = moneyToGive value = 100 } }
}
add_treasury = -50
FRA = { add_treasury = 50 }
}
}
</pre>
- == 效果 ==
+ ==效果==
效果相关的变量:
<pre>
set_variable = {
which = <var>
value = <float>
- which = <scope> # Used in place of value, makes <var> the <scope>'s value of <var>
+ which = <var> / <scope> # 用于替代值,把 <var> 变成第二个<var>或者<scope>的<var>值
}
</pre>
<pre>
change_variable = {
which = <var>
value = <float>
- which = <scope> # Used in place of value, makes <var> the <scope>'s value of <var>
+ which = <var> / <scope> # 用于替代值,把第二个<var>值加入到第一个 <var>值上或者把 <scope>的<var>值加到当前scope的<var>值上
}
</pre>
<pre>
subtract_variable = {
which = <var>
value = <float>
- which = <scope> # Used in place of value, makes <var> the <scope>'s value of <var>
+ which = <var> / <scope> # 用于替代值,把第一个<var>值减去第二个 <var>值或者把 <scope>的<var>值减入到当前scope的<var>值上
}
</pre>
<pre>
divide_variable = {
which = <var>
value = <float>
- which = <scope> # Used in place of value, makes <var> the <scope>'s value of <var>
+ which = <var> / <scope> # 用于替代值,将第一个<var>值除以第二个<var>值或者除以<scope>的<var>值
}
</pre>
<pre>
multiply_variable = {
which = <var>
value = <float>
- which = <scope> # Used in place of value, makes <var> the <scope>'s value of <var>
+ which = <var> / <scope> #用于替代值,将第一个<var>值乘以第二个<var>值或者乘以<scope>的<var>值
}
</pre>
<pre>
export_to_variable = {
- which = <var> # i.e. stabilityVar
- variable_name = <var> # same as which, alternative declaration
- value = <string> # i.e. stability
- who = <scope> # Who to grab the value from
+ which = <var> # 例如 stabilityVar
+ variable_name = <var> # 和 which 相同,另一种声明方式
+ value = <string> # 例如 stability
+ who = <scope> # 从谁抓取该值
- # Supports exporting trigger limit values. Works for int, float and boolean triggers
+ # 支持导出触发限制值。工作于整数、浮点和布尔值触发器
value = trigger_value:<trigger>
}
</pre>
- == 触发器 ==
+ ==触发器==
触发相关的变量:
<pre>
check_variable = {
which = <var>
value = <float>
- which = <var> # Used in place of value, checks value of the first <var> against the value of second <var>
+ which = <var> # 用于替代<value>一句,检查第一个 <var> 值相对于第二个 <var> 的值
}
is_variable_equal = {
which = <string1>
which = <string2>
}
</pre>
- == 变量算术触发器 ==
- Used within triggers to export variables whilst in a trigger scope.
+ ==变量算术触发器==
+ 在触发器内用于导出变量,同时在一个触发器作用域内(比较)。
- Here is a common example:
+ 这是一个通用的例子:
<pre>
variable_arithmetic_trigger = {
custom_tooltip = <string>
- # Exports must be done before triggers
+ # 导出必须在触发器之前完成
export_to_variable = {
variable_name = <string1>
value = <var>
}
export_to_variable = {
variable_name = <string2>
value = <var>
}
- # Normal triggers are valid here
+ # 普通的触发条件在这里有效
<triggers>
# Var1 == Var2
is_variable_equal = {
which = <string1>
which = <string2>
}
# Var1 >= Var2
check_variable = {
which = <string1>
which = <string2>
}
}
</pre>
- This is useful if you want to compare certain triggers against one another. For example, let's say you want to check if your ruler is older than a foreign heir. We have <code>ruler_age</code> and <code>heir_age</code> triggers, but you cannot do this: <code>ruler_age > FROM = { heir_age }</code>.
+ 这很有用,如果你想要比较特定的触发器和另一个。举个例子,假如说你想要检查你的统治者是否比一个外国继承人更老。我们有 <code>ruler_age</code> 和 <code>heir_age</code> 触发器,但是你不能这么做: <code>ruler_age > FROM = { heir_age }</code>。
- However, a variable arithmetic trigger let's you do this.
+ 不过,一个变量算数触发器让你能做到这点。
<pre>
variable_arithmetic_trigger = {
custom_tooltip = HAS_OLDER_RULER_THAN_THEIR_HEIR
export_to_variable = {
variable_name = my_age
value = trigger_value:ruler_age
}
export_to_variable = {
variable_name = their_age
value = trigger_value:heir_age
who = FROM
}
ruler_age = 0
FROM = {
heir_age = 0
}
check_variable = {
which = my_age
which = their_age
}
}
</pre>
- == 事件域值 ==
- 事件域值(Event scope values) are used to reference the index of a variable to a culture or religion. This occurs when you export a culture or religion with '''export_to_variable'''.
+ ==事件域值==
+ 事件域值(Event scope values)用于对一个文化或宗教引用变量索引值。这发生在当你用 '''export_to_variable''' 导出一个文化或者宗教时。
- Whilst the actual value of the variable remains is a number, this number is an index of the culture or religion's location in their respective list. This index is transformed into the correct culture or religion when used with certain effects and triggers.
+ 其实,该变量的真实值仍然是一个数字,这个数字是一个文化或者宗教的、在它们各自的列表中的位置的索引值。当使用在特定的效果和触发时,这个索引值被转换为正确的文化或者宗教。
- To export variables for this, you need to use this syntax:
+ 要为此导出变量,你需要用这个语法:
<pre>
export_to_variable = {
variable_name = myVarName
value = <export value>
}
</pre>
- To use the variable with the effect or trigger, you use this syntax:
+ 要把改变量用于效果或触发,你要用这个语法:
<pre>
set_heir_culture = variable:myVarName
</pre>
- This syntax supports ''FROM'', meaning you can scope to a province and use ''FROM'' inline to scope to the country where the variable was exported.
+ 这个语法支持 ''FROM'',意味着你能转换定义域到一个省份,并且用 ''FROM'' 内联切换定义域到(inline to scope to)该变量被导出的国家。
<pre>
any_owned_province = {
culture = variable:From::myVarName
}
</pre>
- Additionally, in triggers you can use this syntax to grab a export values for comparison:
+ 另外,在触发器里你能用这个语法抓取导出值用于比较:
<pre>
religion_group = new_variable:ruler_religion
</pre>
- This allows you to check export values within triggers (since '''export_to_variable''' is an effect).
+ 这允许你在触发器内检查导出值(因为 '''export_to_variable''' 是效果)。
支持的效果指令:
<pre>
change_religion
change_culture
change_primary_culture
set_ruler_culture
set_ruler_religion
set_consort_culture
set_consort_religion
set_heir_culture
set_heir_religion
</pre>
支持的触发条件:
<pre>
ruler_culture
consort_culture
heir_culture
ruler_religion
consort_religion
heir_religion
culture
religion
</pre>
- == 可导出变量 ==
- === 国家 ===
- {| class=\"wikitable sortable\" width=\"100%\"
- ! width=\"40%\" | 值
- ! width=\"60%\" | 注释
+ ==可导出变量==
+ ===国家===
+ {| class="wikitable sortable" width="100%"
+ ! width="40%" |值
+ ! width="60%" |注释
|-
- |modifier:<country modifier>
+ |modifier:<country modifier>
|<code>modifier:<modifier></code> 语法对于任何国家修正都工作。
|-
|trigger_value:<trigger>
|<code>trigger_value:<trigger></code> 语法对于触发器工作,然后返回整数、浮点数或布尔值。更复杂的触发器不工作。
|-
|prestige
- |
+ |威望
|-
|war_exhaustion
- |
+ |
|-
|corruption
- |
+ |腐败
|-
|stability
- |
+ |稳定
|-
|treasury
- |
+ |国库
|-
|mercantilism
- |
+ |重商主义
|-
|inflation
- |
+ |通货膨胀
|-
|num_of_cities
- |
+ |城市数量
|-
|num_of_ports
- |
+ |港口数量
|-
|adm_tech
- |
+ |行政科技
|-
|dip_tech
- |
+ |外交科技
|-
|mil_tech
- |
+ |军事科技
|-
|years_of_income
- |
+ |年收入
|-
|monthly_income
- |
+ |月收入
|-
|trade_income_percentage
- |
+ |贸易收入占比
|-
|states_development
- |
+ |<sub>发展度相关</sub>
|-
|total_development
- |
+ |<sub>发展度相关</sub>
|-
|average_autonomy
- |
+ |<sub>自治度相关</sub>
|-
|average_home_autonomy
- |
+ |<sub>自治度相关</sub>
|-
|manpower
- |
+ |人力
|-
|manpower_percentage
- |
+ |人力(百分比)
|-
|max_manpower
- |
+ |最大人力
|-
|land_forcelimit
- |
+ |陆军上限
|-
|naval_forcelimit
- |
+ |海军上限
|-
|army_tradition
- |
+ |陆军传统
|-
|navy_tradition
- |
+ |海军传统
|-
|army_size
- |
+ |陆军规模
|-
|navy_size
- |
+ |海军规模
|-
|average_unrest
- |
+ |
|-
|average_autonomy_above_min
- |
+ |
|-
|average_effective_unrest
- |
+ |
|-
|num_of_rebel_armies
- |
+ |叛军军队数量
|-
|num_of_rebel_controlled_provinces
- |
+ |叛军控制省份数量
|-
|overextension_percentage
- |
+ |
|-
|ADM
|当前统治者 ADM 技能
|-
|DIP
|当前统治者 DIP 技能
|-
|MIL
|当前统治者 MIL 技能
|-
|consort_adm
- |
+ |配偶政治(ADM)能力
|-
|consort_dip
- |
+ |配偶外交(DIP)能力
|-
|consort_mil
- |
+ |配偶军事(MIL)能力
|-
|heir_adm
- |
+ |
|-
|heir_dip
- |
+ |
|-
|heir_mil
- |
+ |
|-
|monarch_age
|
|-
|consort_age
- |如果没有配偶存在,返回当前游戏内年份减1。
+ |
|-
|heir_age
|如果没有继承人存在,返回当前游戏内年份减1。
|-
|patriarch_authority
- |
+ |
|-
|piety
- |
+ |
|-
|religious_unity
- |
+ |宗教统一
|-
|tolerance_to_this
|引用正统信仰容忍。
|-
|religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|dominant_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|secondary_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|ruler_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|heir_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|consort_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|adm_advisor_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|dip_advisor_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|mil_advisor_religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|-
|primary_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|dominant_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|ruler_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|heir_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|consort_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|adm_advisor_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|dip_advisor_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|mil_advisor_culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|border_distance
- |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。
+ |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。边境距离
|-
|capital_distance
- |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。
+ |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。首都距离
|-
|opinion
- |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。
+ |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。观点
|-
|trust
- |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。
+ |需要在 '''export_to_variable''' 里使用 <code>who = <scope></code> 才能正确地工作。信任
|}
- === 省份 ===
- {| class=\"wikitable sortable\" width=\"100%\"
- ! width=\"40%\" | 值
- ! width=\"60%\" | 注释
+ ===省份===
+ {| class="wikitable sortable" width="100%"
+ ! width="40%" |值
+ ! width="60%" |注释
|-
|modifier:<province modifier>
|<code>modifier:<modifier></code> 语法对于任何省份修正都工作。
|-
|trigger:<trigger>
|<code>trigger:<trigger></code> 语法对于触发器工作,然后返回整数、浮点数或布尔值。更复杂的触发器不工作。
|-
|base_tax
- |
+ |基础税收
|-
|base_production
- |
+ |基础生产
|-
|base_manpower
- |
+ |基础人力
|-
|development
- |
+ |发展
|-
|unrest
- |
+ |叛乱
|-
|nationalism
- |
+ |分离主义
|-
|local_autonomy
- |
+ |省份自治度
|-
|province_trade_power
- |
+ |省份贸易力量
|-
|tolerance_to_this
|引用正统信仰容忍。
|-
|culture
|返回一个索引值,例如:1是英格兰,2是法兰西,等等。当使用正确的效果和触发器时,数值被转换为特定的文化。
|-
|religion
|返回一个索引值,例如:1是天主教,2是新教,等等。当使用正确的效果和触发器时,数值被转换为特定的宗教。
|}
- == 参考资料 ==
- <references/>
+ ==参考资料==
+ <references />
{{Modding navbox}}
- [[Category:改派教程]]
+ [[Category:模组制作]]
[[en:Variables]]
