作用域:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.1
无编辑摘要
(咯咯炀移动页面Scopes作用域
(没有差异)

2020年11月11日 (三) 19:03的版本

CK3 Scope Overview Chart

Scopes are used in scripting to select entities in order to check for conditions or apply commands.

Uses

Scopes always have a bracketed block on the right side:

<scope_name> = {
    #Stuff to execute in the scope.
}

But not all bracketed blocks are scopes: some are function blocks (option, trigger,...), operators (AND), flow control statements (if, limit), or clause for complex conditions or commands (create_character, ...).

There are several types of scopes accessible from script. These include, but are not limited to: character, title/holding, province, war, unit, religion, faith, culture.

Scopes can be nested, and are usually relative to the scope from which there are called, except for the ones that are global and can be called from "Any" scope.

In Jomini, Scopes can also be chained without nesting:

root.mother.father.killer = {
    #Things we want to do with the killer of the father of the mother of the root character.
}

We can also directly compare scopes for equality:

trigger = {
    root.mother = scope:other_character.mother
}

In CK3, the ability to save and recall scopes has been vastly simplified by the addition of the save_scope_as command, which can save a given scope under a name, to be recalled later:

<scope> = {
    save_scope_as = <scope_name>
}
scope:<scope_name> = {
    #Stuff to execute in the scope.
}

Saved scopes will stay saved within the current code chain, that is, they will remain accessible until every action/event/effect/etc that is run as a result of the current one has been evaluated to completion. They will only be accessible in the given code chain. For example, if there is an event chain that takes years to complete, a scope saved in the initial event will remain accessible until the concluding event, but will not be accessible to any other events that may occur during that time frame.

Triggers and effects in scopes are only evaluated and executed if the scope exists. This can be used with always = yes to check for the existence of a scope in a trigger or for effects that you only want to execute if, for example, a character's religion has a religious head.

Note that the condition tooltips within any_ scopes are misleading and only show whether the conditions are satisfied for one specific, seemingly randomly-chosen thing contained within the scope, and thus may show that some conditions are false even when the scope itself evaluates to true. These are best overridden with a custom_tooltip.

References


机制 
角色 角色属性特质资源生活方式宗族亲族文化革新传统修正宝物
领地与管理 领地封臣内阁宫廷谋略政体法律决议头衔男爵领伯爵领朝廷建筑
战争 战争宣战理由同盟军队受雇军队
信仰 宗教信仰教义核心教义圣地
模组制作补丁可下载内容开发者日志成就术语