Difference between revisions of "StandardSideFilter"
From The Battle for Wesnoth Wiki
(document [filter_side] priority over inline side=) |
(Add some anchors that can be linked to) |
||
(22 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
{{WML Tags}} | {{WML Tags}} | ||
− | From [[FilterWML]], this is the standard way of filtering on sides. | + | From [[FilterWML]], this is the standard way of filtering on sides. Often a SSF needs to be included in a [filter_side] tag. There are however also many tags that take the SSF tags and keys directly as arguments. |
− | * '''side''': filter matches only if side number is contained in a comma-separated list. | + | The following attributes and sub-tags are permitted: |
− | * '''[has_unit]''': filter matches only if side controls a unit matched by this [[StandardUnitFilter]] | + | |
+ | * '''side''': filter matches only if side number is contained in a comma-separated list. Note that as opposed to the usual inline side= key in wml action tags, which defaults to 1, the side= key in a SSF defaults to all sides (similarly, the id= key in SUFs defaults to all ids). This key also accepts ranges (i.e. "1,3-4,6") | ||
+ | * {{anchor|has_unit|'''[has_unit]'''}}: | ||
+ | **'''[[StandardUnitFilter]]''': filter matches only if side controls a unit matched by it | ||
+ | **'''search_recall_list''': (boolean yes|no, default no) whether to include recall list units when trying to match this [[StandardUnitFilter]] against a unit | ||
+ | |||
+ | * '''team_name''': The currently filtered side matches only if this passed team_name is contained in its (the filtered side's) team_name= string. Note that a side can be allied/on the same team like 2 (more...) other sides which can be enemies at the same time. (achieved by defining a side via [side]team_name=1,2 etc.) | ||
+ | |||
+ | * {{anchor|enemy_of|'''[enemy_of]'''}}: The currently filtered side must be an enemy of all of the sides matching this StandardSideFilter for it to match. If this inner StandardSideFilter matches no sides, the outer filter also doesn't. Note that a side is not an enemy of itself. | ||
+ | **StandardSideFilter tags and keys | ||
+ | |||
+ | * {{anchor|allied_with|'''[allied_with]'''}}: The currently filtered side must be allied with all of the sides matching this StandardSideFilter for it to match. If this inner StandardSideFilter matches no sides, the outer filter also doesn't. Note that a side is allied with itself. | ||
+ | **StandardSideFilter tags and keys | ||
+ | |||
+ | * {{anchor|has_enemy|'''[has_enemy]'''}}: The currently filtered side must have at least one enemy matching this StandardSideFilter for it to match. (Note that a side is not an enemy of itself.) | ||
+ | **StandardSideFilter tags and keys. | ||
+ | |||
+ | * {{anchor|has_ally|'''[has_ally]'''}}: The currently filtered side must have at least one ally matching this StandardSideFilter for it to match. (Note that a side is allied with itself.) | ||
+ | **StandardSideFilter tags and keys. | ||
+ | |||
+ | * '''controller''': The currently filtered side matches only if it has this controller string. Sensible values are ai, human, and null. This key is disabled for networked multiplayer, since there the controller value of a side may differ between the clients. Thus using this key would inevitably lead to OOS errors. | ||
+ | |||
+ | * '''formula''': {{DevFeature1.13|5}} A formula using [[Wesnoth Formula Language]]. Do not surround the formula in <code>$(...)</code>, since that will erase the <tt>self</tt> variable. | ||
Also, [and], [or], and [not] subfilters are supported. | Also, [and], [or], and [not] subfilters are supported. | ||
+ | == Wesnoth Formula Language == | ||
+ | |||
+ | When using the '''formula''' key, the context object is a '''side object''' which supports the following keys: | ||
+ | |||
+ | * '''side_number''' | ||
+ | * '''id''' | ||
+ | * '''save_id''' | ||
+ | * '''gold''' | ||
+ | * '''start_gold''' | ||
+ | * '''base_income''' | ||
+ | * '''total_income''' | ||
+ | * '''village_gold''' | ||
+ | * '''village_support''' | ||
+ | * '''recall_cost''' | ||
+ | * '''name''' | ||
+ | * '''is_human''' | ||
+ | * '''is_ai''' | ||
+ | * '''is_network''' | ||
+ | * '''fog''' - true if the side has fog enabled | ||
+ | * '''shroud''' - true if the side has shroud enabled | ||
+ | * '''hidden''' | ||
+ | * '''flag''' | ||
+ | * '''flag_icon''' | ||
+ | * '''team_name''' | ||
+ | * '''color''' | ||
+ | * '''share_vision''' | ||
+ | * '''carryover_bonus''' | ||
+ | * '''carryover_percentage''' | ||
+ | * '''carryover_add''' | ||
+ | * '''recruit''' - a list of possible recruits | ||
+ | * '''wml_vars''' - the WML variables stored with the side | ||
+ | |||
+ | == Interaction with inline side key == | ||
− | Interaction of SSF and side= in tags like [ | + | Interaction of SSF and side= in tags like [remove_shroud] : |
In case that inline side= and [filter_side] are given, inline side= is ignored and [filter_side]side= gets priority: | In case that inline side= and [filter_side] are given, inline side= is ignored and [filter_side]side= gets priority: | ||
selects side 4 and 5: | selects side 4 and 5: | ||
− | [ | + | [remove_shroud] |
side=2 | side=2 | ||
[filter_side] | [filter_side] | ||
side=4,5 | side=4,5 | ||
[/filter_side] | [/filter_side] | ||
− | [ | + | [remove_shroud] |
Latest revision as of 01:13, 25 February 2024
From FilterWML, this is the standard way of filtering on sides. Often a SSF needs to be included in a [filter_side] tag. There are however also many tags that take the SSF tags and keys directly as arguments.
The following attributes and sub-tags are permitted:
- side: filter matches only if side number is contained in a comma-separated list. Note that as opposed to the usual inline side= key in wml action tags, which defaults to 1, the side= key in a SSF defaults to all sides (similarly, the id= key in SUFs defaults to all ids). This key also accepts ranges (i.e. "1,3-4,6")
- [has_unit]:
- StandardUnitFilter: filter matches only if side controls a unit matched by it
- search_recall_list: (boolean yes|no, default no) whether to include recall list units when trying to match this StandardUnitFilter against a unit
- team_name: The currently filtered side matches only if this passed team_name is contained in its (the filtered side's) team_name= string. Note that a side can be allied/on the same team like 2 (more...) other sides which can be enemies at the same time. (achieved by defining a side via [side]team_name=1,2 etc.)
- [enemy_of]: The currently filtered side must be an enemy of all of the sides matching this StandardSideFilter for it to match. If this inner StandardSideFilter matches no sides, the outer filter also doesn't. Note that a side is not an enemy of itself.
- StandardSideFilter tags and keys
- [allied_with]: The currently filtered side must be allied with all of the sides matching this StandardSideFilter for it to match. If this inner StandardSideFilter matches no sides, the outer filter also doesn't. Note that a side is allied with itself.
- StandardSideFilter tags and keys
- [has_enemy]: The currently filtered side must have at least one enemy matching this StandardSideFilter for it to match. (Note that a side is not an enemy of itself.)
- StandardSideFilter tags and keys.
- [has_ally]: The currently filtered side must have at least one ally matching this StandardSideFilter for it to match. (Note that a side is allied with itself.)
- StandardSideFilter tags and keys.
- controller: The currently filtered side matches only if it has this controller string. Sensible values are ai, human, and null. This key is disabled for networked multiplayer, since there the controller value of a side may differ between the clients. Thus using this key would inevitably lead to OOS errors.
- formula: (Version 1.13.5 and later only) A formula using Wesnoth Formula Language. Do not surround the formula in
$(...)
, since that will erase the self variable.
Also, [and], [or], and [not] subfilters are supported.
Wesnoth Formula Language
When using the formula key, the context object is a side object which supports the following keys:
- side_number
- id
- save_id
- gold
- start_gold
- base_income
- total_income
- village_gold
- village_support
- recall_cost
- name
- is_human
- is_ai
- is_network
- fog - true if the side has fog enabled
- shroud - true if the side has shroud enabled
- hidden
- flag
- flag_icon
- team_name
- color
- share_vision
- carryover_bonus
- carryover_percentage
- carryover_add
- recruit - a list of possible recruits
- wml_vars - the WML variables stored with the side
Interaction with inline side key
Interaction of SSF and side= in tags like [remove_shroud] : In case that inline side= and [filter_side] are given, inline side= is ignored and [filter_side]side= gets priority:
selects side 4 and 5:
[remove_shroud] side=2 [filter_side] side=4,5 [/filter_side] [remove_shroud]
This page was last edited on 25 February 2024, at 01:13.