Difference between revisions of "InterfaceActionsWML"
m (→[animate_unit]: mark female_text translatable) |
(→[message]) |
||
(103 intermediate revisions by 23 users not shown) | |||
Line 16: | Line 16: | ||
The following key/tags are accepted for [message]: | The following key/tags are accepted for [message]: | ||
− | * [[StandardUnitFilter]]: The unit whose profile and name are displayed. Do not use a [filter] tag. If no unit matching this filter is found, the message is not displayed (The unit has probably been killed).<br> | + | * [[StandardUnitFilter]]: The unit whose profile and name are displayed. Do not use a [filter] tag. If no unit matching this filter is found, the message is not displayed (The unit has probably been killed).<br>[message] elements should be constructed so that it is either guaranteed that a certain unit is alive, or so that dialog flows smoothly even if the message isn't displayed. |
* '''speaker''': an alternative to standard unit filter. You may specify as the value of the speaker attribute a unit id or any of the following special values: | * '''speaker''': an alternative to standard unit filter. You may specify as the value of the speaker attribute a unit id or any of the following special values: | ||
Line 24: | Line 24: | ||
* '''message''': (translatable) the text to display to the right of the image. ''message'' is sometimes multiple lines; if it is, be sure to use quotes(''' ' ''' or ''' " ''') | * '''message''': (translatable) the text to display to the right of the image. ''message'' is sometimes multiple lines; if it is, be sure to use quotes(''' ' ''' or ''' " ''') | ||
+ | * '''male_message''', '''female_message''': {{DevFeature1.13|2}} (translatable) Used instead of ''message'' if the unit's gender matches. Never used if there is no unit (ie ''speaker=narrator''). {{DevFeature1.13|6}} This matches the primary unit, not the secondary unit. | ||
+ | * '''wait_description''': {{DevFeature1.13|2}} the description of this message displayed when other players in a mp game wait for one player doing input in a [message] (with [option]s or [text_input]). | ||
* '''[show_if]''': if present then this message will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) | * '''[show_if]''': if present then this message will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) | ||
− | * '''side_for''': (default: all sides) comma-separated list of sides for who message is shown. This will <b>not</b> work with messages that take user input ([option]/[text_input]), which can only ever be shown to the current player. {{DevFeature1.13|0}} | + | * '''side_for''': (default: all sides) comma-separated list of sides for who message is shown. This will <b>not</b> work with messages that take user input ([option]/[text_input]), which can only ever be shown to the current player. {{DevFeature1.13|0}} side_for= is now also accepted for messages with user input, it specifies on which side the message is shown (defaults to the currently playing side). For messages with input it does not accept a comma seperated list only a single number. |
− | * '''image''': (default: profile image of speaker) the image to display | + | * '''image''': (default: profile image of speaker) the image to display to the left of the message text. Append ~RIGHT() if you want the image to appear on the right side. |
** {{DevFeature1.13|0}} <b>none:</b> display no image | ** {{DevFeature1.13|0}} <b>none:</b> display no image | ||
+ | * '''mirror''': {{DevFeature1.13|5}}whether to mirror the image specified by the '''image''' attribute. | ||
+ | * '''second_image''': {{DevFeature1.13|6}}same as the '''image''' attribute, but the image is displayed on the right of the message text. {{DevFeature1.17|7}}not working anymore, but there is plan to fix it eventually https://github.com/wesnoth/wesnoth/issues/8770 | ||
+ | * '''second_mirror''': {{DevFeature1.13|6}}same as '''mirror''', but for the '''second_image''' attribute. | ||
+ | * '''image_pos''': {{DevFeature1.13|5}} whether to show the image on the left or right; supercedes the use of ~RIGHT() described above | ||
* '''caption''': (default: name of speaker) the caption to display beside the image. Name to be displayed. Note: use a translation mark to avoid wmllint errors. | * '''caption''': (default: name of speaker) the caption to display beside the image. Name to be displayed. Note: use a translation mark to avoid wmllint errors. | ||
* '''scroll''': Boolean specifying whether the game view should scroll to the speaking unit. Defaults to ''yes''. | * '''scroll''': Boolean specifying whether the game view should scroll to the speaking unit. Defaults to ''yes''. | ||
− | * ''' | + | * '''highlight''': {{DevFeature1.13|5}} Boolean specifying whether to highlight the speaker. Defaults to ''yes''. |
* '''sound''': a sound effect (wav file) to play as the message is displayed. This can be a comma-separated list, from which one will be randomly chosen. | * '''sound''': a sound effect (wav file) to play as the message is displayed. This can be a comma-separated list, from which one will be randomly chosen. | ||
− | * '''[option]''': No '''[option]''' elements have to be used. If '''[option]''' elements are present, then each option will be displayed in a menu for the user to select one option. ''Note: Messages with options will not be shown at all in prestart events'' | + | * '''voice''', '''male_voice''', '''female_voice''': {{DevFeature1.13|?}} a sound to be played as the message is displayed. This can also be a comma-separated list, from which one will be randomly chosen. This is intended for voiceovers for the message. The gendered forms are applied the same as for '''message'''. They are never used when the speaker is the narrator - only '''voice''' is used in that case. |
− | ** '''message''': (translatable) the text displayed for the option | + | * {{anchor|message-option|'''[option]'''}}: No '''[option]''' elements have to be used. If '''[option]''' elements are present, then each option will be displayed in a menu for the user to select one option. ''Note: Messages with options will not be shown at all in prestart events'' |
+ | ** '''message''': (translatable) the text displayed for the option. {{DevFeature1.15|1}} This is now a synonym for '''description='''. | ||
+ | ** '''image''', '''label''', '''description''', '''default''': See [[DescriptionWML#WML_Format|DescriptionWML]]. | ||
+ | ** '''value''': {{DevFeature1.13|?}} Gives the option a value to be stored in a variable. | ||
** '''[show_if]''': if present then this option will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) | ** '''[show_if]''': if present then this option will only be displayed if the conditional statement in this tag is passed (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) | ||
** '''[command]''': an element containing actions which are executed if the option is selected. | ** '''[command]''': an element containing actions which are executed if the option is selected. | ||
− | * '''[text_input]''': there can be only one [text_input] tag. this adds a text input field to the message. ''Note: Messages with text_input will not be shown at all in prestart events'' | + | * '''variable''': {{DevFeature1.13|?}} If present, either the index or the value of the chosen option will be stored in the specified variable. Option indexing starts from 1. If option has '''[show_if]''' condition evaluated as false, then it is hidden and excluded from the indexing. |
+ | * {{anchor|message-text_input|'''[text_input]'''}}: there can be only one [text_input] tag. this adds a text input field to the message. ''Note: Messages with text_input will not be shown at all in prestart events'' | ||
** '''variable''': the variable that the user's input will be written to | ** '''variable''': the variable that the user's input will be written to | ||
** '''label''': a text label to the left of the input field | ** '''label''': a text label to the left of the input field | ||
Line 44: | Line 54: | ||
=== Formatting === | === Formatting === | ||
− | '''[message]''' and other tags such as unit names (user_description), objectives, and floating text can make use of [ | + | '''[message]''' and other tags such as unit names (user_description), objectives, and floating text can make use of [https://docs.gtk.org/Pango/pango_markup.html#pango-markup Pango markup formatting codes]. |
− | + | Prefer to use single quotes (') instead of double quotes (") within the formatting string, as double quotes would need to be escaped in WML (""). Escaping markup can be done with [https://github.com/wesnoth/wesnoth/blob/9daa10a9f27c5a95520e871417bbd72aa52aa688/src/font/pango/escape.hpp#L38-L42 HTML entities]. | |
For example, if you wanted to write "You are victorious!" in large, italic, gold letters, you might write it this way: | For example, if you wanted to write "You are victorious!" in large, italic, gold letters, you might write it this way: | ||
Line 62: | Line 72: | ||
*'''font_variant''', '''variant''': One of 'normal' or 'smallcaps'. | *'''font_variant''', '''variant''': One of 'normal' or 'smallcaps'. | ||
*'''font_stretch''', '''stretch''': One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'. | *'''font_stretch''', '''stretch''': One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'. | ||
− | *'''foreground''', '''fgcolor''', '''color''': An RGB color specification such as '#00FF00' or a color name such as 'red'. | + | *'''foreground''', '''fgcolor''', '''color''': An RGB color specification such as '#00FF00' or a color name such as 'red'. The full list of color names may be found in Pango's [https://github.com/GNOME/pango/blob/main/tools/rgb.txt rgb.txt] file. |
*'''background, bgcolor''': An RGB color specification such as '#00FF00' or a color name such as 'red'. | *'''background, bgcolor''': An RGB color specification such as '#00FF00' or a color name such as 'red'. | ||
*'''underline''': One of 'none', 'single', 'double', 'low', 'error'. | *'''underline''': One of 'none', 'single', 'double', 'low', 'error'. | ||
Line 73: | Line 83: | ||
*'''gravity''': One of 'south', 'east', 'north', 'west', 'auto'. | *'''gravity''': One of 'south', 'east', 'north', 'west', 'auto'. | ||
*'''gravity_hint''': One of 'natural', 'strong', 'line'. | *'''gravity_hint''': One of 'natural', 'strong', 'line'. | ||
+ | |||
+ | The following pango attributes are also available directly as attributes of the '''[message]''' tag: | ||
+ | {{DevFeature1.13|4}} | ||
+ | |||
+ | *'''font''' | ||
+ | *'''font_family''' | ||
+ | *'''font_size''' | ||
+ | *'''font_style''' | ||
+ | *'''font_weight''' | ||
+ | *'''font_variant''' | ||
+ | *'''font_stretch''' | ||
+ | *'''color''' | ||
+ | *'''bgcolor''' | ||
+ | *'''underline''' | ||
+ | *'''underline_color''' | ||
+ | *'''rise''' | ||
+ | *'''strikethrough''' | ||
+ | *'''strikethrough_color''' | ||
+ | *'''fallback''' | ||
+ | *'''letter_spacing''' | ||
+ | *'''gravity''' | ||
+ | *'''gravity_hint''' | ||
== [objectives] == | == [objectives] == | ||
Line 90: | Line 122: | ||
* '''summary''': Displayed first in the objectives text, this should describe the basic objective for the overall scenario. Can be omitted. | * '''summary''': Displayed first in the objectives text, this should describe the basic objective for the overall scenario. Can be omitted. | ||
* '''note''': Displayed last in the objectives text, this is sometimes used for hints or additional information. Can be omitted. | * '''note''': Displayed last in the objectives text, this is sometimes used for hints or additional information. Can be omitted. | ||
− | * '''victory_string''': Default ' _ "Victory:"', this text precedes the victory objectives. | + | * '''victory_string''': Default ' _ "Victory:"', this text precedes the victory objectives. Can be set to "" too. |
− | * '''defeat_string''': Default ' _ "Defeat:"', this text precedes the defeat objectives. | + | * '''defeat_string''': Default ' _ "Defeat:"', this text precedes the defeat objectives. Can be set to "" too. |
* '''gold_carryover_string''': Default ' _ "Gold carryover:"', this text precedes the gold carryover information. | * '''gold_carryover_string''': Default ' _ "Gold carryover:"', this text precedes the gold carryover information. | ||
* '''notes_string''': Default ' _ "Notes:"', this text precedes the notes. | * '''notes_string''': Default ' _ "Notes:"', this text precedes the notes. | ||
* '''silent''': Default: not present. If set to "yes", the objectives are silently changed. Else, they will be shown to the user when appropriate. | * '''silent''': Default: not present. If set to "yes", the objectives are silently changed. Else, they will be shown to the user when appropriate. | ||
+ | * '''delayed_variable_substitution''': {{DevFeature1.13|8}} If set to yes, any variables or [insert_tag] are not substituted right away. Instead, they are substituted whenever the objectives are actually viewed. | ||
Tags of '''[objectives]''': | Tags of '''[objectives]''': | ||
− | * '''[objective]''': describes a win or loss condition. Most scenarios have multiple win or loss conditions, so use a separate [objective] subtag for each line; this helps with translations. | + | * {{anchor|objectives-objective|'''[objective]'''}}: describes a win or loss condition. Most scenarios have multiple win or loss conditions, so use a separate [objective] subtag for each line; this helps with translations. |
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet, with whatever is provided, for the objective defined by the [objective] block. | ** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet, with whatever is provided, for the objective defined by the [objective] block. | ||
** '''red''': Default '0' for winning objectives, '255' for losing objectives. Overrides the default red coloring of the entire objective, including the bullet. | ** '''red''': Default '0' for winning objectives, '255' for losing objectives. Overrides the default red coloring of the entire objective, including the bullet. | ||
Line 103: | Line 136: | ||
** '''blue''': Default '0'. Overrides the default blue coloring of the entire objective, including the bullet. | ** '''blue''': Default '0'. Overrides the default blue coloring of the entire objective, including the bullet. | ||
** '''description''': text for the specific win or loss condition. | ** '''description''': text for the specific win or loss condition. | ||
− | ** '''condition''': The color and placement of the text. Values are 'win'(colored green, placed after ''victory_string'') and 'lose'(colored red, placed after ''defeat_string'') | + | ** '''caption''': a text which will be displayed above the ''description''. This can be used to display a subcategory of objectives below ''victory_string'' or ''defeat_string''. |
+ | ** '''condition''': The color and placement of the text. Values are 'win'(colored green, placed after ''victory_string'') and 'lose'(colored red, placed after ''defeat_string''). | ||
** '''show_turn_counter''': If set to yes, displays the number of turns remaining in the scenario. Default is no. | ** '''show_turn_counter''': If set to yes, displays the number of turns remaining in the scenario. Default is no. | ||
− | ** '''[show_if]''': A condition that disables the objective if it doesn't hold. Conditional objectives are refreshed at '''[show_objectives]''' time only. | + | ** '''[show_if]''': A condition that disables the objective if it doesn't hold. Conditional objectives are refreshed at '''[show_objectives]''' time only, or when manually opening the scenario objectives. |
− | * '''[gold_carryover]''': describes how the gold carryover works in this scenario. This is intended to be a more convenient way of displaying carryover information than using the note= key in [objectives]. | + | * {{anchor|objectives-gold_carryover|'''[gold_carryover]'''}}: describes how the gold carryover works in this scenario. This is intended to be a more convenient way of displaying carryover information than using the note= key in [objectives]. |
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided. | ** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided. | ||
** '''red''': Default '255'. Overrides the default red coloring of the entire objective, including the bullet. | ** '''red''': Default '255'. Overrides the default red coloring of the entire objective, including the bullet. | ||
Line 113: | Line 147: | ||
** '''bonus''' (boolean): whether an early finish bonus is granted. If omitted, early finish bonus is not mentioned. | ** '''bonus''' (boolean): whether an early finish bonus is granted. If omitted, early finish bonus is not mentioned. | ||
** '''carryover_percentage''': the amount of carryover gold. If omitted, the amount is not mentioned. | ** '''carryover_percentage''': the amount of carryover gold. If omitted, the amount is not mentioned. | ||
− | * '''[note]''': describes a note, usually used for hints or additional information. This is an easier way of adding several notes than concatenating them together into a single string to use with the ''note='' key. | + | ** '''[show_if]''': {{DevFeature1.13|11}} Gold carryover will not be shown if the specified condition isn't met. Conditional gold carryover is refreshed at '''[show_objectives]''' time only. |
+ | * {{anchor|objectives-note|'''[note]'''}}: describes a note, usually used for hints or additional information. This is an easier way of adding several notes than concatenating them together into a single string to use with the ''note='' key. | ||
** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided for the note defined by the [note] block. | ** '''bullet''': Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided for the note defined by the [note] block. | ||
** '''red''': Default '255'. Overrides the default red coloring of the entire note, including the bullet. | ** '''red''': Default '255'. Overrides the default red coloring of the entire note, including the bullet. | ||
Line 126: | Line 161: | ||
'''Note:''' Due to limitations in portable devices where there are no scroll bars for context menus, there is a hard-coded limit of 7 custom WML menu items. If you really need to have more than 7 menu items, try combining some of them in a submenu. {{DevFeature1.13|0}} This limitation is being removed in a [http://forums.wesnoth.org/viewtopic.php?p=572554#p572554 future version] of Wesnoth. | '''Note:''' Due to limitations in portable devices where there are no scroll bars for context menus, there is a hard-coded limit of 7 custom WML menu items. If you really need to have more than 7 menu items, try combining some of them in a submenu. {{DevFeature1.13|0}} This limitation is being removed in a [http://forums.wesnoth.org/viewtopic.php?p=572554#p572554 future version] of Wesnoth. | ||
− | * '''id''': the unique id for this menu item. If a menu item with this id already exists, it allows you to set specific changes to that item. | + | * '''id''': the unique id for this menu item. If a menu item with this id already exists, it allows you to set specific changes to that item. All menus will be sorted lexicographically by the id string. The ordering is underscores, digits, and finally letters. |
* '''description''': the in-game text that will appear for this item in the menu. | * '''description''': the in-game text that will appear for this item in the menu. | ||
− | * '''image''': the image to display next to this item. | + | * '''image''': the image to display next to this item, defaults to "buttons/WML-custom.png" |
− | * '''needs_select''': if ''yes'' (default ''no''), then the latest select event (see [[EventWML]]) that triggered before this menu item was chosen will be transmitted over the network before this menu item action will be. This only has any effect in networked multiplayer, and is intended to allow more elaborate menu item behaviour there without causing out of sync errors. If you don't know what this means, just leave it | + | * '''needs_select''': if ''yes'' (default ''no''), then the latest select event (see [[EventWML]]) that triggered before this menu item was chosen will be transmitted over the network before this menu item action will be. This only has any effect in networked multiplayer, and is intended to allow more elaborate menu item behaviour there without causing out of sync errors. If you don't know what this means, just leave it. {{DevFeature1.13|6}} ''needs_select=yes'' is deprecated, consider using manual variable syncing with [sync_variable]. |
+ | * '''synced''' {{DevFeature1.13|1}}: if ''no'' (default ''yes'') the command handler will only be run on the client that invoked the menu item; this means that changing the gamestate in a command handler of a menu item with ''synced=no'' will cause OOS | ||
* '''use_hotkey''': if ''no'' (default ''yes''), then the user cannot assign hotkeys to this menu item. If ''only'', the menu item is only accessible via hotkeys, not via right-click context; you can use this in combination with [default_hotkey] if you want custom hotkeys in your campaign/mp. | * '''use_hotkey''': if ''no'' (default ''yes''), then the user cannot assign hotkeys to this menu item. If ''only'', the menu item is only accessible via hotkeys, not via right-click context; you can use this in combination with [default_hotkey] if you want custom hotkeys in your campaign/mp. | ||
* '''[show_if]''': If present, the menu item will only be available if the conditional statement (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) within evaluates to true. When this is evaluated, the WML variables ''$x1'' and ''$y1'' will point to the location on which the context menu was invoked, so it's possible to for example only enable the option on empty hexes or on a particular unit. | * '''[show_if]''': If present, the menu item will only be available if the conditional statement (see [[ConditionalActionsWML#Condition_Tags|ConditionalActionsWML]]) within evaluates to true. When this is evaluated, the WML variables ''$x1'' and ''$y1'' will point to the location on which the context menu was invoked, so it's possible to for example only enable the option on empty hexes or on a particular unit. | ||
− | * '''[filter_location]''': contains a | + | * '''[filter_location]''': contains a [[StandardLocationFilter]] similar to the one found inside Single Unit Filters. The menu item will only be available on matching locations. |
* '''[default_hotkey]''': contains a hotkey WML to specify what hotkey to assign to this, '''if the user has no hotkey assigned to this yet'''. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys: | * '''[default_hotkey]''': contains a hotkey WML to specify what hotkey to assign to this, '''if the user has no hotkey assigned to this yet'''. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys: | ||
** '''key''': a string that contains the key to assign to this. | ** '''key''': a string that contains the key to assign to this. | ||
** '''alt''', '''shift''', '''cmd'''(apple only), '''ctrl''': boolean values. | ** '''alt''', '''shift''', '''cmd'''(apple only), '''ctrl''': boolean values. | ||
+ | ** '''repeat_on_hold''' {{DevFeature1.13|12}}: if ''yes'' (default ''no''), holding the hotkey will repeat the action continuously, unless it blocks input with something like '''[message]'''. Due to a bug, versions older than 1.13.12 always repeat the action, with no way to disable it. | ||
* '''[command]''': contains the WML actions to be executed when the menu item is selected. Again, the WML variables ''$x1'' and ''$y1'' will point to the location on which the context menu was invoked on. | * '''[command]''': contains the WML actions to be executed when the menu item is selected. Again, the WML variables ''$x1'' and ''$y1'' will point to the location on which the context menu was invoked on. | ||
** '''delayed_variable_substitution ''' (boolean yes|no, default: yes): If no, forces a variable substitution run onto the wml included in this [command] block. Use this, if you want variables which are to substitute to get the values they have at execution time of the event where this set_menu_item appears. Other than that, they get the values they have at invocation time of the menu item. | ** '''delayed_variable_substitution ''' (boolean yes|no, default: yes): If no, forces a variable substitution run onto the wml included in this [command] block. Use this, if you want variables which are to substitute to get the values they have at execution time of the event where this set_menu_item appears. Other than that, they get the values they have at invocation time of the menu item. | ||
Line 148: | Line 185: | ||
The following tags are also action tags: | The following tags are also action tags: | ||
+ | |||
+ | === [change_theme] === | ||
+ | |||
+ | {{DevFeature1.13|8}} | ||
+ | |||
+ | Change the current interface theme. | ||
+ | |||
+ | * '''theme''': The ID of the new theme. Use <code>theme=</code> (empty key) to switch back to the theme that the player has selected in Preferences. On <b>1.14.2</b> and later it is also possible to omit the key entirely to achieve the same effect (on previous versions this will crash the Lua engine). | ||
=== [item] === | === [item] === | ||
Makes a graphical item appear on a certain hex. Note this only places the graphics for an item. It does not make the item do anything. Use a moveto event to make moving onto the item do something. <tt>''('''Hint:''' There are a number of predefined items that are used in various campaigns that you can make use of. You can find [http://www.wesnoth.org/macro-reference.xhtml#file:items.cfg a list of them] if you look into the items.cfg file in the wesnoth install directory (under /data/core/macros).)''</tt> | Makes a graphical item appear on a certain hex. Note this only places the graphics for an item. It does not make the item do anything. Use a moveto event to make moving onto the item do something. <tt>''('''Hint:''' There are a number of predefined items that are used in various campaigns that you can make use of. You can find [http://www.wesnoth.org/macro-reference.xhtml#file:items.cfg a list of them] if you look into the items.cfg file in the wesnoth install directory (under /data/core/macros).)''</tt> | ||
* '''x''', '''y''': the location to place the item. (only for [event][item]: full [[StandardLocationFilter|SLF]] support) | * '''x''', '''y''': the location to place the item. (only for [event][item]: full [[StandardLocationFilter|SLF]] support) | ||
− | * '''image''': the image (in ''images/'' as .png) to place on the hex. This image is aligned with the top-left of the hex (which is 72 pixels wide and 72 pixels tall). It is drawn underneath units. ''('''Hint:''' If using an image smaller than 72x72, then it might be useful to [[ | + | * '''image''': the image (in ''images/'' as .png) to place on the hex. This image is aligned with the top-left of the hex (which is 72 pixels wide and 72 pixels tall). It is drawn underneath units. ''('''Hint:''' If using an image smaller than 72x72, then it might be useful to [[ImagePathFunctions#Blit_Function|BLIT]] the image onto <tt>misc/blank-hex.png</tt> (a blank 72x72 image).)'' |
− | * '''halo''': an image to place centered on the hex. It is drawn on top of units. Use this instead of ''image'' if the image is bigger than the hex or if you want to animate an image. | + | * '''halo''': an image to place centered on the hex. It is drawn on top of units. Use this instead of ''image'' if the image is bigger than the hex or if you want to animate an image (https://github.com/wesnoth/wesnoth/issues/1219). |
+ | * '''name''' an id that can be used to remove the item. | ||
''Example (where the integer after the colon is the duration of each frame or square bracket expansion as per AnimationWML is used): halo=scenery/fire1.png:100,scenery/fire2.png:100,scenery/fire3.png:100,scenery/fire4.png:100,scenery/fire5.png:100,scenery/fire6.png:100,scenery/fire7.png:100,scenery/fire8.png:100'' | ''Example (where the integer after the colon is the duration of each frame or square bracket expansion as per AnimationWML is used): halo=scenery/fire1.png:100,scenery/fire2.png:100,scenery/fire3.png:100,scenery/fire4.png:100,scenery/fire5.png:100,scenery/fire6.png:100,scenery/fire7.png:100,scenery/fire8.png:100'' | ||
or equivalently (requires Wesnoth 1.11.2+): | or equivalently (requires Wesnoth 1.11.2+): | ||
''halo=scenery/fire[1~8].png:100'' | ''halo=scenery/fire[1~8].png:100'' | ||
− | * '''team_name''': name of the team for which the item is to be displayed (hidden for others). For multiple teams just put all the names in one string, for example separated by commas. | + | * '''team_name''': name of the team for which the item is to be displayed (hidden for others). For multiple teams just put all the names in one string, for example separated by commas. {{DevFeature1.15|0}} In 1.14 the '''[side]team_name''' attribute was expected to be a substring of this '''team_name'''. In 1.15 both are expected to be comma-separated lists of names and the item is visible if the lists intersect. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]]) |
* '''visible_in_fog''': whether the item should be visible through fog or not. Default yes. | * '''visible_in_fog''': whether the item should be visible through fog or not. Default yes. | ||
* '''redraw''': (boolean yes|no, default: yes): If no, disables implicit calls to [[InterfaceActionsWML#.5Bredraw.5D|[redraw]]] when placing the items. | * '''redraw''': (boolean yes|no, default: yes): If no, disables implicit calls to [[InterfaceActionsWML#.5Bredraw.5D|[redraw]]] when placing the items. | ||
+ | * '''[filter_team]''': {{DevFeature1.15|0}} A [[StandardSideFilter]]. Set '''team_name''' to the union of all '''[side]team_name''' attributes of all sides that match the SSF. ([[https://github.com/wesnoth/wesnoth/pull/3533|#3533]]) | ||
+ | * {{DevFeature1.15|0}} If both '''team_name''' and '''[filter_team]''' are set, '''team_name''' is ignored. | ||
=== [remove_item] === | === [remove_item] === | ||
Removes any graphical items on a given hex. | Removes any graphical items on a given hex. | ||
− | * [[StandardLocationFilter]]: the hexes to remove items | + | * [[StandardLocationFilter]]: the hexes to remove items from |
− | * '''image''' if specified, only removes the given image | + | * '''image''': if specified, only removes the given item if one of its 'image', 'halo' or 'name' attributes is exactly this value. (for 'halo' and 'image' this in particular means that the image name must include any [[ImagePathFunctions|image path functions]] appended to the original image name.) |
=== [print] === | === [print] === | ||
− | Displays a message across the screen. The message will disappear after a certain time. | + | Displays a message across the screen. The message will disappear after a certain time, or when another [print] tag is encountered. |
− | * '''text''': (translatable) the text to display. | + | * '''text''': (translatable) the text to display. Can be an empty string to remove a previous message without showing a new one. |
* '''size''': (default=12) the pointsize of the font to use | * '''size''': (default=12) the pointsize of the font to use | ||
− | * '''duration''': | + | * '''duration''': the length of time to display the text for. |
− | * '''red''', '''green''', '''blue''': | + | ** (Before 1.15.4) This is measured in the number of 'frames', and the default is 50. A frame in Wesnoth is usually displayed for around 30ms. |
+ | ** {{DevFeature1.15|4}} This is measured in milliseconds. Don't use the default value, because it's a mere 50ms. | ||
+ | ** {{DevFeature1.15|14}} The default is 5000 milliseconds. | ||
+ | ** {{DevFeature1.15|14}} The string '''unlimited''' displays the text until it's removed by another [print] tag. | ||
+ | * '''color''': (default '''0,0,0''') three comma-separated values giving the red, green and blue values (0-255). | ||
+ | * '''red''', '''green''', '''blue''': deprecated, use color=0,0,0 instead. | ||
+ | |||
=== [move_unit_fake] === | === [move_unit_fake] === | ||
Moves an image of a unit along a certain path on the map. The path does not need to be a continuous list of adjacent hexes, so for example only the start and end points can be given, in which case the straightest line between those points will be calculated and used. | Moves an image of a unit along a certain path on the map. The path does not need to be a continuous list of adjacent hexes, so for example only the start and end points can be given, in which case the straightest line between those points will be calculated and used. | ||
Line 180: | Line 234: | ||
* '''gender''': the gender of the fake unit. Example: gender=female | * '''gender''': the gender of the fake unit. Example: gender=female | ||
* '''variation''': the variation of the fake unit. Example: variation=undead | * '''variation''': the variation of the fake unit. Example: variation=undead | ||
− | * '''image_mods''': [[ | + | * '''image_mods''': [[ImagePathFunctions|image path functions]] sequence to be applied on the fake unit. |
* '''force_scroll''': Whether to scroll the map or not even when [[#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to ''yes'' starting with version '''1.11.6'''; the attribute did not exist in previous versions and this action behaved as if ''no'' was passed instead. | * '''force_scroll''': Whether to scroll the map or not even when [[#.5Block_view.5D|[lock_view]]] is in effect or ''Follow Unit Actions'' is disabled in ''Advanced Preferences''. Defaults to ''yes'' starting with version '''1.11.6'''; the attribute did not exist in previous versions and this action behaved as if ''no'' was passed instead. | ||
=== [move_units_fake] === | === [move_units_fake] === | ||
moves multiple images of units along paths on the map. These units are moved in lockstep. | moves multiple images of units along paths on the map. These units are moved in lockstep. | ||
+ | * '''force_scroll''': {{DevFeature1.15|0}} Has the same meaning as in [move_unit_fake] but a different default. | ||
* '''[fake_unit]''': A fake unit to move | * '''[fake_unit]''': A fake unit to move | ||
** '''type''': the type of unit whose image to use | ** '''type''': the type of unit whose image to use | ||
Line 191: | Line 246: | ||
** '''side''': the side of the fake unit, used for team-coloring the fake unit | ** '''side''': the side of the fake unit, used for team-coloring the fake unit | ||
** '''skip_steps''': the number of steps to skip before this unit starts moving | ** '''skip_steps''': the number of steps to skip before this unit starts moving | ||
+ | |||
=== [hide_unit] === | === [hide_unit] === | ||
Temporarily prevents the engine from displaying the given unit. The unit does not become invisible, as it would be with the '''[hides]''' ability; it is still the same plain unit, but without an image. Useful in conjunction with '''[move_unit_fake]''': to move a leader unit into position on-screen. Until 1.8 each '''[hide_unit]''' tag only hides one unit. | Temporarily prevents the engine from displaying the given unit. The unit does not become invisible, as it would be with the '''[hides]''' ability; it is still the same plain unit, but without an image. Useful in conjunction with '''[move_unit_fake]''': to move a leader unit into position on-screen. Until 1.8 each '''[hide_unit]''' tag only hides one unit. | ||
Line 202: | Line 258: | ||
Locks gamemap view scrolling for human players, so they cannot scroll the gamemap view until it is unlocked. WML or Lua actions such as '''[scroll_to]''' will continue to work normally, as they ignore this restriction; the locked/unlocked state is preserved when saving the current game. | Locks gamemap view scrolling for human players, so they cannot scroll the gamemap view until it is unlocked. WML or Lua actions such as '''[scroll_to]''' will continue to work normally, as they ignore this restriction; the locked/unlocked state is preserved when saving the current game. | ||
− | This feature is generally intended to be used in cutscenes to prevent the player scrolling away from scripted actions. | + | This feature is generally intended to be used in cutscenes to prevent the player scrolling away from scripted actions. |
+ | |||
+ | {{DevFeature1.13|8}} This now also blocks the player from zooming the gamemap view. WML or Lua zoom will continue to work normally. | ||
=== [unlock_view] === | === [unlock_view] === | ||
Line 215: | Line 273: | ||
=== [scroll_to] === | === [scroll_to] === | ||
Scroll to a given hex | Scroll to a given hex | ||
− | |||
* [[StandardLocationFilter]], do not use a [filter_location] sub-tag. If more than one location matches the filter, only the first matching location will be used. | * [[StandardLocationFilter]], do not use a [filter_location] sub-tag. If more than one location matches the filter, only the first matching location will be used. | ||
− | * '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values '' | + | * '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default. |
− | * '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to '' | + | * '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no''). |
+ | * '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex being scrolled to (defaults to ''no''). | ||
* '''side''': the side or sides for which this should happen. By default, the [scroll_to] happens for everyone. | * '''side''': the side or sides for which this should happen. By default, the [scroll_to] happens for everyone. | ||
* '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to] happens for everyone. | * '''[filter_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to] happens for everyone. | ||
Line 224: | Line 282: | ||
=== [scroll_to_unit] === | === [scroll_to_unit] === | ||
Scroll to a given unit | Scroll to a given unit | ||
− | * [[StandardUnitFilter]] | + | * [[StandardUnitFilter]]; do not use a [filter] subtag. |
− | * '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values '' | + | * '''check_fogged''': whether to scroll even to locations covered in fog or shroud. Possible values ''yes'' (don't scroll to fog) and ''no'' (scroll even to fog), with ''no'' as the default. |
− | * '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to '' | + | * '''immediate''': whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to ''no''). |
+ | * '''highlight''': {{DevFeature1.13|5}} Whether to highlight the hex the unit is on (defaults to ''no''). | ||
* '''for_side''': the side or sides for which this should happen. By default, the [scroll_to_unit] happens for everyone. | * '''for_side''': the side or sides for which this should happen. By default, the [scroll_to_unit] happens for everyone. | ||
* '''[for_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to_unit] happens for everyone. | * '''[for_side]''': a [[StandardSideFilter]] to select the sides for which this should happen. By default, the [scroll_to_unit] happens for everyone. | ||
Line 235: | Line 294: | ||
* '''fire_event''': whether a ''select'' event should be triggered or not (def. ''no''). (Note that select events aren't multiplayer save.) | * '''fire_event''': whether a ''select'' event should be triggered or not (def. ''no''). (Note that select events aren't multiplayer save.) | ||
* '''highlight''': whether the unit's current hex should be highlighted (def. ''yes''). | * '''highlight''': whether the unit's current hex should be highlighted (def. ''yes''). | ||
+ | |||
+ | '''Note:''' fire_event does not appear to work in 1.14 or 1.16. | ||
=== [sound]=== | === [sound]=== | ||
Plays a sound | Plays a sound | ||
− | * '''name''': the filename of the sound to play (in ''sounds/'' as .wav or .ogg) | + | * '''name''': the filename of the sound to play (in ''sounds/'' as .wav or .ogg). This can be a comma-separated list, from which one sound will be chosen randomly. |
* '''repeat''': repeats the sound for a specified additional number of times (default=0) | * '''repeat''': repeats the sound for a specified additional number of times (default=0) | ||
+ | |||
=== [sound_source] === | === [sound_source] === | ||
Creates a sound source. "Sound sources" is a general name for a mechanism which makes possible for map elements to emit sounds according to some rules, where "map elements" can be specific locations or terrain types. For now, only sound sources tied to locations are supported. | Creates a sound source. "Sound sources" is a general name for a mechanism which makes possible for map elements to emit sounds according to some rules, where "map elements" can be specific locations or terrain types. For now, only sound sources tied to locations are supported. | ||
Line 246: | Line 308: | ||
* '''delay''': a numerical value (in milliseconds) of the minimal delay between two playbacks of the source's sound if the source remains visible on the screen; if one scrolls out and back in, the source will be considered as ready to play | * '''delay''': a numerical value (in milliseconds) of the minimal delay between two playbacks of the source's sound if the source remains visible on the screen; if one scrolls out and back in, the source will be considered as ready to play | ||
* '''chance''': a percentage (a value from 0 to 100) describing the chance of the source being activated every second after the delay has passed or when the source's location appears on the screen (note that it cannot play more than one file at the same time) | * '''chance''': a percentage (a value from 0 to 100) describing the chance of the source being activated every second after the delay has passed or when the source's location appears on the screen (note that it cannot play more than one file at the same time) | ||
− | * '''check_fogged''': possible values | + | * '''check_fogged''': possible values ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are fogged |
− | * '''check_shrouded''': possible values | + | * '''check_shrouded''': possible values ''yes'' and ''no'' - ''yes'' means the source will not play if its locations are shrouded |
* '''x,y''': similar to x,y as found in a [[StandardLocationFilter]], these are the locations associated with the sound source | * '''x,y''': similar to x,y as found in a [[StandardLocationFilter]], these are the locations associated with the sound source | ||
* '''fade_range''' (default = 3): distance in hexes that determines a "circular" area around the one specified by '''full_range''' where sound volume fades out linearly | * '''fade_range''' (default = 3): distance in hexes that determines a "circular" area around the one specified by '''full_range''' where sound volume fades out linearly | ||
* '''full_range''' (default = 14): distance in hexes that determines a "circular" area where source plays with full volume, relative to screen center | * '''full_range''' (default = 14): distance in hexes that determines a "circular" area where source plays with full volume, relative to screen center | ||
* '''loop''': number of times a sound sample should be looped if it stays visible. -1 means infinite (~65000) | * '''loop''': number of times a sound sample should be looped if it stays visible. -1 means infinite (~65000) | ||
+ | |||
+ | === [story] === | ||
+ | {{DevFeature1.13|8}} | ||
+ | |||
+ | Shows the story screen. | ||
+ | * '''title''': Default title used if a part does not specify one — unlike the intro storyscreen, the scenario name is not used as a default title. | ||
+ | * '''[part]''', '''[if]''', '''[switch]''', '''[wml_message]''', '''[deprecated_message]''' : See [[IntroWML]]. | ||
=== [remove_sound_source] === | === [remove_sound_source] === | ||
Line 257: | Line 326: | ||
* '''id''': the identification key of the sound source to remove | * '''id''': the identification key of the sound source to remove | ||
− | === [music]=== | + | === [music] === |
Switches to playing different music | Switches to playing different music | ||
* '''name''': the filename of the music to play (in ''music/'' as .ogg) | * '''name''': the filename of the music to play (in ''music/'' as .ogg) | ||
* see [[MusicListWML]] for the correct syntax | * see [[MusicListWML]] for the correct syntax | ||
− | ===[volume]=== | + | |
+ | === [volume] === | ||
Changes the game volume to a percent of the preferences volume for the game being played. Values can go from 0 to 100: | Changes the game volume to a percent of the preferences volume for the game being played. Values can go from 0 to 100: | ||
* '''music''': Changes the music volume. | * '''music''': Changes the music volume. | ||
* '''sound''': Changes the sound volume. | * '''sound''': Changes the sound volume. | ||
− | === [color_adjust]=== | + | |
− | + | === [color_adjust] === | |
+ | Adjust the color tint of terrain, by adjusting time-of-day coloring. | ||
* '''red''', '''green''', '''blue''': values from -255 to 255, the amount to tint by for each color | * '''red''', '''green''', '''blue''': values from -255 to 255, the amount to tint by for each color | ||
+ | |||
+ | === [screen_fade] === | ||
+ | {{DevFeature1.17|6}} | ||
+ | |||
+ | Overlay the game display with the given color, fading over the specified duration. This can be used for screen fade effects. | ||
+ | * '''red''', '''green''', '''blue''': values from 0 to 255, the final overlay color (defaults to 0,0,0) | ||
+ | * '''alpha''': value from 0 to 255, the strength of the effect. 0 means no effect and can be used to fade in. 255 means fully opaque and can be used to fully fade out to the given color. Intermediate values will end up with a partial overlay tint on the game screen. | ||
+ | * '''duration''': the length of time it will take to complete the fade, in milliseconds. If 0 the effect is immediate. | ||
+ | |||
=== [delay] === | === [delay] === | ||
Pauses the game. | Pauses the game. | ||
* '''time''': the time to pause in milliseconds | * '''time''': the time to pause in milliseconds | ||
− | * '''accelerate ''' (boolean yes|no, default no): {{DevFeature1.13|0}} whether the delay is affected by acceleration. | + | * '''accelerate ''' (boolean yes|no, default no): {{DevFeature1.13|0}} whether the delay is affected by acceleration. When [delay] is used to make an animation, this should be set to yes so that your animation matches the ones generated by the game. |
=== [redraw] === | === [redraw] === | ||
Line 283: | Line 363: | ||
* [[StandardUnitFilter]]: All matching units will get the overlay (do not use [filter]) | * [[StandardUnitFilter]]: All matching units will get the overlay (do not use [filter]) | ||
* '''image''': the image to place on the unit | * '''image''': the image to place on the unit | ||
+ | * '''object_id''': object id to use, defaults to the '''image''' key with an "overlay_" prefix; this allows using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']] | ||
+ | * '''duration''': object duration | ||
=== [remove_unit_overlay] === | === [remove_unit_overlay] === | ||
− | + | Removes a particular overlayed image from a unit | |
* [[StandardUnitFilter]]: The overlay will get removed from all matching units (do not use [filter]) | * [[StandardUnitFilter]]: The overlay will get removed from all matching units (do not use [filter]) | ||
* '''image''': the image to remove from the unit | * '''image''': the image to remove from the unit | ||
+ | * '''object_id''': object id to use | ||
+ | Using [[DirectActionsWML#.5Bremove_object.5D|'''[remove_object]''']] is also possible, see https://github.com/wesnoth/wesnoth/commit/26c2f941f2bcdd89528481e114c0375ad2a46271 | ||
=== [animate_unit] === | === [animate_unit] === | ||
Line 303: | Line 387: | ||
* '''with_bars''': yes/no: whether to display the status bars during the animation (e.g. the hitpoint bar) | * '''with_bars''': yes/no: whether to display the status bars during the animation (e.g. the hitpoint bar) | ||
* '''[animate]''': a sub block with the same syntax as '''[animate_unit]''' except that the '''[filter]''' block is mandatory to find the unit. This block will find and animate another unit simultaneously. | * '''[animate]''': a sub block with the same syntax as '''[animate_unit]''' except that the '''[filter]''' block is mandatory to find the unit. This block will find and animate another unit simultaneously. | ||
− | * '''[facing]''': a [[StandardLocationFilter]] specifying what | + | * '''[facing]''': a [[StandardLocationFilter]] specifying what hex the unit should be facing when animated |
=== [label] === | === [label] === | ||
Places a label on the map. | Places a label on the map. | ||
* '''x''', '''y''': the location of the label. {{DevFeature1.13|1}} (only for [event][label]: full [[StandardLocationFilter|SLF]] support) | * '''x''', '''y''': the location of the label. {{DevFeature1.13|1}} (only for [event][label]: full [[StandardLocationFilter|SLF]] support) | ||
− | * '''text''': what the label should say | + | * '''text''': what the label should say. If you put an empty string <code>""</code> as an argument, the label will be completely removed. Use this method if you want to remove a specific label from any location. |
* '''team_name''': if specified, the label will only be visible to the given team. | * '''team_name''': if specified, the label will only be visible to the given team. | ||
* '''color''': color of the label. The format is r,g,b; r, g and b are numbers between 0 and 255. | * '''color''': color of the label. The format is r,g,b; r, g and b are numbers between 0 and 255. | ||
Line 314: | Line 398: | ||
* '''visible_in_shroud''': whether the label should be visible through shroud or not. Default no. | * '''visible_in_shroud''': whether the label should be visible through shroud or not. Default no. | ||
* '''immutable''': whether this label is protected from being removed or changed by players. Default yes. | * '''immutable''': whether this label is protected from being removed or changed by players. Default yes. | ||
+ | * '''category''': the Show/Hide Labels dialog allows showing/hiding all labels of a given category by toggling a checkbox. | ||
+ | * '''tooltip''': A tooltip visible when mouseovering the hex the label is on | ||
+ | * '''side''': the number of the side that placed the label. Can be 0 for labels placed by WML. | ||
=== [floating_text]=== | === [floating_text]=== | ||
Floats text (similar to the damage and healing numbers) on the given locations. | Floats text (similar to the damage and healing numbers) on the given locations. | ||
− | * [[StandardLocationFilter]]: the text will be floated on all matching locations simultaneously. | + | * [[StandardLocationFilter]]: the text will be floated on all matching locations simultaneously (do not use [filter] unless you intend to match one or more units). |
* '''text''': the text to display. | * '''text''': the text to display. | ||
Line 333: | Line 420: | ||
Shows a deprecated message in the message area, this feature is only intended to be used to warn about deprecated macros in mainline. The message is not translatable. | Shows a deprecated message in the message area, this feature is only intended to be used to warn about deprecated macros in mainline. The message is not translatable. | ||
* '''message''': the message to show. | * '''message''': the message to show. | ||
+ | * '''level''': {{DevFeature1.13|10}} The deprecation level, a number from 1 to 3. | ||
+ | * '''what''': {{DevFeature1.13|10}} The name of the thing being deprecated. Use this instead of '''message''' if possible; a stock message will be generated from it. Use '''message''' only if more information is required; it will be appended to the stock message. This should not be translatable | ||
+ | * '''version''': {{DevFeature1.13|10}} For deprecation levels 2 and 3, this indicates the version in which the feature could be removed. It does ''not'' indicate the version in which it became deprecated. | ||
+ | |||
+ | The meanings of the deprecation levels are as follows: | ||
+ | |||
+ | # Deprecated, but will only be removed if absolutely necessary. The '''version''' key is ignored. | ||
+ | # It will be removed no earlier than a specified version. | ||
+ | # It will be removed in the next stable version | ||
+ | # It has already been removed, leaving just a stub to inform users of how to update their code. | ||
+ | |||
+ | Note that as of 1.13.11, deprecation messages show only in the log, not in the chat message area. The '''message''' can be translatable, but does not need to be. | ||
+ | |||
=== [wml_message] === | === [wml_message] === | ||
Outputs a message to Wesnoth's console output. Intended for campaign designers to output silent text to the console, without annoying the player; then, that text might contain information useful for later bug-reporting. The log domain for it is '''wml''', and the '''debug/dbg''' log level is available for use with the '''logger''' attribute. Depending on the current log level ('''error''' by default), which may be changed with the in-game :log command, or the --log-<level>=wml command line switch, the messages are echoed to the in-game chat. | Outputs a message to Wesnoth's console output. Intended for campaign designers to output silent text to the console, without annoying the player; then, that text might contain information useful for later bug-reporting. The log domain for it is '''wml''', and the '''debug/dbg''' log level is available for use with the '''logger''' attribute. Depending on the current log level ('''error''' by default), which may be changed with the in-game :log command, or the --log-<level>=wml command line switch, the messages are echoed to the in-game chat. | ||
Line 340: | Line 440: | ||
Note: As of 1.9.4/1.9.5 (r48805) the following "loggers" should work: If in [wml_message]: err/error, warn/wrn/warning, debug/dbg; using the :log command: Only the long forms error, warning, info and debug (this part gathered by trying rather than source inspecting). The long forms are most likely also the only ones working when starting wesnoth with --log-<level>=wml. | Note: As of 1.9.4/1.9.5 (r48805) the following "loggers" should work: If in [wml_message]: err/error, warn/wrn/warning, debug/dbg; using the :log command: Only the long forms error, warning, info and debug (this part gathered by trying rather than source inspecting). The long forms are most likely also the only ones working when starting wesnoth with --log-<level>=wml. | ||
For log level warning or error (as during normal play), only wml_messages with logger error or warning display (for both). With logger info or debug, additionally wml_messages with logger info or debug display (for both). | For log level warning or error (as during normal play), only wml_messages with logger error or warning display (for both). With logger info or debug, additionally wml_messages with logger info or debug display (for both). | ||
+ | |||
+ | === [test_condition] === | ||
+ | |||
+ | {{DevFeature1.13|2}} | ||
+ | |||
+ | Evaluates the contained conditional tags. If they evaluate to the expected value, it prints out a message to the console explaining which part of the condition caused this result in a way similar to [wml_message]. This can be used if your conditional test is failing and you're not sure why. | ||
+ | |||
+ | * '''result''': Whether you expect the conditions to fail or succeed. If no (the default), a message will be printed if the conditional tags fail. If yes, a message will instead be printed if the conditional tags pass. | ||
+ | * '''logger''': Same as for [wml_message]. Defaults to "warning". | ||
=== [open_help] === | === [open_help] === | ||
Opens the in-game help. | Opens the in-game help. | ||
* '''topic''': the id of the topic to open | * '''topic''': the id of the topic to open | ||
+ | |||
+ | Examples of ids: | ||
+ | * unit_Mage | ||
+ | * unit_Dark Adept | ||
+ | * weaponspecial_charge | ||
+ | * terrain_human_castle | ||
+ | |||
+ | The engine will print the topic ids if run from the command line with the ''--log-debug=help'' option. | ||
+ | |||
=== [show_objectives] === | === [show_objectives] === | ||
refreshes the objectives defined by [objectives] and its [show_if] tags, and displays them. (It is also called whenever the user explicitly asks for the objectives; this matters only if the tag was overridden by a [[LuaWML#register_wml_action|Lua]] script.) | refreshes the objectives defined by [objectives] and its [show_if] tags, and displays them. (It is also called whenever the user explicitly asks for the objectives; this matters only if the tag was overridden by a [[LuaWML#register_wml_action|Lua]] script.) | ||
Line 350: | Line 468: | ||
=== [chat] === | === [chat] === | ||
− | Displays a message in the chat area, not visible for observers. Alternative visible for | + | Displays a message in the chat area, not visible for observers. Alternative unconditionally visible for everyone: [[LuaWML:Display#wesnoth.message]]. {{DevFeature1.13|9}} can be visible for observers. |
* '''speaker''': (default="WML") A string for the name of the sender of the message. | * '''speaker''': (default="WML") A string for the name of the sender of the message. | ||
* '''message''': The message that should be displayed. | * '''message''': The message that should be displayed. | ||
+ | * '''observable''' (boolean yes|no, default yes): {{DevFeature1.13|9}} Whether the message is displayed for observers. | ||
* '''[[StandardSideFilter]]''' tags and keys as argument; if the same client controls multiple sides that match, then the message will only be displayed once. | * '''[[StandardSideFilter]]''' tags and keys as argument; if the same client controls multiple sides that match, then the message will only be displayed once. | ||
+ | |||
+ | === [zoom] === | ||
+ | |||
+ | {{DevFeature1.13|8}} | ||
+ | |||
+ | Changes the zoom level of the map. | ||
+ | |||
+ | * '''factor''': The new zoom factor, measured as a multiple of the base zoom. | ||
+ | * '''relative''': If yes, zoom relative to current zoom level. Otherwise, set the absolute zoom level. Default no. | ||
== Useful Macros == | == Useful Macros == |
Latest revision as of 13:40, 10 July 2024
Contents
- 1 Interface actions
- 2 [inspect]
- 3 [message]
- 4 [objectives]
- 5 [set_menu_item]
- 6 [clear_menu_item]
- 7 Other interface tags
- 7.1 [change_theme]
- 7.2 [item]
- 7.3 [remove_item]
- 7.4 [print]
- 7.5 [move_unit_fake]
- 7.6 [move_units_fake]
- 7.7 [hide_unit]
- 7.8 [unhide_unit]
- 7.9 [lock_view]
- 7.10 [unlock_view]
- 7.11 [scroll]
- 7.12 [scroll_to]
- 7.13 [scroll_to_unit]
- 7.14 [select_unit]
- 7.15 [sound]
- 7.16 [sound_source]
- 7.17 [story]
- 7.18 [remove_sound_source]
- 7.19 [music]
- 7.20 [volume]
- 7.21 [color_adjust]
- 7.22 [screen_fade]
- 7.23 [delay]
- 7.24 [redraw]
- 7.25 [unit_overlay]
- 7.26 [remove_unit_overlay]
- 7.27 [animate_unit]
- 7.28 [label]
- 7.29 [floating_text]
- 7.30 [deprecated_message]
- 7.31 [wml_message]
- 7.32 [test_condition]
- 7.33 [open_help]
- 7.34 [show_objectives]
- 7.35 [chat]
- 7.36 [zoom]
- 8 Useful Macros
- 9 See Also
Interface actions
Part of ActionWML, interface actions are actions that do not have a direct effect on gameplay; instead, they show something to the player. The main interface tags are [message] and [objectives], but several other tags affect the interface also.
[inspect]
This user interface instantly displays the gamestate inspector dialog at the current scenario state (the same one that can be brought up with the :inspect command), which can be used to inspect the values of WML variables, AI configuration, recall lists, and more.
- name: optional attribute to specify the name of this gamestate inspector dialog. It is just a label to help differentiate between different invocations of gamestate inspector dialog.
[message]
The most commonly used interface action is [message], which displays a message to the user in a dialog box. It can also be used to take input from the user.
The following key/tags are accepted for [message]:
- StandardUnitFilter: The unit whose profile and name are displayed. Do not use a [filter] tag. If no unit matching this filter is found, the message is not displayed (The unit has probably been killed).
[message] elements should be constructed so that it is either guaranteed that a certain unit is alive, or so that dialog flows smoothly even if the message isn't displayed.
- speaker: an alternative to standard unit filter. You may specify as the value of the speaker attribute a unit id or any of the following special values:
- narrator: the dialog box is displayed without a caption for the unit speaking or a unit image
- unit: the primary unit for the event is speaking
- second_unit: the secondary unit for the event is speaking
- message: (translatable) the text to display to the right of the image. message is sometimes multiple lines; if it is, be sure to use quotes( ' or " )
- male_message, female_message: (Version 1.13.2 and later only) (translatable) Used instead of message if the unit's gender matches. Never used if there is no unit (ie speaker=narrator). (Version 1.13.6 and later only) This matches the primary unit, not the secondary unit.
- wait_description: (Version 1.13.2 and later only) the description of this message displayed when other players in a mp game wait for one player doing input in a [message] (with [option]s or [text_input]).
- [show_if]: if present then this message will only be displayed if the conditional statement in this tag is passed (see ConditionalActionsWML)
- side_for: (default: all sides) comma-separated list of sides for who message is shown. This will not work with messages that take user input ([option]/[text_input]), which can only ever be shown to the current player. (Version 1.13.0 and later only) side_for= is now also accepted for messages with user input, it specifies on which side the message is shown (defaults to the currently playing side). For messages with input it does not accept a comma seperated list only a single number.
- image: (default: profile image of speaker) the image to display to the left of the message text. Append ~RIGHT() if you want the image to appear on the right side.
- (Version 1.13.0 and later only) none: display no image
- mirror: (Version 1.13.5 and later only)whether to mirror the image specified by the image attribute.
- second_image: (Version 1.13.6 and later only)same as the image attribute, but the image is displayed on the right of the message text. (Version 1.17.7 and later only)not working anymore, but there is plan to fix it eventually https://github.com/wesnoth/wesnoth/issues/8770
- second_mirror: (Version 1.13.6 and later only)same as mirror, but for the second_image attribute.
- image_pos: (Version 1.13.5 and later only) whether to show the image on the left or right; supercedes the use of ~RIGHT() described above
- caption: (default: name of speaker) the caption to display beside the image. Name to be displayed. Note: use a translation mark to avoid wmllint errors.
- scroll: Boolean specifying whether the game view should scroll to the speaking unit. Defaults to yes.
- highlight: (Version 1.13.5 and later only) Boolean specifying whether to highlight the speaker. Defaults to yes.
- sound: a sound effect (wav file) to play as the message is displayed. This can be a comma-separated list, from which one will be randomly chosen.
- voice, male_voice, female_voice: (Version 1.13.? and later only) a sound to be played as the message is displayed. This can also be a comma-separated list, from which one will be randomly chosen. This is intended for voiceovers for the message. The gendered forms are applied the same as for message. They are never used when the speaker is the narrator - only voice is used in that case.
- [option]: No [option] elements have to be used. If [option] elements are present, then each option will be displayed in a menu for the user to select one option. Note: Messages with options will not be shown at all in prestart events
- message: (translatable) the text displayed for the option. (Version 1.15.1 and later only) This is now a synonym for description=.
- image, label, description, default: See DescriptionWML.
- value: (Version 1.13.? and later only) Gives the option a value to be stored in a variable.
- [show_if]: if present then this option will only be displayed if the conditional statement in this tag is passed (see ConditionalActionsWML)
- [command]: an element containing actions which are executed if the option is selected.
- variable: (Version 1.13.? and later only) If present, either the index or the value of the chosen option will be stored in the specified variable. Option indexing starts from 1. If option has [show_if] condition evaluated as false, then it is hidden and excluded from the indexing.
- [text_input]: there can be only one [text_input] tag. this adds a text input field to the message. Note: Messages with text_input will not be shown at all in prestart events
- variable: the variable that the user's input will be written to
- label: a text label to the left of the input field
- max_length: the maximum number of characters that may be typed into the field
- text: text that is written into the field in the beginning
- Check EventWML#Multiplayer_safety to find out in which events you can safely use [option] and [text_input] without causing OOS.
Formatting
[message] and other tags such as unit names (user_description), objectives, and floating text can make use of Pango markup formatting codes.
Prefer to use single quotes (') instead of double quotes (") within the formatting string, as double quotes would need to be escaped in WML (""). Escaping markup can be done with HTML entities.
For example, if you wanted to write "You are victorious!" in large, italic, gold letters, you might write it this way:
<span color='#BCB088' size='large' font-style='italic'>You are victorious!</span>
These are the codes taken from the Pango markup formatting guide:
- font, font_desc: A font description string, such as "Sans Italic 12".
- font_family, face: A font family name.
- font_size, size: Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'.
- font_style, style: One of 'normal', 'oblique', 'italic'.
- font_weight, weight: One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight.
- font_variant, variant: One of 'normal' or 'smallcaps'.
- font_stretch, stretch: One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'.
- foreground, fgcolor, color: An RGB color specification such as '#00FF00' or a color name such as 'red'. The full list of color names may be found in Pango's rgb.txt file.
- background, bgcolor: An RGB color specification such as '#00FF00' or a color name such as 'red'.
- underline: One of 'none', 'single', 'double', 'low', 'error'.
- underline_color: The color of underlines; an RGB color specification such as '#00FF00' or a color name such as 'red'.
- rise: Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.
- strikethrough: 'true' or 'false' whether to strike through the text.
- strikethrough_color: The color of strikethrough lines; an RGB color specification such as '#00FF00' or a color name such as 'red'
- fallback: 'true' or 'false' whether to enable fallback. If disabled, then characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text. Fallback is enabled by default. Most applications should not disable fallback.
- letter_spacing: Inter-letter spacing in 1024ths of a point.
- gravity: One of 'south', 'east', 'north', 'west', 'auto'.
- gravity_hint: One of 'natural', 'strong', 'line'.
The following pango attributes are also available directly as attributes of the [message] tag: (Version 1.13.4 and later only)
- font
- font_family
- font_size
- font_style
- font_weight
- font_variant
- font_stretch
- color
- bgcolor
- underline
- underline_color
- rise
- strikethrough
- strikethrough_color
- fallback
- letter_spacing
- gravity
- gravity_hint
[objectives]
The other tag used for plot development is [objectives]. The [objectives] tag overwrites any previously set objectives, and displays text which should describe the objectives of the scenario. Scenario objectives are displayed on the player's first turn after the tag is used, or as part of the event if it triggers during that player's turn. Objectives can also be accessed at any time in a scenario using the "Scenario Objectives" game menu option, making this tag useful for scenario-specific information that the player may need to refer to during play.
Attributes of [objectives]:
- side: Default '0'. The side to set the objectives for. A value of 0 sets objectives for all sides. note: There are side-specific objectives and default objectives, which are used in case a side doesn't have specific ones. Specifying 0 sets the default ones.
- StandardSideFilter tags and keys: Sets the objectives of all matching sides to these passed specifications (the rest of this [objectives] tag). If no sides (such as when passing side=0) or all sides match, sets the default objectives, and the side specific ones for the matching sides otherwise.
- bullet: Default '• '. Replaces the default bullet, with whatever is passed, for all objectives, gold carryover notes, and notes defined with [note].
- summary: Displayed first in the objectives text, this should describe the basic objective for the overall scenario. Can be omitted.
- note: Displayed last in the objectives text, this is sometimes used for hints or additional information. Can be omitted.
- victory_string: Default ' _ "Victory:"', this text precedes the victory objectives. Can be set to "" too.
- defeat_string: Default ' _ "Defeat:"', this text precedes the defeat objectives. Can be set to "" too.
- gold_carryover_string: Default ' _ "Gold carryover:"', this text precedes the gold carryover information.
- notes_string: Default ' _ "Notes:"', this text precedes the notes.
- silent: Default: not present. If set to "yes", the objectives are silently changed. Else, they will be shown to the user when appropriate.
- delayed_variable_substitution: (Version 1.13.8 and later only) If set to yes, any variables or [insert_tag] are not substituted right away. Instead, they are substituted whenever the objectives are actually viewed.
Tags of [objectives]:
- [objective]: describes a win or loss condition. Most scenarios have multiple win or loss conditions, so use a separate [objective] subtag for each line; this helps with translations.
- bullet: Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet, with whatever is provided, for the objective defined by the [objective] block.
- red: Default '0' for winning objectives, '255' for losing objectives. Overrides the default red coloring of the entire objective, including the bullet.
- green: Default '255' for winning objectives, '0' for losing objectives. Overrides the default green coloring of the entire objective, including the bullet.
- blue: Default '0'. Overrides the default blue coloring of the entire objective, including the bullet.
- description: text for the specific win or loss condition.
- caption: a text which will be displayed above the description. This can be used to display a subcategory of objectives below victory_string or defeat_string.
- condition: The color and placement of the text. Values are 'win'(colored green, placed after victory_string) and 'lose'(colored red, placed after defeat_string).
- show_turn_counter: If set to yes, displays the number of turns remaining in the scenario. Default is no.
- [show_if]: A condition that disables the objective if it doesn't hold. Conditional objectives are refreshed at [show_objectives] time only, or when manually opening the scenario objectives.
- [gold_carryover]: describes how the gold carryover works in this scenario. This is intended to be a more convenient way of displaying carryover information than using the note= key in [objectives].
- bullet: Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided.
- red: Default '255'. Overrides the default red coloring of the entire objective, including the bullet.
- green: Default '255'. Overrides the default green coloring of the entire objective, including the bullet.
- blue: Default '192'. Overrides the default blue coloring of the entire objective, including the bullet.
- bonus (boolean): whether an early finish bonus is granted. If omitted, early finish bonus is not mentioned.
- carryover_percentage: the amount of carryover gold. If omitted, the amount is not mentioned.
- [show_if]: (Version 1.13.11 and later only) Gold carryover will not be shown if the specified condition isn't met. Conditional gold carryover is refreshed at [show_objectives] time only.
- [note]: describes a note, usually used for hints or additional information. This is an easier way of adding several notes than concatenating them together into a single string to use with the note= key.
- bullet: Default '• ' or whatever is set in the parent [objectives] block. Replaces the default bullet with whatever is provided for the note defined by the [note] block.
- red: Default '255'. Overrides the default red coloring of the entire note, including the bullet.
- green: Default '255'. Overrides the default green coloring of the entire note, including the bullet.
- blue: Default '255'. Overrides the default blue coloring of the entire note, including the bullet.
- description: the text of the note.
- [show_if]: The note will not be shown if the specified condition isn't met. Conditional notes are refreshed at [show_objectives] time only.
This tag is used to add a custom option in the right-click context menu which can then be used to trigger arbitrary WML commands. The menu items can be set and modified during any event, for example during "start" or "prestart" events. The user can also assign hotkeys to these WML commands unless specified otherwise. When the hotkey is pressed the event will be fired/filtered at the current mouse position.
Note: Due to limitations in portable devices where there are no scroll bars for context menus, there is a hard-coded limit of 7 custom WML menu items. If you really need to have more than 7 menu items, try combining some of them in a submenu. (Version 1.13.0 and later only) This limitation is being removed in a future version of Wesnoth.
- id: the unique id for this menu item. If a menu item with this id already exists, it allows you to set specific changes to that item. All menus will be sorted lexicographically by the id string. The ordering is underscores, digits, and finally letters.
- description: the in-game text that will appear for this item in the menu.
- image: the image to display next to this item, defaults to "buttons/WML-custom.png"
- needs_select: if yes (default no), then the latest select event (see EventWML) that triggered before this menu item was chosen will be transmitted over the network before this menu item action will be. This only has any effect in networked multiplayer, and is intended to allow more elaborate menu item behaviour there without causing out of sync errors. If you don't know what this means, just leave it. (Version 1.13.6 and later only) needs_select=yes is deprecated, consider using manual variable syncing with [sync_variable].
- synced (Version 1.13.1 and later only): if no (default yes) the command handler will only be run on the client that invoked the menu item; this means that changing the gamestate in a command handler of a menu item with synced=no will cause OOS
- use_hotkey: if no (default yes), then the user cannot assign hotkeys to this menu item. If only, the menu item is only accessible via hotkeys, not via right-click context; you can use this in combination with [default_hotkey] if you want custom hotkeys in your campaign/mp.
- [show_if]: If present, the menu item will only be available if the conditional statement (see ConditionalActionsWML) within evaluates to true. When this is evaluated, the WML variables $x1 and $y1 will point to the location on which the context menu was invoked, so it's possible to for example only enable the option on empty hexes or on a particular unit.
- [filter_location]: contains a StandardLocationFilter similar to the one found inside Single Unit Filters. The menu item will only be available on matching locations.
- [default_hotkey]: contains a hotkey WML to specify what hotkey to assign to this, if the user has no hotkey assigned to this yet. (Unlike the rest of a menu item definition, modifying this tag has no effect on the game; it is only effective when initially defining a menu item.) Hotkey WML matches the format in the preferences file and contains the following keys:
- key: a string that contains the key to assign to this.
- alt, shift, cmd(apple only), ctrl: boolean values.
- repeat_on_hold (Version 1.13.12 and later only): if yes (default no), holding the hotkey will repeat the action continuously, unless it blocks input with something like [message]. Due to a bug, versions older than 1.13.12 always repeat the action, with no way to disable it.
- [command]: contains the WML actions to be executed when the menu item is selected. Again, the WML variables $x1 and $y1 will point to the location on which the context menu was invoked on.
- delayed_variable_substitution (boolean yes|no, default: yes): If no, forces a variable substitution run onto the wml included in this [command] block. Use this, if you want variables which are to substitute to get the values they have at execution time of the event where this set_menu_item appears. Other than that, they get the values they have at invocation time of the menu item.
Removes a menu item from the scenario. Normally menu items are, including all their defining wml, automatically carried over between scenarios. This tag prevents this. (The behavior is comparable to set_variable/clear_variable).
- id: (string): id of the menu item to clear. Can be a comma-separated list.
Other interface tags
The following tags are also action tags:
[change_theme]
(Version 1.13.8 and later only)
Change the current interface theme.
- theme: The ID of the new theme. Use
theme=
(empty key) to switch back to the theme that the player has selected in Preferences. On 1.14.2 and later it is also possible to omit the key entirely to achieve the same effect (on previous versions this will crash the Lua engine).
[item]
Makes a graphical item appear on a certain hex. Note this only places the graphics for an item. It does not make the item do anything. Use a moveto event to make moving onto the item do something. (Hint: There are a number of predefined items that are used in various campaigns that you can make use of. You can find a list of them if you look into the items.cfg file in the wesnoth install directory (under /data/core/macros).)
- x, y: the location to place the item. (only for [event][item]: full SLF support)
- image: the image (in images/ as .png) to place on the hex. This image is aligned with the top-left of the hex (which is 72 pixels wide and 72 pixels tall). It is drawn underneath units. (Hint: If using an image smaller than 72x72, then it might be useful to BLIT the image onto misc/blank-hex.png (a blank 72x72 image).)
- halo: an image to place centered on the hex. It is drawn on top of units. Use this instead of image if the image is bigger than the hex or if you want to animate an image (https://github.com/wesnoth/wesnoth/issues/1219).
- name an id that can be used to remove the item.
Example (where the integer after the colon is the duration of each frame or square bracket expansion as per AnimationWML is used): halo=scenery/fire1.png:100,scenery/fire2.png:100,scenery/fire3.png:100,scenery/fire4.png:100,scenery/fire5.png:100,scenery/fire6.png:100,scenery/fire7.png:100,scenery/fire8.png:100 or equivalently (requires Wesnoth 1.11.2+): halo=scenery/fire[1~8].png:100
- team_name: name of the team for which the item is to be displayed (hidden for others). For multiple teams just put all the names in one string, for example separated by commas. (Version 1.15.0 and later only) In 1.14 the [side]team_name attribute was expected to be a substring of this team_name. In 1.15 both are expected to be comma-separated lists of names and the item is visible if the lists intersect. ([[1]])
- visible_in_fog: whether the item should be visible through fog or not. Default yes.
- redraw: (boolean yes|no, default: yes): If no, disables implicit calls to [redraw] when placing the items.
- [filter_team]: (Version 1.15.0 and later only) A StandardSideFilter. Set team_name to the union of all [side]team_name attributes of all sides that match the SSF. ([[2]])
- (Version 1.15.0 and later only) If both team_name and [filter_team] are set, team_name is ignored.
[remove_item]
Removes any graphical items on a given hex.
- StandardLocationFilter: the hexes to remove items from
- image: if specified, only removes the given item if one of its 'image', 'halo' or 'name' attributes is exactly this value. (for 'halo' and 'image' this in particular means that the image name must include any image path functions appended to the original image name.)
[print]
Displays a message across the screen. The message will disappear after a certain time, or when another [print] tag is encountered.
- text: (translatable) the text to display. Can be an empty string to remove a previous message without showing a new one.
- size: (default=12) the pointsize of the font to use
- duration: the length of time to display the text for.
- (Before 1.15.4) This is measured in the number of 'frames', and the default is 50. A frame in Wesnoth is usually displayed for around 30ms.
- (Version 1.15.4 and later only) This is measured in milliseconds. Don't use the default value, because it's a mere 50ms.
- (Version 1.15.14 and later only) The default is 5000 milliseconds.
- (Version 1.15.14 and later only) The string unlimited displays the text until it's removed by another [print] tag.
- color: (default 0,0,0) three comma-separated values giving the red, green and blue values (0-255).
- red, green, blue: deprecated, use color=0,0,0 instead.
[move_unit_fake]
Moves an image of a unit along a certain path on the map. The path does not need to be a continuous list of adjacent hexes, so for example only the start and end points can be given, in which case the straightest line between those points will be calculated and used.
- type: the type of the unit whose image to use
- x: a comma-separated list of x locations to move along
- y: a comma-separated list of y locations to move along (x and y values are matched pairs)
- side: the side of the fake unit, used for team-coloring the fake unit
- gender: the gender of the fake unit. Example: gender=female
- variation: the variation of the fake unit. Example: variation=undead
- image_mods: image path functions sequence to be applied on the fake unit.
- force_scroll: Whether to scroll the map or not even when [lock_view] is in effect or Follow Unit Actions is disabled in Advanced Preferences. Defaults to yes starting with version 1.11.6; the attribute did not exist in previous versions and this action behaved as if no was passed instead.
[move_units_fake]
moves multiple images of units along paths on the map. These units are moved in lockstep.
- force_scroll: (Version 1.15.0 and later only) Has the same meaning as in [move_unit_fake] but a different default.
- [fake_unit]: A fake unit to move
- type: the type of unit whose image to use
- x: a comma-separated list of x locations to move along
- y: a comma-separated list of y locations to move along (x and y values are matched pairs)
- side: the side of the fake unit, used for team-coloring the fake unit
- skip_steps: the number of steps to skip before this unit starts moving
[hide_unit]
Temporarily prevents the engine from displaying the given unit. The unit does not become invisible, as it would be with the [hides] ability; it is still the same plain unit, but without an image. Useful in conjunction with [move_unit_fake]: to move a leader unit into position on-screen. Until 1.8 each [hide_unit] tag only hides one unit.
- StandardUnitFilter: All matching units will be hidden
[unhide_unit]
Stops the currently hidden units from being hidden.
- StandardUnitFilter: Only the matching units will be unhidden
[lock_view]
Locks gamemap view scrolling for human players, so they cannot scroll the gamemap view until it is unlocked. WML or Lua actions such as [scroll_to] will continue to work normally, as they ignore this restriction; the locked/unlocked state is preserved when saving the current game.
This feature is generally intended to be used in cutscenes to prevent the player scrolling away from scripted actions.
(Version 1.13.8 and later only) This now also blocks the player from zooming the gamemap view. WML or Lua zoom will continue to work normally.
[unlock_view]
Unlocks gamemap view scrolling for human players.
[scroll]
Scroll a certain number of pixels in a given direction. Useful for earthquake/shaking effects.
- x, y: the number of pixels to scroll along the x and y axis
- side: the side or sides for which this should happen. By default, the [scroll] happens for everyone.
- [filter_side]: a StandardSideFilter to select the sides for which this should happen. By default, the [scroll] happens for everyone.
[scroll_to]
Scroll to a given hex
- StandardLocationFilter, do not use a [filter_location] sub-tag. If more than one location matches the filter, only the first matching location will be used.
- check_fogged: whether to scroll even to locations covered in fog or shroud. Possible values yes (don't scroll to fog) and no (scroll even to fog), with no as the default.
- immediate: whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to no).
- highlight: (Version 1.13.5 and later only) Whether to highlight the hex being scrolled to (defaults to no).
- side: the side or sides for which this should happen. By default, the [scroll_to] happens for everyone.
- [filter_side]: a StandardSideFilter to select the sides for which this should happen. By default, the [scroll_to] happens for everyone.
[scroll_to_unit]
Scroll to a given unit
- StandardUnitFilter; do not use a [filter] subtag.
- check_fogged: whether to scroll even to locations covered in fog or shroud. Possible values yes (don't scroll to fog) and no (scroll even to fog), with no as the default.
- immediate: whether to instantly warp to the target hex regardless of the scroll speed setting in Preferences (defaults to no).
- highlight: (Version 1.13.5 and later only) Whether to highlight the hex the unit is on (defaults to no).
- for_side: the side or sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.
- [for_side]: a StandardSideFilter to select the sides for which this should happen. By default, the [scroll_to_unit] happens for everyone.
[select_unit]
Selects a given unit.
- StandardUnitFilter: The first unit found will be selected.
- fire_event: whether a select event should be triggered or not (def. no). (Note that select events aren't multiplayer save.)
- highlight: whether the unit's current hex should be highlighted (def. yes).
Note: fire_event does not appear to work in 1.14 or 1.16.
[sound]
Plays a sound
- name: the filename of the sound to play (in sounds/ as .wav or .ogg). This can be a comma-separated list, from which one sound will be chosen randomly.
- repeat: repeats the sound for a specified additional number of times (default=0)
[sound_source]
Creates a sound source. "Sound sources" is a general name for a mechanism which makes possible for map elements to emit sounds according to some rules, where "map elements" can be specific locations or terrain types. For now, only sound sources tied to locations are supported.
- id: a unique identification key of the sound source
- sounds: a list of comma separated, randomly played sounds associated with the sound source
- delay: a numerical value (in milliseconds) of the minimal delay between two playbacks of the source's sound if the source remains visible on the screen; if one scrolls out and back in, the source will be considered as ready to play
- chance: a percentage (a value from 0 to 100) describing the chance of the source being activated every second after the delay has passed or when the source's location appears on the screen (note that it cannot play more than one file at the same time)
- check_fogged: possible values yes and no - yes means the source will not play if its locations are fogged
- check_shrouded: possible values yes and no - yes means the source will not play if its locations are shrouded
- x,y: similar to x,y as found in a StandardLocationFilter, these are the locations associated with the sound source
- fade_range (default = 3): distance in hexes that determines a "circular" area around the one specified by full_range where sound volume fades out linearly
- full_range (default = 14): distance in hexes that determines a "circular" area where source plays with full volume, relative to screen center
- loop: number of times a sound sample should be looped if it stays visible. -1 means infinite (~65000)
[story]
(Version 1.13.8 and later only)
Shows the story screen.
- title: Default title used if a part does not specify one — unlike the intro storyscreen, the scenario name is not used as a default title.
- [part], [if], [switch], [wml_message], [deprecated_message] : See IntroWML.
[remove_sound_source]
Removes a previously defined sound source.
- id: the identification key of the sound source to remove
[music]
Switches to playing different music
- name: the filename of the music to play (in music/ as .ogg)
- see MusicListWML for the correct syntax
[volume]
Changes the game volume to a percent of the preferences volume for the game being played. Values can go from 0 to 100:
- music: Changes the music volume.
- sound: Changes the sound volume.
[color_adjust]
Adjust the color tint of terrain, by adjusting time-of-day coloring.
- red, green, blue: values from -255 to 255, the amount to tint by for each color
[screen_fade]
(Version 1.17.6 and later only)
Overlay the game display with the given color, fading over the specified duration. This can be used for screen fade effects.
- red, green, blue: values from 0 to 255, the final overlay color (defaults to 0,0,0)
- alpha: value from 0 to 255, the strength of the effect. 0 means no effect and can be used to fade in. 255 means fully opaque and can be used to fully fade out to the given color. Intermediate values will end up with a partial overlay tint on the game screen.
- duration: the length of time it will take to complete the fade, in milliseconds. If 0 the effect is immediate.
[delay]
Pauses the game.
- time: the time to pause in milliseconds
- accelerate (boolean yes|no, default no): (Version 1.13.0 and later only) whether the delay is affected by acceleration. When [delay] is used to make an animation, this should be set to yes so that your animation matches the ones generated by the game.
[redraw]
Redraws the screen (this normally isn't done during events, although some of the other interface actions cause the screen or parts of it to be redrawn).
- clear_shroud (boolean yes|no, default no): If yes, clears fog and shroud around existing units. Useful if you, for example, spawn friendly units in the middle of an event and want the shroud to update accordingly (otherwise units that spawn inside fog would remain invisible for the duration of the event, since the fog would not automatically get cleared around them).
- StandardSideFilter: the sides for which to recalculate fog and shroud.
- side: If used (forces clear_shroud=yes), clears fog and shroud for that side.
[unit_overlay]
Sets an image that will be drawn over a particular unit, and follow it around
- StandardUnitFilter: All matching units will get the overlay (do not use [filter])
- image: the image to place on the unit
- object_id: object id to use, defaults to the image key with an "overlay_" prefix; this allows using [remove_object]
- duration: object duration
[remove_unit_overlay]
Removes a particular overlayed image from a unit
- StandardUnitFilter: The overlay will get removed from all matching units (do not use [filter])
- image: the image to remove from the unit
- object_id: object id to use
Using [remove_object] is also possible, see https://github.com/wesnoth/wesnoth/commit/26c2f941f2bcdd89528481e114c0375ad2a46271
[animate_unit]
Uses an animation of a unit to animate it on screen (if the unit has the corresponding animation).
- flag: The key to find the custom animation in the unit description (see the [extra_anim] description in AnimationWML). Standard animations can be triggered with the following keywords: leading recruited standing idling levelout levelin healing healed poisoned movement defend attack death victory pre_teleport post_teleport
- [filter] with a StandardUnitFilter as argument, see FilterWML. By default, the unit at the event location will be animated. You can use this tag to choose any other unit to animate.
- [primary_attack]: If this tag is not present, the filter for animation will be triggered with no attack. If it is here, all attacks from the unit will be filtered, and a matching one will be used to filter the animation. Takes a weapon filter as argument, see FilterWML.
- [secondary_attack]: Similar to [primary_attack]. May be needed to trigger a defense animation correctly, if there are more than one animations available for the defending unit.
- hits: yes/no/hit/miss/kill: which according variation of a attack/defense animation shall be chosen (required)
- text: a text to hover during the animation
- male_text, female_text: (Version 1.13.2 and later only) (translatable) gender-specific versions of the above
- red: red value for the text color (0-255)
- green: green value for the text color
- blue: blue value for the text color
- with_bars: yes/no: whether to display the status bars during the animation (e.g. the hitpoint bar)
- [animate]: a sub block with the same syntax as [animate_unit] except that the [filter] block is mandatory to find the unit. This block will find and animate another unit simultaneously.
- [facing]: a StandardLocationFilter specifying what hex the unit should be facing when animated
[label]
Places a label on the map.
- x, y: the location of the label. (Version 1.13.1 and later only) (only for [event][label]: full SLF support)
- text: what the label should say. If you put an empty string
""
as an argument, the label will be completely removed. Use this method if you want to remove a specific label from any location. - team_name: if specified, the label will only be visible to the given team.
- color: color of the label. The format is r,g,b; r, g and b are numbers between 0 and 255.
- visible_in_fog: whether the label should be visible through fog or not. Default yes.
- visible_in_shroud: whether the label should be visible through shroud or not. Default no.
- immutable: whether this label is protected from being removed or changed by players. Default yes.
- category: the Show/Hide Labels dialog allows showing/hiding all labels of a given category by toggling a checkbox.
- tooltip: A tooltip visible when mouseovering the hex the label is on
- side: the number of the side that placed the label. Can be 0 for labels placed by WML.
[floating_text]
Floats text (similar to the damage and healing numbers) on the given locations.
- StandardLocationFilter: the text will be floated on all matching locations simultaneously (do not use [filter] unless you intend to match one or more units).
- text: the text to display.
The default text color is #6b8cff. To change the color, use Pango markup. For example:
# Float some golden yellow text at 20,20. [floating_text] x,y=20,20 text="<span color='#cccc33'>" + _ "Your text here" + "</span>" [/floating_text]
[deprecated_message]
Shows a deprecated message in the message area, this feature is only intended to be used to warn about deprecated macros in mainline. The message is not translatable.
- message: the message to show.
- level: (Version 1.13.10 and later only) The deprecation level, a number from 1 to 3.
- what: (Version 1.13.10 and later only) The name of the thing being deprecated. Use this instead of message if possible; a stock message will be generated from it. Use message only if more information is required; it will be appended to the stock message. This should not be translatable
- version: (Version 1.13.10 and later only) For deprecation levels 2 and 3, this indicates the version in which the feature could be removed. It does not indicate the version in which it became deprecated.
The meanings of the deprecation levels are as follows:
- Deprecated, but will only be removed if absolutely necessary. The version key is ignored.
- It will be removed no earlier than a specified version.
- It will be removed in the next stable version
- It has already been removed, leaving just a stub to inform users of how to update their code.
Note that as of 1.13.11, deprecation messages show only in the log, not in the chat message area. The message can be translatable, but does not need to be.
[wml_message]
Outputs a message to Wesnoth's console output. Intended for campaign designers to output silent text to the console, without annoying the player; then, that text might contain information useful for later bug-reporting. The log domain for it is wml, and the debug/dbg log level is available for use with the logger attribute. Depending on the current log level (error by default), which may be changed with the in-game :log command, or the --log-<level>=wml command line switch, the messages are echoed to the in-game chat.
- message: the message to show.
- logger: the Wesnoth engine output logger that should catch the text; this might be 'err' (the errors log level), 'warn'/'wrn' (the warnings log level) or anything else (the information log level). Not all information will be displayed depending on the log level chosen when starting Wesnoth.
Note: As of 1.9.4/1.9.5 (r48805) the following "loggers" should work: If in [wml_message]: err/error, warn/wrn/warning, debug/dbg; using the :log command: Only the long forms error, warning, info and debug (this part gathered by trying rather than source inspecting). The long forms are most likely also the only ones working when starting wesnoth with --log-<level>=wml. For log level warning or error (as during normal play), only wml_messages with logger error or warning display (for both). With logger info or debug, additionally wml_messages with logger info or debug display (for both).
[test_condition]
(Version 1.13.2 and later only)
Evaluates the contained conditional tags. If they evaluate to the expected value, it prints out a message to the console explaining which part of the condition caused this result in a way similar to [wml_message]. This can be used if your conditional test is failing and you're not sure why.
- result: Whether you expect the conditions to fail or succeed. If no (the default), a message will be printed if the conditional tags fail. If yes, a message will instead be printed if the conditional tags pass.
- logger: Same as for [wml_message]. Defaults to "warning".
[open_help]
Opens the in-game help.
- topic: the id of the topic to open
Examples of ids:
- unit_Mage
- unit_Dark Adept
- weaponspecial_charge
- terrain_human_castle
The engine will print the topic ids if run from the command line with the --log-debug=help option.
[show_objectives]
refreshes the objectives defined by [objectives] and its [show_if] tags, and displays them. (It is also called whenever the user explicitly asks for the objectives; this matters only if the tag was overridden by a Lua script.)
- side: the side to show the objectives. If not set, all sides are used.
- StandardSideFilter tags and keys: Tag affects the matching sides instead of just all or the one given by the integer value of the side= key.
[chat]
Displays a message in the chat area, not visible for observers. Alternative unconditionally visible for everyone: LuaWML:Display#wesnoth.message. (Version 1.13.9 and later only) can be visible for observers.
- speaker: (default="WML") A string for the name of the sender of the message.
- message: The message that should be displayed.
- observable (boolean yes|no, default yes): (Version 1.13.9 and later only) Whether the message is displayed for observers.
- StandardSideFilter tags and keys as argument; if the same client controls multiple sides that match, then the message will only be displayed once.
[zoom]
(Version 1.13.8 and later only)
Changes the zoom level of the map.
- factor: The new zoom factor, measured as a multiple of the base zoom.
- relative: If yes, zoom relative to current zoom level. Otherwise, set the absolute zoom level. Default no.
Useful Macros
There are some predefined macros that you find useful for interface actions. You can find a complete list along with a detailed explanation of how they work here.
- {HIGHLIGHT_UNIT} Highlight a unit on the map. Use this to show important units
- {HIGHLIGHT_IMAGE} Places and highlights an image on the map. Use this to show important items or locations
- {SET_IMAGE} Places an image on the map which has no other function.
- {QUAKE <soundfile>} Creates a tremor-like screenshake and plays <soundfile>. For example, {QUAKE (rumble.ogg)}.
- {FLASH_WHITE} Flash the screen white momentarily. You can also replace WHITE with RED, BLUE or GREEN for a different colour.