ImagePathFunctions

From The Battle for Wesnoth Wiki
Revision as of 21:57, 2 July 2007 by Esr (talk | contribs) (TC is gone)

Image Path Functions provide a simple method for WML coders to alter the way their specified images will be displayed in the game. All of the function parameters are included at the end of an image path and should not contain any spaces or special characters (other than those specified here).

Team-Color Function

In Wesnoth version 1.2, the only Image Path Function was ~TC(), which took two comma-separated parameters: the team number and the source color palette. The valid values for both of these parameters are defined in the file data/team-colors.cfg

Syntax

~TC( team number , source color palette )

  • team number - this is the first parameter, a number 1-9 signifying the team number of a unit. Number 1 typically means the red team, 2 typically means the blue team, and so on (unless the scenario color settings for any side have been altered).
  • source color palette - the second parameter is a source color palette, usually magenta. Do not surround this parameter with quotes.

After 1.3.4 this function was removed. Use ~RC() instead. Also, note that the names of the palettes shipped with the game are no longer numeric but are English names for the base color of the template (e.g. "red", "green", "blue", etc.)

Re-Color Function

Template:DevFeature May be used to change some colors in an image

Syntax

~RC( source color palette > color range ID )

  • source color palette - the first parameter is a source color palette, usually magenta. Do not surround this parameter with quotes.
  • color range ID - this is the second parameter,signifying the ID of a color range defined in the file data/team-colors.cfg (or it may be a custom ID for a color range defined locally).

Example

In the following example, the magenta regions in an elvish captain's image are turned a healthy shade of green:

     [message]
           speaker=narrator
           image=units/elves-wood/captain.png~RC(magenta>green)
           message=_ "Now I am on the green team."
     [/message]

In releases up to 1.3.4, the IDs of the color ranges shipped with Wesnoth were numeric, 1-9. In later releases they are the lowercased English name of the palette's base color (e.g. 'red', 'brown', etc.)

Flip Function

Template:DevFeature May be used to flip an image horizontally and/or vertically

Syntax

~FL( optional argument list )

  • vertical - if the string "vert" is found anywhere in the argument list, the image will be flipped vertically.
  • horizontal - if the string "horiz" is found anywhere in the argument list, the image will be flipped horizantally.
  • if the argument list is empty, the image will only be flipped horizantally.