<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.wesnoth.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Artisticdude</id>
	<title>The Battle for Wesnoth Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.wesnoth.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Artisticdude"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/Special:Contributions/Artisticdude"/>
	<updated>2026-05-02T15:48:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=56190</id>
		<title>WML for Complete Beginners: Chapter 1</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=56190"/>
		<updated>2015-03-28T18:05:50Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Formatting revisions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a &amp;quot;[http://en.wikipedia.org/wiki/Markup_language markup language].&amp;quot; This means that the syntax of the entire language consists of two fundamental elements: '''tags''' and '''attributes'''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try using capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a '''tagset'''. A tagset always contains exactly two tags: the opening tag and the closing tag. For example, the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags in WML. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. &lt;br /&gt;
&lt;br /&gt;
:Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag, except a closing tag has a forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called a &amp;quot;tagset&amp;quot;.&lt;br /&gt;
::*A tagset can only ever consist of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:Now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you just say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what to do generally (like telling your friend to &amp;quot;go&amp;quot;), but without attributes to specify ''exactly'' what to do (like telling your friend where and when to go, and what to do when he gets there), the WML engine won't be able to do anything because you haven't given it enough specific information. If you told your friend, &amp;quot;Go,&amp;quot; he'd understand that you want him to go somewhere, but he'd be unable to actually perform the task because he doesn't know ''where'' to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-translatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, all you have to do is add an underscore before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is generally considered a good practice to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::However, the game considers both of the above strings to be equivalent, and will therefore recognize both as translatable strings. Adding whitespaces just allows for better human readability in your WML code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Unsurprisingly, numerical strings are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter [FIXME HERE]). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
Continue to [[WML for Complete Beginners: Chapter 2]]&lt;br /&gt;
&lt;br /&gt;
[[Category:WML_for_Complete_Beginners]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Armour_Tutorial&amp;diff=52222</id>
		<title>Armour Tutorial</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Armour_Tutorial&amp;diff=52222"/>
		<updated>2013-10-21T19:00:54Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Dark tones */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;By [http://forums.wesnoth.org/memberlist.php?mode=viewprofile&amp;amp;u=110981 LordBob] ([http://forums.wesnoth.org/viewtopic.php?f=18&amp;amp;t=23783 original thread])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After receiving compliments on the loyalists' armour and hearing a few of you wish they could do the same, I decided I'd try and help. This tutorial will guide you through the basic shading of metalic armour.&lt;br /&gt;
&lt;br /&gt;
First things first, it's best to state the obvious here a now: there's no magical trick, only a keen eye and lots of hard work. Not only must you think weight and shape, but also movement: the viewer must not feel that parts of your armour obstruct the character's moves.  Reference pictures of actual armour ('''not''' pictures of typical fantasy computer-game armour, but rather pictures of physical armour that has actually been used at some point in human history) will help design believable sets of armour. If you have the opportunity, visit a place where you can sketch from real armour. Sketch in odd angles, with special attention to light and shapes. Reference, reference, reference! &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, the shading. I'll develop the tutorial through 3 examples, each one a different metal.&lt;br /&gt;
&lt;br /&gt;
==Dark tones==&lt;br /&gt;
&lt;br /&gt;
*'''Step one, pick the base colour of your metal.''' Greys for steel and iron, browns for bronze or gold. The colour you chose should reflect the overall tone of your finished armour. One this is done, pick your light source and begin the thinking.&lt;br /&gt;
&lt;br /&gt;
*'''Step two, the dark tones.''' I use a brush of fixed size and variable opacity, with low transparency if you're heavy-handed. With Photoshop, I use the &amp;quot;Multiply&amp;quot; fusion mode and pick the base colour of my metal. In midtones, giving several light strokes is better than a single strong stroke, since it will give texture and a gradient effect to your metal.&lt;br /&gt;
&lt;br /&gt;
*'''Step three, darker tones.''' For this step, I use a similar brush of smaller size and give heavier strokes. This time, it's better to apply large patches. What you'll have to bear in mind when shading is that metal doesn't reflect light like cloth or leather. Contrasts on metal are high, whether it be light or shadows. In my example, step #2 is far from enough. Shadowed areas develop darker patches, caused by the obstruction of light by an arm, a shield, etc. Reflections of nearby objects will also manifest as darker patches. Step #3 is better as far as contrast goes, but we're not done yet.&lt;br /&gt;
&lt;br /&gt;
*'''Step four, counter-reflection.''' This step is the key to metal shading. When shading, you must be aware that metal doesn't need a direct lightsource to reflect light. Reflections on a nearby wall, shield, and light diffused by the sky are enough to cause the counter-reflection. For this step, I keep the smaller brush and select the &amp;quot;Screen&amp;quot; fusion mode. You'll have to imagine where your plausible secondary lightsource would be located. Every surface can have counter-reflections, it gives them volume and their metallic aspect.&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/lordbob-armor-tutorial/Armour-tutorial-1.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now your dark tones are done, it's time to give life to your metal by adding the light tones to the dark tones we've already done above.&lt;br /&gt;
&lt;br /&gt;
==Light Tones==&lt;br /&gt;
&lt;br /&gt;
*'''Step five - diffuse light:''' I pick a brush of fixed size and pressure-sensitive opacity, this time with the fusion mode Screen. The colour I pick in this step is the base colour of my metal. The aim is to obtain a diffused light in places not in shadow.&lt;br /&gt;
&lt;br /&gt;
*'''Step six - strong light:''' more screening with the same bush and colour. On bent metal, light with be more intense as the surface comes closer to the light source. The key here is to have a good mental image of your armour, in order to identify those places where direct light is strongest.&lt;br /&gt;
&lt;br /&gt;
*'''Step seven - pinpoint reflections:''' step six is already convincing enough, but not all the metal in a drawing receives the same intensity of light. In order to include this in your picture, spots on which you want to attract the viewer's eye will receive pin-size dots of white. I do this with a smaller brush, still in Screen mode, using this time a light grey tone so that the light tends toward white. This is important with tainted metals such as copper, brass, bronze... If you feel confortable enough, you can also use a basic brush and apply pure white in Normal mode. Note that not all mettalic spots ought to receive those white dots : your image would be too shiny. You have to use them as a track that guides the viewer to where you want his attention.&lt;br /&gt;
&lt;br /&gt;
*'''Step eight - colour overlay:''' this step is what truly gives life to your metal and blends it in the whole picture. Reflections on metal are tinted by the nature of the light and the surfaces on which the light reflects. I use a fixed size, pressure-sensitive brush in Overlay mode with very low transparency (25-30%). The colour I apply depends on the nature of the light: bluish for the sky, orange for torchlight or a campfire, the colour of your character's clothes where they reflect light, brown next to leather or a wooden shield...Keep in mind that with reflections, the effect will only be strong close to the reflecting surface, whereas intense light sources such as the sky or fire will diffuse their tint everywhere. This step is up to your imagination, just don't overdo it. And keep that transparency low! Oversaturated reflections will only remove credibility from your painstakingly shaded metal.&lt;br /&gt;
&lt;br /&gt;
http://www.wesnoth.org/wiki-images/tutorial/lordbob-armor-tutorial/Armour-tutorial-2.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''To be continued...'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[Art Tutorials]]&lt;br /&gt;
&lt;br /&gt;
[[Category: Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=52221</id>
		<title>Create Art</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=52221"/>
		<updated>2013-10-21T18:58:30Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* General Art and Computer Graphics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;float:right; margin-left:1em;&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Graphic artists working on artwork intended for mainline Wesnoth usually meet on the [http://forums.wesnoth.org/viewforum.php?f=9 Art Contributions forum] or on the [http://forums.wesnoth.org/viewforum.php?f=18 restricted Art Development forum] (&amp;quot;restricted&amp;quot; meaning that only those users with special permissions - such as art contributors and developers - can post there). The former is a great place to post and discuss new and current mainline Wesnoth art and graphics, and the latter to see what the art development team is working on. Artists working on graphics for [[Glossary|UMC]] add-ons meet in the [http://forums.wesnoth.org/viewforum.php?f=23 Art Workshop forum].&lt;br /&gt;
&lt;br /&gt;
Unit and terrain art is stored in the lossless ''Portable Network Graphics'' (PNG) format. Each frame of a unit animation, and each variation of a terrain is stored as a separate .png file in ''data/core/images'' under the [[EditingWesnoth#Where_is_my_game_data_directory.3F|main data directory]] of the game, and generally these files will be 72 x 72 pixels (the size of Wesnoth's basic hexagonal tile) with an alpha channel (a part of the file that indicates how transparent each pixel is). When creating your own images, you can test them without overwriting any game data by putting them in your [[EditingWesnoth#Where_is_my_user_data_directory.3F|user data directory]]. The game also supports JPEG images, although these are better suited for story art.&lt;br /&gt;
&lt;br /&gt;
To edit these graphics, you'll need some program capable of creating PNG's - some of the programs in the following list are free, open-source software, and will do the job nicely: [[Art Programs]]&lt;br /&gt;
&lt;br /&gt;
If you need some inspiration, we have a (no longer maintained) [[GraphicLibrary|Graphics Library]] which collects art posted on the forum. You can use this for ideas, and as a scrap heap for different parts of unit images (a technique described [[Give Your Hero A Personality|here]]).&lt;br /&gt;
&lt;br /&gt;
== Art Tutorials ==&lt;br /&gt;
&lt;br /&gt;
These are a work-in-progress, and describe both how to make art fit into Wesnoth's style, as well as giving some considerable tips on drawing in general.  Especially useful is the [[External Tutorials]] page which lists a large number of art tutorials available on the web.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General Art and Computer Graphics ===&lt;br /&gt;
* [[Using the Levels Adjustment]] - How to make scanned pencil drawings ''not'' look washed out.&lt;br /&gt;
* [[Extending dynamic range]] - The Grooviest (so far) tutorial about extending the dynamic range of images and how this technique can be used to make better scans of pencil drawings.&lt;br /&gt;
* [[Scanning with camera]] - How to transfer real-life art to computer using a digital camera instead of a scanner.&lt;br /&gt;
* [[Art Supplies]] - What physical items you need to do larger cell-shaded art like that of Jetrel/Jormungadr/et al.&lt;br /&gt;
* [[Inking With Pencils|Computer Inking a Sketch]] - Info from Jason Lutes on his portrait workflow.&lt;br /&gt;
* [[Scaling Digital Images]] - How to properly resize an image on a computer.&lt;br /&gt;
* [[How to Shade]] - An attempt at tackling a very complicated topic.&lt;br /&gt;
* [[Cartography for Wesnoth|How to make Wesnoth-style Maps ]] - Kestenvarn's tricks of the trade.&lt;br /&gt;
* [[Designing weapons and armour]] - Advice from zookeeper on designing realistic weapons for your characters.&lt;br /&gt;
* [[Portrait Tutorial]] - A guide on how to draw unit/character portraits by Kitty.&lt;br /&gt;
* [[Armour Tutorial]] A tutorial on how to shade metallic armour by LordBob.&lt;br /&gt;
====Vector Art====&lt;br /&gt;
Sgt. Groovy's vector workshop - Tips and tricks for drawing with Inkscape.&lt;br /&gt;
:* [[Z-order tricks]] - A few methods for faking overlapping shapes.&lt;br /&gt;
:* [[Variable-width strokes]] - How to make the strokes vary in width, like being drawn with a flat-tipped pen &amp;amp;mdash; no tablet needed!&lt;br /&gt;
:* [[Shaped gradients with Gaussian blur]] - How to make gradients in other shapes than linear or radial.&lt;br /&gt;
:* [[Smooth shading in vector]] - The basic vector techniques for smooth shading, employing Gaussian blur and clipping/masking.&lt;br /&gt;
:* [[Vector Inking]] - Vector techniques, including mouse-only, for inking your sketches.&lt;br /&gt;
:* [[Making portrait art in vector]] - A complete tutorial for making Wesnoth unit portraits in vector graphics.&lt;br /&gt;
&lt;br /&gt;
=== [[Terrain|Terrain Graphics]] ===&lt;br /&gt;
&lt;br /&gt;
The following is information specific to drawing terrain for Wesnoth.  Read Frame's &amp;quot;Tiles Tutorial&amp;quot; for a good overview of how terrain graphics work.&lt;br /&gt;
&lt;br /&gt;
* [[Mesilliac's Essay on Terrain Perspective]] - The geometry behind the perspective used for terrain tiles in Wesnoth.&lt;br /&gt;
* [[Tiles Tutorial]] - Frame's tutorial describing the process of making terrain tiles in Wesnoth, and how they interact with adjacent tiles.&lt;br /&gt;
* [[How To Make Seamless Tiles]] - The tutorial is aimed at Photoshop users, but the technique is similar with GIMP.&lt;br /&gt;
* [[Seamless Tiles Using Inkscape]] - This tutorial teaches a method for making seamless hex tiles in vector craphics (to be rendered in raster).&lt;br /&gt;
* [[Turning Square Tiles into Hex]] - Nifty tricks for transforming square (or any rectangle) shaped seamless tiles into hexagon seamless tiles.&lt;br /&gt;
* [[CastleTutorial|Castle Tutorial]] - A description of how Wesnoth's castle tiles work (needs updating, but useful nonetheless).&lt;br /&gt;
* [[MultiHexTutorial|Multi-Hex Tiling Tutorial]] - A description of how multi-hex tiles work.&lt;br /&gt;
* [[Editing Castles]] - Instructions for how to make/edit castles (and other corner-based terrains) using yobbo's GIMP script.&lt;br /&gt;
* [[How to create textures]] - This tutorial proposes a process to create custom terrain textures from photo reference.&lt;br /&gt;
&lt;br /&gt;
These describe the system used to specify how terrains behave in game:&lt;br /&gt;
* [[TerrainCodesWML]] - A list of the letters used to represent terrain types.&lt;br /&gt;
* [[TerrainGraphicsWML]] - If you really need to get technical, start here.&lt;br /&gt;
* [http://www.anathas.org/ayin/wesnoth/doc/terrain_graphics_wml Ayin's Terrain Graphics document] - If you really, ''really'' need to get technical, this describes the terrain graphics WML system in depth.&lt;br /&gt;
&lt;br /&gt;
=== Sprite Art ===&lt;br /&gt;
The following are different tutorials about sprite work compiled by various Wesnoth sprite artists.  These will give you the most specific-to-Wesnoth information about making sprites, and are well worth a read.&lt;br /&gt;
 &lt;br /&gt;
* [[Creating Unit Art]] - A list of specifications you will need to match.&lt;br /&gt;
* [[Give Your Hero A Personality]] - Tricks for editing existing images, including some clip art.&lt;br /&gt;
* [[Team Color Shifting]] - How to create art that uses our new team color system.&lt;br /&gt;
* [[TeamColoring]] - How to automatically team-color sprites to see what they look like in various colors.&lt;br /&gt;
* [[Creating Shadows Under Units]] - How we create the shadows for the units in-game.&lt;br /&gt;
* [[How to Anti-Alias Sprite Art]] - A means of removing the jagged edges on pixel lines.&lt;br /&gt;
* [[Rotate Pixel Art Without Blurring]]&lt;br /&gt;
* [http://forums.wesnoth.org/download/file.php?id=56284 Zerovirus's Spriting Workflow] - Wesnoth artist Zerovirus explains step-by-step his methodology for creating Wesnoth sprites from scratch (.png file).&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
* [[FrankenPacks]] - A quick and dirty way to create sprites for [[Glossary|UMC]].&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
====Animation====&lt;br /&gt;
:* [[Basic Animation Tutorial]] - Or &amp;quot;How to Animate Sprites for Dummies,&amp;quot; covering the basic theory, and all of the mistakes to avoid.&lt;br /&gt;
:* [[From Base Frame To Full Animation]] - A solid method of moving baseframes forward towards full animation.&lt;br /&gt;
:* [[How to create motion blurs]] - A simple explanation on how to create attack animation weapon blurs.&lt;br /&gt;
:* [[Making Bow Animations]] - The current standard for how we want bow animations to work.&lt;br /&gt;
:* [[Fire Animation]] - A great guide to creating fire FX by rhyging5.&lt;br /&gt;
&lt;br /&gt;
=== External Tutorials ===&lt;br /&gt;
The following page contains dozens of links to tutorials covering all manner of artwork, including sprite art.  These were not made by Wesnoth artists, but should prove very useful for general instruction.&lt;br /&gt;
&lt;br /&gt;
* [[External Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
* [[GraphicLibrary]] - Old library of user contributed graphics (most should be GPL'ed)&lt;br /&gt;
* [[Project]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49629</id>
		<title>WML for Complete Beginners: Chapter 1</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49629"/>
		<updated>2013-04-04T18:45:35Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Attributes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try using capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags in WML. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag, except a closing tag has a forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called a &amp;quot;tagset&amp;quot;.&lt;br /&gt;
::*A tagset can only ever consist of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:Now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. If you told your friend, &amp;quot;Go,&amp;quot; he'd understand that you want him to go somewhere, but he'd be unable to actually perform the task because he doesn't know ''where'' to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, all you have to do is add an underscore before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is generally considered a good practice to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::However, the game considers both of the above strings to be equivalent, and will therefore recognize both as translatable strings. Adding whitespaces just allows for better human readability in your WML code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Unsurprisingly, numerical strings are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter [FIXME HERE]). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49628</id>
		<title>WML for Complete Beginners: Chapter 1</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49628"/>
		<updated>2013-04-04T18:39:35Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Attributes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try using capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags in WML. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag, except a closing tag has a forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called a &amp;quot;tagset&amp;quot;.&lt;br /&gt;
::*A tagset can only ever consist of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:Now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. If you told your friend, &amp;quot;Go,&amp;quot; he'd understand that you want him to go somewhere, but he'd be unable to actually perform the task because he doesn't know ''where'' to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49627</id>
		<title>WML for Complete Beginners: Chapter 1</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49627"/>
		<updated>2013-04-04T18:35:58Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Tags */ Rewording, grammar nitpicks, clarifications&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try using capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags in WML. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag, except a closing tag has a forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called a &amp;quot;tagset&amp;quot;.&lt;br /&gt;
::*A tagset can only ever consist of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:Now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Artisticdude&amp;diff=49626</id>
		<title>User:Artisticdude</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Artisticdude&amp;diff=49626"/>
		<updated>2013-04-04T18:29:36Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''WIP Links:'''&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
*[http://wiki.wesnoth.org/WML_for_Complete_Beginners '''WIP template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial''']&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Template for future &amp;quot;Animating Running Cycles&amp;quot; tutorial&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
=Animating Running Cycles=&lt;br /&gt;
by [http://forums.wesnoth.org/memberlist.php?mode=viewprofile&amp;amp;u=119614 artisticdude]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Note: This is a work in progress.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
I've heard some people say that running cycles are the hardest animation to create. Personally, I disagree with the idea that running animations are ''harder'' to create than any other kind of animation. It's true that creating running animations generally involves more ''work'' than creating most other animations (attack, death, defense, etc.), but usually running animations also follow a very strict set of rules. Once you understand these rules, creating running animations should be little more than investing enough time to see it through.&lt;br /&gt;
&lt;br /&gt;
Note that I assume at least some level of competence in pixel art and animating throughout this tutorial. I also assume that the graphics program you are using supports layers and transparency (while those features aren't ''strictly'' necessary in order to create a running animation, they are huge time savers and will make your life a heck of a lot easier). If you haven't already, I suggest reading the [[Basic Animation Tutorial]] and [[From Base Frame To Full Animation]] before following this tutorial any further.&lt;br /&gt;
&lt;br /&gt;
In this tutorial, I will demonstrate how to create a standard south-east/south-west facing run cycle by using the Goblin Impaler unit from mainline. Running animations for the other directions (north-east/north-west, south, &amp;amp; north) are drawn at different angles, but the concepts and theories discussed here apply to running cycles in all directions.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: The Theory Behind Running Cycles==&lt;br /&gt;
&lt;br /&gt;
===Poses===&lt;br /&gt;
&lt;br /&gt;
Wesnoth running cycles are split into four distinct poses. Not frames, ''poses'', as in anatomical positions. These positions are:&lt;br /&gt;
* Contact&lt;br /&gt;
* Recoil&lt;br /&gt;
* Passing&lt;br /&gt;
* High Point&lt;br /&gt;
&lt;br /&gt;
===Rotation===&lt;br /&gt;
&lt;br /&gt;
As you may have noticed in the poses example above, there is a a certain amount of rotation happening over the course of the animation in the hips and shoulder areas. If you &lt;br /&gt;
&lt;br /&gt;
===Bobbing===&lt;br /&gt;
&lt;br /&gt;
===Movement Arcs===&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: Understanding Your Subject==&lt;br /&gt;
This is the most important part of the animation. You can come up with eight beautiful frames for your animation, but if those frames don't read as a realistic and fluid motion when played together as an animation, you might as well have just doodled random scribbles instead. Understanding your subject's anatomy, equipment, and weight will help you immensely in creating a realistic and fluid animation.&lt;br /&gt;
&lt;br /&gt;
===Anatomy===&lt;br /&gt;
&lt;br /&gt;
It is vital to any animation that you understand your subject's anatomy: where their joints are located, how far and in what direction those joints can bend and/or twist, whether there is a bone beneath the surface of a certain area or whether that area is composed of flexible membrane, etc. etc. This is especially important if your subject is not humanoid, but even for humanoids with non-human appendages or modified human appendages (tails, enormous ears, an extra set of arms, etc.). Before you even open your graphic editing program, study the baseframe of your subject and learn as much as you can about its anatomy. Find and study references, both still images and videos, if possible. Even creatures that don't have any real-world counterparts to study often have anatomical structures similar to those of real-world creatures. &lt;br /&gt;
&lt;br /&gt;
===Equipment===&lt;br /&gt;
&lt;br /&gt;
In addition to anatomy, it is paramount that you understand the equipment your subject is wearing/holding, since this will have a significant impact on how the character actually moves. I follow a list of simple steps to help me understand the equipment of the subject, in the form of a series of questions:&lt;br /&gt;
&lt;br /&gt;
*'''What exactly is each piece of equipment?'''&lt;br /&gt;
Most of the time it will be fairly obvious what each piece of equipment on your subject is (it's really hard to mistake a properly-drawn sword for a toothbrush), but there will be occasions where you won't be able to decide what that blue dot at the side of the subject's waist is.&lt;br /&gt;
*'''What is the three-dimensional shape of each piece of equipment?'''&lt;br /&gt;
*'''What is each piece of equipment made of?'''&lt;br /&gt;
**'''How flexible/rigid is that material?''' Obviously a cloth tunic will have different dynamics than a solid metal breastplate.&lt;br /&gt;
*'''How much does weight is the subject carrying?'''&lt;br /&gt;
Weight is a huge factor in animations. How you convey that weight in your animation can either make your subject look light and etherial, or heavy and ponderous. If you're animating a fairy, chances are the subject's movements will be swift and graceful. Likewise, if you're animating a troll warrior, the subject's movements are likely to be clumsier and more ponderous. The movement of your subject will also be heavily influenced by the weight of their equipment; for instance, an elf in lightweight leather armor will be able to move much faster and easier compared to a human wearing a suit of heavy steel armor. In order to produce a convincing animation, you will need to make sure you know approximately how much weight your subject is dealing with.&lt;br /&gt;
&lt;br /&gt;
Note that these questions are only to assist in drawing the motion of the object, not in drawing the object itself. To successfully draw and shade an object well, you must ask many additional questions which I won't go into here. If you do not know how to shade an object, I suggest you stop reading this page right now and do more reading up and practice on the subject before continuing.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: Direction and Perspective==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Direction===&lt;br /&gt;
&lt;br /&gt;
So now that we understand how the character should move, it's time to start planning the direction of the movment. In this case, since we're doing a south-east running animation, we have to have the subject move from one hex to the neighboring south-east hex:&lt;br /&gt;
&lt;br /&gt;
http://img51.imageshack.us/img51/6304/atob.png&lt;br /&gt;
&lt;br /&gt;
So what now? Obviously we can't have the unit running at the wrong angle, otherwise it will look like he's sliding when the animation plays in-game. In order to help us avoid that potential pitfall, let's draw a three-dimensional graph to visualize the direction in which the unit will be running:&lt;br /&gt;
&lt;br /&gt;
http://img18.imageshack.us/img18/5393/73920527.png&lt;br /&gt;
&lt;br /&gt;
Viola! When in doubt, draw a graph. As you can see, we want our unit to run down the X axis (the red line) in order to reach the adjacent hex. If we were creating a north-east/north-west running animation, we would want the unit to run up the Y axis (the pink line). For now, however, let's stick with the south-east/south-west animation down the X axis. &lt;br /&gt;
&lt;br /&gt;
So this is the path we want our unit to take during the animation:&lt;br /&gt;
&lt;br /&gt;
http://img842.imageshack.us/img842/7556/howtogetthere.png&lt;br /&gt;
&lt;br /&gt;
In terms of individual pixels, the line that shows the path our subject will take has a pixel angle of &amp;quot;two over, down one, over one, repeat&amp;quot;, that is to say, over two pixels, down and over one pixel, then over two pixels again, down and over one pixel again, etc. To illustrate:&lt;br /&gt;
&lt;br /&gt;
http://img94.imageshack.us/img94/1418/pixelangleinstance.png&lt;br /&gt;
&lt;br /&gt;
It may be helpful for some to have the line be two pixels tall rather than only a single pixel tall, as I did in the first three images above. Note that the same angle still applies. Think of it as just placing another single-pixel-tall line on top of our existing single-pixel-tall line, like so:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http://img717.imageshack.us/img717/9810/thickerline.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, now we've established the direction in which our subject will be moving and the path the subject will be taking. We've even set up a helpful guideline to make sure the subject doesn't accidentally wander off that path at some point during the animation. Having gotten this step out of the way, let's talk about the perspective of your animation.&lt;br /&gt;
&lt;br /&gt;
===Perspective===&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Planning Your Animation==&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Details, Details, Details==&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Testing Your Animation==&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Artisticdude&amp;diff=49625</id>
		<title>User:Artisticdude</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Artisticdude&amp;diff=49625"/>
		<updated>2013-04-04T18:22:03Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Direction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''WIP Links:'''&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
*[http://wiki.wesnoth.org/WML_for_Complete_Beginners '''WIP template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial''']&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Template for future &amp;quot;Animating Running Cycles&amp;quot; tutorial&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
=Animating Running Cycles=&lt;br /&gt;
by [http://forums.wesnoth.org/memberlist.php?mode=viewprofile&amp;amp;u=119614 artisticdude]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Note: This is a work in progress.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
I've heard some people say that running cycles are the hardest animation to make. Personally, I disagree with this notion. Running animations involve a lot of work, more so than most other animations (attack, death, defense, etc.), but generally running animations follow a very strict set of rules. Once you fully understand these rules, creating running animations should be little more than investing enough time to see it through.&lt;br /&gt;
&lt;br /&gt;
Note that I assume at least some level of competence in pixel art and animating throughout this tutorial. I also assume that the graphics program you are using supports layers and transparency, although those features are not strictly necessary in order to create a running animation. If you haven't already, I suggest reading the [[Basic Animation Tutorial]] and [[From Base Frame To Full Animation]] before reading this page further.&lt;br /&gt;
&lt;br /&gt;
In this tutorial, I will demonstrate how to create a standard south-east/south-west facing run cycle by using the Goblin Impaler unit from mainline. Running cycles for different directions (north-east/north-west, south, &amp;amp; north) are drawn at different angles, but the concepts and theories discussed here apply to running cycles in all directions.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: The Theory Behind Running Cycles==&lt;br /&gt;
&lt;br /&gt;
===Poses===&lt;br /&gt;
&lt;br /&gt;
Wesnoth running cycles are split into four distinct poses. Not frames, ''poses'', as in anatomical positions. These positions are:&lt;br /&gt;
* Contact&lt;br /&gt;
* Recoil&lt;br /&gt;
* Passing&lt;br /&gt;
* High Point&lt;br /&gt;
&lt;br /&gt;
===Rotation===&lt;br /&gt;
&lt;br /&gt;
As you may have noticed in the poses example above, there is a a certain amount of rotation happening over the course of the animation in the hips and shoulder areas. If you &lt;br /&gt;
&lt;br /&gt;
===Bobbing===&lt;br /&gt;
&lt;br /&gt;
===Movement Arcs===&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: Understanding Your Subject==&lt;br /&gt;
This is the most important part of the animation. You can come up with eight beautiful frames for your animation, but if those frames don't read as a realistic and fluid motion when played together as an animation, you might as well have just doodled random scribbles instead. Understanding your subject's anatomy, equipment, and weight will help you immensely in creating a realistic and fluid animation.&lt;br /&gt;
&lt;br /&gt;
===Anatomy===&lt;br /&gt;
&lt;br /&gt;
It is vital to any animation that you understand your subject's anatomy: where their joints are located, how far and in what direction those joints can bend and/or twist, whether there is a bone beneath the surface of a certain area or whether that area is composed of flexible membrane, etc. etc. This is especially important if your subject is not humanoid, but even for humanoids with non-human appendages or modified human appendages (tails, enormous ears, an extra set of arms, etc.). Before you even open your graphic editing program, study the baseframe of your subject and learn as much as you can about its anatomy. Find and study references, both still images and videos, if possible. Even creatures that don't have any real-world counterparts to study often have anatomical structures similar to those of real-world creatures. &lt;br /&gt;
&lt;br /&gt;
===Equipment===&lt;br /&gt;
&lt;br /&gt;
In addition to anatomy, it is paramount that you understand the equipment your subject is wearing/holding, since this will have a significant impact on how the character actually moves. I follow a list of simple steps to help me understand the equipment of the subject, in the form of a series of questions:&lt;br /&gt;
&lt;br /&gt;
*'''What exactly is each piece of equipment?'''&lt;br /&gt;
Most of the time it will be fairly obvious what each piece of equipment on your subject is (it's really hard to mistake a properly-drawn sword for a toothbrush), but there will be occasions where you won't be able to decide what that blue dot at the side of the subject's waist is.&lt;br /&gt;
*'''What is the three-dimensional shape of each piece of equipment?'''&lt;br /&gt;
*'''What is each piece of equipment made of?'''&lt;br /&gt;
**'''How flexible/rigid is that material?''' Obviously a cloth tunic will have different dynamics than a solid metal breastplate.&lt;br /&gt;
*'''How much does weight is the subject carrying?'''&lt;br /&gt;
Weight is a huge factor in animations. How you convey that weight in your animation can either make your subject look light and etherial, or heavy and ponderous. If you're animating a fairy, chances are the subject's movements will be swift and graceful. Likewise, if you're animating a troll warrior, the subject's movements are likely to be clumsier and more ponderous. The movement of your subject will also be heavily influenced by the weight of their equipment; for instance, an elf in lightweight leather armor will be able to move much faster and easier compared to a human wearing a suit of heavy steel armor. In order to produce a convincing animation, you will need to make sure you know approximately how much weight your subject is dealing with.&lt;br /&gt;
&lt;br /&gt;
Note that these questions are only to assist in drawing the motion of the object, not in drawing the object itself. To successfully draw and shade an object well, you must ask many additional questions which I won't go into here. If you do not know how to shade an object, I suggest you stop reading this page right now and do more reading up and practice on the subject before continuing.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: Direction and Perspective==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Direction===&lt;br /&gt;
&lt;br /&gt;
So now that we understand how the character should move, it's time to start planning the direction of the movment. In this case, since we're doing a south-east running animation, we have to have the subject move from one hex to the neighboring south-east hex:&lt;br /&gt;
&lt;br /&gt;
http://img51.imageshack.us/img51/6304/atob.png&lt;br /&gt;
&lt;br /&gt;
So what now? Obviously we can't have the unit running at the wrong angle, otherwise it will look like he's sliding when the animation plays in-game. In order to help us avoid that potential pitfall, let's draw a three-dimensional graph to visualize the direction in which the unit will be running:&lt;br /&gt;
&lt;br /&gt;
http://img18.imageshack.us/img18/5393/73920527.png&lt;br /&gt;
&lt;br /&gt;
Viola! When in doubt, draw a graph. As you can see, we want our unit to run down the X axis (the red line) in order to reach the adjacent hex. If we were creating a north-east/north-west running animation, we would want the unit to run up the Y axis (the pink line). For now, however, let's stick with the south-east/south-west animation down the X axis. &lt;br /&gt;
&lt;br /&gt;
So this is the path we want our unit to take during the animation:&lt;br /&gt;
&lt;br /&gt;
http://img842.imageshack.us/img842/7556/howtogetthere.png&lt;br /&gt;
&lt;br /&gt;
In terms of individual pixels, the line that shows the path our subject will take has a pixel angle of &amp;quot;two over, down one, over one, repeat&amp;quot;, that is to say, over two pixels, down and over one pixel, then over two pixels again, down and over one pixel again, etc. To illustrate:&lt;br /&gt;
&lt;br /&gt;
http://img94.imageshack.us/img94/1418/pixelangleinstance.png&lt;br /&gt;
&lt;br /&gt;
It may be helpful for some to have the line be two pixels tall rather than only a single pixel tall, as I did in the first three images above. Note that the same angle still applies. Think of it as just placing another single-pixel-tall line on top of our existing single-pixel-tall line, like so:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http://img717.imageshack.us/img717/9810/thickerline.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, now we've established the direction in which our subject will be moving and the path the subject will be taking. We've even set up a helpful guideline to make sure the subject doesn't accidentally wander off that path at some point during the animation. Having gotten this step out of the way, let's talk about the perspective of your animation.&lt;br /&gt;
&lt;br /&gt;
===Perspective===&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Planning Your Animation==&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Details, Details, Details==&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Testing Your Animation==&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Artisticdude&amp;diff=49624</id>
		<title>User:Artisticdude</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Artisticdude&amp;diff=49624"/>
		<updated>2013-04-04T18:10:43Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Chapter 2: Understanding Your Subject */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''WIP Links:'''&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
*[http://wiki.wesnoth.org/WML_for_Complete_Beginners '''WIP template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial''']&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Template for future &amp;quot;Animating Running Cycles&amp;quot; tutorial&lt;br /&gt;
&lt;br /&gt;
--------------------&lt;br /&gt;
&lt;br /&gt;
=Animating Running Cycles=&lt;br /&gt;
by [http://forums.wesnoth.org/memberlist.php?mode=viewprofile&amp;amp;u=119614 artisticdude]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Note: This is a work in progress.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
I've heard some people say that running cycles are the hardest animation to make. Personally, I disagree with this notion. Running animations involve a lot of work, more so than most other animations (attack, death, defense, etc.), but generally running animations follow a very strict set of rules. Once you fully understand these rules, creating running animations should be little more than investing enough time to see it through.&lt;br /&gt;
&lt;br /&gt;
Note that I assume at least some level of competence in pixel art and animating throughout this tutorial. I also assume that the graphics program you are using supports layers and transparency, although those features are not strictly necessary in order to create a running animation. If you haven't already, I suggest reading the [[Basic Animation Tutorial]] and [[From Base Frame To Full Animation]] before reading this page further.&lt;br /&gt;
&lt;br /&gt;
In this tutorial, I will demonstrate how to create a standard south-east/south-west facing run cycle by using the Goblin Impaler unit from mainline. Running cycles for different directions (north-east/north-west, south, &amp;amp; north) are drawn at different angles, but the concepts and theories discussed here apply to running cycles in all directions.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: The Theory Behind Running Cycles==&lt;br /&gt;
&lt;br /&gt;
===Poses===&lt;br /&gt;
&lt;br /&gt;
Wesnoth running cycles are split into four distinct poses. Not frames, ''poses'', as in anatomical positions. These positions are:&lt;br /&gt;
* Contact&lt;br /&gt;
* Recoil&lt;br /&gt;
* Passing&lt;br /&gt;
* High Point&lt;br /&gt;
&lt;br /&gt;
===Rotation===&lt;br /&gt;
&lt;br /&gt;
As you may have noticed in the poses example above, there is a a certain amount of rotation happening over the course of the animation in the hips and shoulder areas. If you &lt;br /&gt;
&lt;br /&gt;
===Bobbing===&lt;br /&gt;
&lt;br /&gt;
===Movement Arcs===&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: Understanding Your Subject==&lt;br /&gt;
This is the most important part of the animation. You can come up with eight beautiful frames for your animation, but if those frames don't read as a realistic and fluid motion when played together as an animation, you might as well have just doodled random scribbles instead. Understanding your subject's anatomy, equipment, and weight will help you immensely in creating a realistic and fluid animation.&lt;br /&gt;
&lt;br /&gt;
===Anatomy===&lt;br /&gt;
&lt;br /&gt;
It is vital to any animation that you understand your subject's anatomy: where their joints are located, how far and in what direction those joints can bend and/or twist, whether there is a bone beneath the surface of a certain area or whether that area is composed of flexible membrane, etc. etc. This is especially important if your subject is not humanoid, but even for humanoids with non-human appendages or modified human appendages (tails, enormous ears, an extra set of arms, etc.). Before you even open your graphic editing program, study the baseframe of your subject and learn as much as you can about its anatomy. Find and study references, both still images and videos, if possible. Even creatures that don't have any real-world counterparts to study often have anatomical structures similar to those of real-world creatures. &lt;br /&gt;
&lt;br /&gt;
===Equipment===&lt;br /&gt;
&lt;br /&gt;
In addition to anatomy, it is paramount that you understand the equipment your subject is wearing/holding, since this will have a significant impact on how the character actually moves. I follow a list of simple steps to help me understand the equipment of the subject, in the form of a series of questions:&lt;br /&gt;
&lt;br /&gt;
*'''What exactly is each piece of equipment?'''&lt;br /&gt;
Most of the time it will be fairly obvious what each piece of equipment on your subject is (it's really hard to mistake a properly-drawn sword for a toothbrush), but there will be occasions where you won't be able to decide what that blue dot at the side of the subject's waist is.&lt;br /&gt;
*'''What is the three-dimensional shape of each piece of equipment?'''&lt;br /&gt;
*'''What is each piece of equipment made of?'''&lt;br /&gt;
**'''How flexible/rigid is that material?''' Obviously a cloth tunic will have different dynamics than a solid metal breastplate.&lt;br /&gt;
*'''How much does weight is the subject carrying?'''&lt;br /&gt;
Weight is a huge factor in animations. How you convey that weight in your animation can either make your subject look light and etherial, or heavy and ponderous. If you're animating a fairy, chances are the subject's movements will be swift and graceful. Likewise, if you're animating a troll warrior, the subject's movements are likely to be clumsier and more ponderous. The movement of your subject will also be heavily influenced by the weight of their equipment; for instance, an elf in lightweight leather armor will be able to move much faster and easier compared to a human wearing a suit of heavy steel armor. In order to produce a convincing animation, you will need to make sure you know approximately how much weight your subject is dealing with.&lt;br /&gt;
&lt;br /&gt;
Note that these questions are only to assist in drawing the motion of the object, not in drawing the object itself. To successfully draw and shade an object well, you must ask many additional questions which I won't go into here. If you do not know how to shade an object, I suggest you stop reading this page right now and do more reading up and practice on the subject before continuing.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: Direction and Perspective==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Direction===&lt;br /&gt;
&lt;br /&gt;
So now that we understand how the character should move, it's time to start planning the direction of the movment. In this case, we have to have the subject move from one hex to the neighboring south-east hex, from point A to point B.&lt;br /&gt;
&lt;br /&gt;
http://img51.imageshack.us/img51/6304/atob.png&lt;br /&gt;
&lt;br /&gt;
So what now? Obviously we can't have the unit running at the wrong angle, otherwise it will look like he's sliding when the animation plays in-game. So let's draw a three-dimensional graph to visualize the direction in which the unit will be running:&lt;br /&gt;
&lt;br /&gt;
http://img18.imageshack.us/img18/5393/73920527.png&lt;br /&gt;
&lt;br /&gt;
As you can see, we want our unit to run down the X axis (the red line) in order to reach the adjacent hex. If we were creating a north-east/north-west running animation, we would want the unit to run up the Y axis (the pink line). For now, however, let's stick with the south-east/south-west animation down the X axis. &lt;br /&gt;
&lt;br /&gt;
So this is the path we want our unit to take during the animation:&lt;br /&gt;
&lt;br /&gt;
http://img842.imageshack.us/img842/7556/howtogetthere.png&lt;br /&gt;
&lt;br /&gt;
In terms of individual pixels, the line we used has a pixel angle of &amp;quot;two over, down one, over one, repeat&amp;quot;, that is to say, over two pixels, down and over one pixel, then over two pixels, down and over one pixel, etc. To illustrate:&lt;br /&gt;
&lt;br /&gt;
http://img94.imageshack.us/img94/1418/pixelangleinstance.png&lt;br /&gt;
&lt;br /&gt;
It may be helpful for some to have the line be two pixels tall rather than only a single pixel tall, as I did in the first three images above. The same angle still applies, however. Think of it as just placing another single-pixel-tall line on top of another single-pixel-tall line, like so:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http://img717.imageshack.us/img717/9810/thickerline.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You have now established the direction in which your unit will be moving and facing. You have even set up a helpful guideline to make sure you don't accidentally stray from that direction at some point during the animation process. So now that you have determined the direction, let's talk about the perspective of your animation.&lt;br /&gt;
&lt;br /&gt;
===Perspective===&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Planning Your Animation==&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Details, Details, Details==&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Testing Your Animation==&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=49618</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=49618"/>
		<updated>2013-04-02T17:43:18Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Introduction]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_1]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_2]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_3]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_4]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_5]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_6]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_7]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_8]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_9]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_10]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Chapter_11]]&lt;br /&gt;
&lt;br /&gt;
[[WML_for_Complete_Beginners:_Conclusion]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Introduction&amp;diff=49617</id>
		<title>WML for Complete Beginners: Introduction</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Introduction&amp;diff=49617"/>
		<updated>2013-04-02T17:40:40Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Introduction==  Hey there!  Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder about the purpose of this tutorial. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
The specific demographic for which this tutorial is intended is users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder paths and locate specific directories. In this tutorial you will learn the fundamentals of WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming in WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML (in fact, it is recommended that you ''avoid'' using those fancy word processors); a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without being required to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Conclusion&amp;diff=49616</id>
		<title>WML for Complete Beginners: Conclusion</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Conclusion&amp;diff=49616"/>
		<updated>2013-04-02T17:40:11Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Conclusion: Where to Go From Here==  As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the h…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_11&amp;diff=49615</id>
		<title>WML for Complete Beginners: Chapter 11</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_11&amp;diff=49615"/>
		<updated>2013-04-02T17:39:33Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 11: More Logic: Cases and Loops==  ===Cases===  Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to …'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without having to wade through a quagmire of if codeblocks. This is done via the switch/case codeblock, which tests the value of a variable for multiple conditions, and determines the action performed as a result of that evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
I was a very messy child, much to the distress of my mother, who was the epitome of cleanliness and couldn't for the life of her understand how she could have raised such an untidy child as me. Occasionally she'd work up enough courage to venture into the land of chaos that was my room, and then she'd tell me not leave my room until it was picked up.&lt;br /&gt;
&lt;br /&gt;
Okay, intimate family analogies aside, pay attention to how my mother told me to clean up my room: I was not to leave my room until it was clean. Whether or not the room was clean was the condition on which my permission to leave my room depended. So each time I put something away (which, more often then not, I did by stuffing the item under the bed), I would have to check to see that condition was met. If the room wasn't clean, then my mother's condition wasn't met and I had to keep cleaning. If the room was clean, then my mother's condition was met and I was free to leave my room.&lt;br /&gt;
&lt;br /&gt;
Talk about basic parts of loops, variations of loops (do/while, etc.)&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_10&amp;diff=49614</id>
		<title>WML for Complete Beginners: Chapter 10</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_10&amp;diff=49614"/>
		<updated>2013-04-02T17:39:08Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 10: Introduction to Logic==  ===If This, Then That===  Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk tow…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_9&amp;diff=49613</id>
		<title>WML for Complete Beginners: Chapter 9</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_9&amp;diff=49613"/>
		<updated>2013-04-02T17:38:37Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 9: Macros==  Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customer…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_8&amp;diff=49612</id>
		<title>WML for Complete Beginners: Chapter 8</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_8&amp;diff=49612"/>
		<updated>2013-04-02T17:38:18Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 8: Array, and Container Variables==  So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, t…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_7&amp;diff=49611</id>
		<title>WML for Complete Beginners: Chapter 7</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_7&amp;diff=49611"/>
		<updated>2013-04-02T17:37:55Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 7: Introduction to Variables==  Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new hom…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_6&amp;diff=49610</id>
		<title>WML for Complete Beginners: Chapter 6</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_6&amp;diff=49610"/>
		<updated>2013-04-02T17:37:30Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 6: Building and Including a Custom Unit==  Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custo…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.&lt;br /&gt;
&lt;br /&gt;
===Creating Your Custom Unit's .cfg File===&lt;br /&gt;
&lt;br /&gt;
===Including the Custom Unit In Your Campaign===&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_5&amp;diff=49609</id>
		<title>WML for Complete Beginners: Chapter 5</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_5&amp;diff=49609"/>
		<updated>2013-04-02T17:37:06Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 5: Events==  Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_4&amp;diff=49608</id>
		<title>WML for Complete Beginners: Chapter 4</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_4&amp;diff=49608"/>
		<updated>2013-04-02T17:36:38Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 4: Creating Your First Scenario==  Now that you have your _main.cfg file, it's time to create your first scenario.  ===Creating the Scenario Map===  All scenarios requi…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_3&amp;diff=49607</id>
		<title>WML for Complete Beginners: Chapter 3</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_3&amp;diff=49607"/>
		<updated>2013-04-02T17:35:56Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 3: The _main.cfg==  Note: this page borrows heavily from the BuildingCampaignsTheCampaignFile page.  So we've created a campaign folder, but as of yet the game does…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_2&amp;diff=49606</id>
		<title>WML for Complete Beginners: Chapter 2</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_2&amp;diff=49606"/>
		<updated>2013-04-02T17:35:12Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 2: The Userdata Directory and the Campaign Folder==  So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_first_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49605</id>
		<title>WML for Complete Beginners: Chapter 1</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners:_Chapter_1&amp;diff=49605"/>
		<updated>2013-04-02T17:34:44Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Created page with '==Chapter 1: Syntax==  First things first; let's go over the ''syntax'' of WML.  For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of r…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try using capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:Nesuworjoni420&amp;diff=49601</id>
		<title>User:Nesuworjoni420</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:Nesuworjoni420&amp;diff=49601"/>
		<updated>2013-04-02T04:14:15Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:UFJAbby&amp;diff=49600</id>
		<title>User:UFJAbby</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:UFJAbby&amp;diff=49600"/>
		<updated>2013-04-02T04:13:39Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=User:ValerieLu&amp;diff=49599</id>
		<title>User:ValerieLu</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=User:ValerieLu&amp;diff=49599"/>
		<updated>2013-04-02T04:13:15Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create&amp;diff=49593</id>
		<title>Create</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create&amp;diff=49593"/>
		<updated>2013-04-02T03:57:41Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* What can I create, and how? */ &amp;quot;campaign server&amp;quot; -&amp;gt; &amp;quot;add-on server&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Create/Translations}}&lt;br /&gt;
{| style=&amp;quot;float:right&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Interested in creating your own scenarios and campaigns?  One of Wesnoth's best features is its extensibility.  Players can create new maps, units, races, scenarios, art, music, and even entire campaigns.  Access to the &amp;quot;guts&amp;quot; of the game is both simple and difficult; if you have a UTF-8 text editor you have everything you need to build your own world.  However, learning the Wesnoth Markup Language (WML) takes some effort.  This section will guide you through the process of creating and distributing your own content.&lt;br /&gt;
&lt;br /&gt;
== Read this first! ==&lt;br /&gt;
Before you modify or add anything, it is important to understand how the game stores and organizes its data.  This article will explain the game's directory structure and introduce the ''userdata'' directory.&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
&lt;br /&gt;
== What can I create, and how? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- artisticdude: As of 2/4/12, the screenshot was updated to 1.10 (it had been at least 1.6, possibly even earlier). Links to previous screenshots (main image and thumb): http://www.wesnoth.org/images/sshots/wesnoth-1.4-4.jpg http://www.wesnoth.org/images/sshots/wesnoth-1.4-4-175.jpg --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;thumb tright&amp;quot;&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
[http://img837.imageshack.us/img837/865/screenshot20120205at529.png http://img26.imageshack.us/img26/8613/thumbhav.png]&lt;br /&gt;
&amp;lt;div class=&amp;quot;thumbcaption&amp;quot;&amp;gt;Battle for Wesnoth 1.10 map editor&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[BuildingMaps|Maps]] - the layout of terrain tiles&lt;br /&gt;
&lt;br /&gt;
* [[BuildingScenarios|Scenarios]] - a scenario makes things happen on a map, making it playable&lt;br /&gt;
* [[BuildingCampaigns|Campaigns]] - how to put it all together into a campaign&lt;br /&gt;
* [[BuildingMultiplayer|Multiplayer Maps and Scenarios]] - a specialized look at maps and scenarios '''(outdated)'''&lt;br /&gt;
* [[MultiplayerCampaigns|Multiplayer Campaigns]] - making a campaign accessible in multiplayer '''(outdated)'''&lt;br /&gt;
* [[BuildingUnits|Units]]&lt;br /&gt;
* [[BuildingFactions|Multiplayer factions and eras]]&lt;br /&gt;
&lt;br /&gt;
* [[Create Art|Art]] - complete with '''tutorials!'''&lt;br /&gt;
* [[Create Music|Music]]&lt;br /&gt;
* [[Create Writing|Writing]]&lt;br /&gt;
* [[WesnothTranslations|Translations]] - work on translating Wesnoth&lt;br /&gt;
* [[Practical Guide to Modifying AI Behavior|Artificial Intelligence]] - how to create and modify AI behaviour &lt;br /&gt;
&lt;br /&gt;
* [[Distributing content]] - all about the add-on server&lt;br /&gt;
* [[Authoring tools]] - tools for helping you write campaign WML&lt;br /&gt;
* [[Maintenance tools]] - tools for helping you sanity-check and maintain campaigns&lt;br /&gt;
&amp;lt;!-- artisticdude: This next link serves no real purpose, it can probably be deleted entirely. For now, I'm hiding it as a comment. --&amp;gt;&lt;br /&gt;
&amp;lt;!-- * [[Clueless Guides]] - half-baked guides that wait for improvement --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What have others done? ==&lt;br /&gt;
&lt;br /&gt;
There is a multitude of multiplayer factions and eras, multiplayer maps and discussion of campaigns on the [http://www.wesnoth.org/forum Wesnoth forum]&lt;br /&gt;
* [http://forums.wesnoth.org/viewforum.php?f=19 Faction and Era Development forum]&lt;br /&gt;
* [http://www.wesnoth.org/forum/viewforum.php?f=15 Multiplayer Development forum]&lt;br /&gt;
* [http://www.wesnoth.org/forum/viewforum.php?f=8 Scenario and Campaign Development forum]&lt;br /&gt;
* [[Faction|Complete faction list]]&lt;br /&gt;
&lt;br /&gt;
If you want to be creative without having to invent an entire new campaign, &lt;br /&gt;
see this thread on [http://www.wesnoth.org/forum/viewtopic.php?t=17171 abandoned campaigns].  You should be able to pick one of these up and complete it with much less effort than doing an all-new one.&lt;br /&gt;
&lt;br /&gt;
== The world of Wesnoth ==&lt;br /&gt;
Not all campaigns take place in Wesnoth, but many do.  There is definitely a certain flavor to campaigns that are intended to take place somewhere in the world of Wesnoth.  Stake out a time period or a map locale and tell a story.&lt;br /&gt;
* [[Timeline of Wesnoth|The timeline of Wesnoth]]&lt;br /&gt;
* [[Geography of Wesnoth|The geography of Wesnoth]]&lt;br /&gt;
* [[Races|The races of creatures in Wesnoth]]&lt;br /&gt;
* [[Poetry of Wesnoth|Wesnothian poetry]]&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
* [[ExternalUtilities| External Utilities]] - some extra tools for easier creating stuff&lt;br /&gt;
* [[ReferenceWML|WML Reference]] - a quicklink&lt;br /&gt;
* [[FAQ#Maps.2C_Scenarios_and_Campaigns|FAQ]] - if you have a question, post it&lt;br /&gt;
* ADDON SERVER [http://addons.wesnoth.org web interface] - An alternate way to download user made content&lt;br /&gt;
&lt;br /&gt;
[[Category:Create|*]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create&amp;diff=49592</id>
		<title>Create</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create&amp;diff=49592"/>
		<updated>2013-04-02T03:54:17Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: On second thought, just remove any mention of the to-do art, since we don't have a current list of to-do projects&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Create/Translations}}&lt;br /&gt;
{| style=&amp;quot;float:right&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Interested in creating your own scenarios and campaigns?  One of Wesnoth's best features is its extensibility.  Players can create new maps, units, races, scenarios, art, music, and even entire campaigns.  Access to the &amp;quot;guts&amp;quot; of the game is both simple and difficult; if you have a UTF-8 text editor you have everything you need to build your own world.  However, learning the Wesnoth Markup Language (WML) takes some effort.  This section will guide you through the process of creating and distributing your own content.&lt;br /&gt;
&lt;br /&gt;
== Read this first! ==&lt;br /&gt;
Before you modify or add anything, it is important to understand how the game stores and organizes its data.  This article will explain the game's directory structure and introduce the ''userdata'' directory.&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
&lt;br /&gt;
== What can I create, and how? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- artisticdude: As of 2/4/12, the screenshot was updated to 1.10 (it had been at least 1.6, possibly even earlier). Links to previous screenshots (main image and thumb): http://www.wesnoth.org/images/sshots/wesnoth-1.4-4.jpg http://www.wesnoth.org/images/sshots/wesnoth-1.4-4-175.jpg --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;thumb tright&amp;quot;&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
[http://img837.imageshack.us/img837/865/screenshot20120205at529.png http://img26.imageshack.us/img26/8613/thumbhav.png]&lt;br /&gt;
&amp;lt;div class=&amp;quot;thumbcaption&amp;quot;&amp;gt;Battle for Wesnoth 1.10 map editor&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[BuildingMaps|Maps]] - the layout of terrain tiles&lt;br /&gt;
&lt;br /&gt;
* [[BuildingScenarios|Scenarios]] - a scenario makes things happen on a map, making it playable&lt;br /&gt;
* [[BuildingCampaigns|Campaigns]] - how to put it all together into a campaign&lt;br /&gt;
* [[BuildingMultiplayer|Multiplayer Maps and Scenarios]] - a specialized look at maps and scenarios '''(outdated)'''&lt;br /&gt;
* [[MultiplayerCampaigns|Multiplayer Campaigns]] - making a campaign accessible in multiplayer '''(outdated)'''&lt;br /&gt;
* [[BuildingUnits|Units]]&lt;br /&gt;
* [[BuildingFactions|Multiplayer factions and eras]]&lt;br /&gt;
&lt;br /&gt;
* [[Create Art|Art]] - complete with '''tutorials!'''&lt;br /&gt;
* [[Create Music|Music]]&lt;br /&gt;
* [[Create Writing|Writing]]&lt;br /&gt;
* [[WesnothTranslations|Translations]] - work on translating Wesnoth&lt;br /&gt;
* [[Practical Guide to Modifying AI Behavior|Artificial Intelligence]] - how to create and modify AI behaviour &lt;br /&gt;
&lt;br /&gt;
* [[Distributing content]] - all about the campaign server&lt;br /&gt;
* [[Authoring tools]] - tools for helping you write campaign WML&lt;br /&gt;
* [[Maintenance tools]] - tools for helping you sanity-check and maintain campaigns&lt;br /&gt;
&amp;lt;!-- artisticdude: This next link serves no real purpose, it can probably be deleted entirely. For now, I'm hiding it as a comment. --&amp;gt;&lt;br /&gt;
&amp;lt;!-- * [[Clueless Guides]] - half-baked guides that wait for improvement --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What have others done? ==&lt;br /&gt;
&lt;br /&gt;
There is a multitude of multiplayer factions and eras, multiplayer maps and discussion of campaigns on the [http://www.wesnoth.org/forum Wesnoth forum]&lt;br /&gt;
* [http://forums.wesnoth.org/viewforum.php?f=19 Faction and Era Development forum]&lt;br /&gt;
* [http://www.wesnoth.org/forum/viewforum.php?f=15 Multiplayer Development forum]&lt;br /&gt;
* [http://www.wesnoth.org/forum/viewforum.php?f=8 Scenario and Campaign Development forum]&lt;br /&gt;
* [[Faction|Complete faction list]]&lt;br /&gt;
&lt;br /&gt;
If you want to be creative without having to invent an entire new campaign, &lt;br /&gt;
see this thread on [http://www.wesnoth.org/forum/viewtopic.php?t=17171 abandoned campaigns].  You should be able to pick one of these up and complete it with much less effort than doing an all-new one.&lt;br /&gt;
&lt;br /&gt;
== The world of Wesnoth ==&lt;br /&gt;
Not all campaigns take place in Wesnoth, but many do.  There is definitely a certain flavor to campaigns that are intended to take place somewhere in the world of Wesnoth.  Stake out a time period or a map locale and tell a story.&lt;br /&gt;
* [[Timeline of Wesnoth|The timeline of Wesnoth]]&lt;br /&gt;
* [[Geography of Wesnoth|The geography of Wesnoth]]&lt;br /&gt;
* [[Races|The races of creatures in Wesnoth]]&lt;br /&gt;
* [[Poetry of Wesnoth|Wesnothian poetry]]&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
* [[ExternalUtilities| External Utilities]] - some extra tools for easier creating stuff&lt;br /&gt;
* [[ReferenceWML|WML Reference]] - a quicklink&lt;br /&gt;
* [[FAQ#Maps.2C_Scenarios_and_Campaigns|FAQ]] - if you have a question, post it&lt;br /&gt;
* ADDON SERVER [http://addons.wesnoth.org web interface] - An alternate way to download user made content&lt;br /&gt;
&lt;br /&gt;
[[Category:Create|*]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create&amp;diff=49591</id>
		<title>Create</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create&amp;diff=49591"/>
		<updated>2013-04-02T03:53:00Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Removed reference to a (severely) obsolete list of to-do art projects&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Create/Translations}}&lt;br /&gt;
{| style=&amp;quot;float:right&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Interested in creating your own scenarios and campaigns?  One of Wesnoth's best features is its extensibility.  Players can create new maps, units, races, scenarios, art, music, and even entire campaigns.  Access to the &amp;quot;guts&amp;quot; of the game is both simple and difficult; if you have a UTF-8 text editor you have everything you need to build your own world.  However, learning the Wesnoth Markup Language (WML) takes some effort.  This section will guide you through the process of creating and distributing your own content.&lt;br /&gt;
&lt;br /&gt;
It should also be noted that '''we need a lot of help creating artwork for the core of the game.''' We'll happily help you out, if you take a swing at them.&lt;br /&gt;
&lt;br /&gt;
== Read this first! ==&lt;br /&gt;
Before you modify or add anything, it is important to understand how the game stores and organizes its data.  This article will explain the game's directory structure and introduce the ''userdata'' directory.&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
&lt;br /&gt;
== What can I create, and how? ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- artisticdude: As of 2/4/12, the screenshot was updated to 1.10 (it had been at least 1.6, possibly even earlier). Links to previous screenshots (main image and thumb): http://www.wesnoth.org/images/sshots/wesnoth-1.4-4.jpg http://www.wesnoth.org/images/sshots/wesnoth-1.4-4-175.jpg --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;thumb tright&amp;quot;&amp;gt;&amp;lt;div&amp;gt;&lt;br /&gt;
[http://img837.imageshack.us/img837/865/screenshot20120205at529.png http://img26.imageshack.us/img26/8613/thumbhav.png]&lt;br /&gt;
&amp;lt;div class=&amp;quot;thumbcaption&amp;quot;&amp;gt;Battle for Wesnoth 1.10 map editor&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[BuildingMaps|Maps]] - the layout of terrain tiles&lt;br /&gt;
&lt;br /&gt;
* [[BuildingScenarios|Scenarios]] - a scenario makes things happen on a map, making it playable&lt;br /&gt;
* [[BuildingCampaigns|Campaigns]] - how to put it all together into a campaign&lt;br /&gt;
* [[BuildingMultiplayer|Multiplayer Maps and Scenarios]] - a specialized look at maps and scenarios '''(outdated)'''&lt;br /&gt;
* [[MultiplayerCampaigns|Multiplayer Campaigns]] - making a campaign accessible in multiplayer '''(outdated)'''&lt;br /&gt;
* [[BuildingUnits|Units]]&lt;br /&gt;
* [[BuildingFactions|Multiplayer factions and eras]]&lt;br /&gt;
&lt;br /&gt;
* [[Create Art|Art]] - complete with '''tutorials!'''&lt;br /&gt;
* [[Create Music|Music]]&lt;br /&gt;
* [[Create Writing|Writing]]&lt;br /&gt;
* [[WesnothTranslations|Translations]] - work on translating Wesnoth&lt;br /&gt;
* [[Practical Guide to Modifying AI Behavior|Artificial Intelligence]] - how to create and modify AI behaviour &lt;br /&gt;
&lt;br /&gt;
* [[Distributing content]] - all about the campaign server&lt;br /&gt;
* [[Authoring tools]] - tools for helping you write campaign WML&lt;br /&gt;
* [[Maintenance tools]] - tools for helping you sanity-check and maintain campaigns&lt;br /&gt;
&amp;lt;!-- artisticdude: This next link serves no real purpose, it can probably be deleted entirely. For now, I'm hiding it as a comment. --&amp;gt;&lt;br /&gt;
&amp;lt;!-- * [[Clueless Guides]] - half-baked guides that wait for improvement --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What have others done? ==&lt;br /&gt;
&lt;br /&gt;
There is a multitude of multiplayer factions and eras, multiplayer maps and discussion of campaigns on the [http://www.wesnoth.org/forum Wesnoth forum]&lt;br /&gt;
* [http://forums.wesnoth.org/viewforum.php?f=19 Faction and Era Development forum]&lt;br /&gt;
* [http://www.wesnoth.org/forum/viewforum.php?f=15 Multiplayer Development forum]&lt;br /&gt;
* [http://www.wesnoth.org/forum/viewforum.php?f=8 Scenario and Campaign Development forum]&lt;br /&gt;
* [[Faction|Complete faction list]]&lt;br /&gt;
&lt;br /&gt;
If you want to be creative without having to invent an entire new campaign, &lt;br /&gt;
see this thread on [http://www.wesnoth.org/forum/viewtopic.php?t=17171 abandoned campaigns].  You should be able to pick one of these up and complete it with much less effort than doing an all-new one.&lt;br /&gt;
&lt;br /&gt;
== The world of Wesnoth ==&lt;br /&gt;
Not all campaigns take place in Wesnoth, but many do.  There is definitely a certain flavor to campaigns that are intended to take place somewhere in the world of Wesnoth.  Stake out a time period or a map locale and tell a story.&lt;br /&gt;
* [[Timeline of Wesnoth|The timeline of Wesnoth]]&lt;br /&gt;
* [[Geography of Wesnoth|The geography of Wesnoth]]&lt;br /&gt;
* [[Races|The races of creatures in Wesnoth]]&lt;br /&gt;
* [[Poetry of Wesnoth|Wesnothian poetry]]&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
* [[ExternalUtilities| External Utilities]] - some extra tools for easier creating stuff&lt;br /&gt;
* [[ReferenceWML|WML Reference]] - a quicklink&lt;br /&gt;
* [[FAQ#Maps.2C_Scenarios_and_Campaigns|FAQ]] - if you have a question, post it&lt;br /&gt;
* ADDON SERVER [http://addons.wesnoth.org web interface] - An alternate way to download user made content&lt;br /&gt;
&lt;br /&gt;
[[Category:Create|*]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaWML&amp;diff=49588</id>
		<title>LuaWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaWML&amp;diff=49588"/>
		<updated>2013-04-02T03:32:00Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Interface to the engine and helper functions */ Minor rephrasing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
== The '''[lua]''' tag ==&lt;br /&gt;
&lt;br /&gt;
This tag is a part of [[ActionWML]], thus can be used inside [event] and at other places where [[ActionWML]] can be used. It makes it possible to write actions with the [http://www.lua.org Lua 5.2] language.&lt;br /&gt;
&lt;br /&gt;
The tag supports only the '''code''' key, which is a string containing the Lua scripts. Since Lua makes usage of the quotes and the { and } symbols, it is certainly wise to enclose the script between stronger quotes, as they prevent the preprocessor from performing macro expansion and tokenization.&lt;br /&gt;
&lt;br /&gt;
 [lua]&lt;br /&gt;
     code = &amp;lt;&amp;lt; wesnoth.message &amp;quot;Hello World!&amp;quot; &amp;gt;&amp;gt;&lt;br /&gt;
 [/lua]&lt;br /&gt;
&lt;br /&gt;
The Lua kernel can also be accessed from the [[CommandMode|command mode]]:&lt;br /&gt;
&lt;br /&gt;
 :lua local u = wesnoth.get_units({ id = &amp;quot;Konrad&amp;quot; })[1]; u.moves = 5&lt;br /&gt;
&lt;br /&gt;
The '''[args]''' sub-tag can be used to pass a WML object to the script via its variadic local variable &amp;quot;'''...'''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 [lua]&lt;br /&gt;
     code = &amp;lt;&amp;lt; local t = ...; wesnoth.message(tostring(t.text)) &amp;gt;&amp;gt;&lt;br /&gt;
     [args]&lt;br /&gt;
         text = _ &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
     [/args]&lt;br /&gt;
 [/lua]&lt;br /&gt;
&lt;br /&gt;
== Global environment ==&lt;br /&gt;
&lt;br /&gt;
All the Lua scripts of a scenario share the same global environment (aka Lua state). For instance, a function defined in an event can be used in all the events that happen after it.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name = preload&lt;br /&gt;
     first_time_only = no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             function narrator(t)&lt;br /&gt;
                 -- Behave like the [message] tag.&lt;br /&gt;
                 wesnoth.fire(&amp;quot;message&amp;quot;,&lt;br /&gt;
                   { speaker = &amp;quot;narrator&amp;quot;, message = t.sentence })&lt;br /&gt;
             end&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name = turn 1&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt; narrator(...) &amp;gt;&amp;gt;&lt;br /&gt;
         [args]&lt;br /&gt;
             sentence = _ &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
         [/args]&lt;br /&gt;
     [/lua]&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt; narrator(...) &amp;gt;&amp;gt;&lt;br /&gt;
         [args]&lt;br /&gt;
             sentence = _ &amp;quot;How are you today?&amp;quot;&lt;br /&gt;
         [/args]&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
In the example above, the redundant structure could be hidden behind macros. But it may be better to simply define a new WML tag.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name = preload&lt;br /&gt;
     first_time_only = no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             -- The function is now local, since its name does not have to be&lt;br /&gt;
             -- visible outside this Lua scripts.&lt;br /&gt;
             local function handler(t)&lt;br /&gt;
                 -- Behave like the [message] tag.&lt;br /&gt;
                 wesnoth.fire(&amp;quot;message&amp;quot;,&lt;br /&gt;
                   { speaker = &amp;quot;narrator&amp;quot;, message = t.sentence })&lt;br /&gt;
             end&lt;br /&gt;
             -- Create a new tag named [narrator].&lt;br /&gt;
             wesnoth.register_wml_action(&amp;quot;narrator&amp;quot;, handler)&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name = turn 1&lt;br /&gt;
     [narrator]&lt;br /&gt;
         sentence = _ &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
     [/narrator]&lt;br /&gt;
     [narrator]&lt;br /&gt;
         sentence = _ &amp;quot;How are you today?&amp;quot;&lt;br /&gt;
     [/narrator]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
The global environment is not preserved over save/load cycles. Therefore, storing values in the global environment is generally a bad idea (unless it has been redirected to WML variables, see [[LuaWML:Variables#set_wml_var_metatable|helper.set_wml_var_metatable]]). The only time assigning global variables (including function definitions) makes sense is during a [[EventWML#Predefined 'name' Key Values|preload]] event, as this event is always run. Therefore, helper functions defined at that time will be available to all the later scripts.&lt;br /&gt;
&lt;br /&gt;
The global environment initially contains the following modules: [http://www.lua.org/manual/5.1/manual.html#5.1 basic] (no name), [http://www.lua.org/manual/5.1/manual.html#5.4 string], [http://www.lua.org/manual/5.1/manual.html#5.5 table], and [http://www.lua.org/manual/5.1/manual.html#5.6 math]. A '''wesnoth''' module is also available, it provides access to the [[#Interface to the C++ engine|C++ engine]]. Additionally, the functions clock, date, time and difftime from the [http://www.lua.org/manual/5.1/manual.html#5.8 os] library (keep in mind that they aren't multiplayer- and replay-safe), as well as traceback from the [http://www.lua.org/manual/5.1/manual.html#5.9 debug] library are also available.&lt;br /&gt;
&lt;br /&gt;
At the start of a script, the variadic local variable '''...''' (three dots) is a proxy table representing [[#Encoding WML objects into Lua tables|WML data]]. This table is the content of the '''[args]''' sub-tag of the '''[lua]''' tag, if any.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
The following WML event is taken from Wesnoth' tutorial. It will serve as an example to present how Lua scripts are embedded into Wesnoth. The event is fired whenever a unit from side 1 (that is, the hero controlled by the user) moves to a tile that is not the one set in the WML variable ''target_hex''.&lt;br /&gt;
&lt;br /&gt;
 # General catch for them moving to the wrong place.&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [allow_undo][/allow_undo]&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=target_hex.is_set&lt;br /&gt;
             equals=yes&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [if]&lt;br /&gt;
                 [variable]&lt;br /&gt;
                     name=x1&lt;br /&gt;
                     equals=$target_hex.x&lt;br /&gt;
                 [/variable]&lt;br /&gt;
                 [variable]&lt;br /&gt;
                     name=y1&lt;br /&gt;
                     equals=$target_hex.y&lt;br /&gt;
                 [/variable]&lt;br /&gt;
                 [then]&lt;br /&gt;
                 [/then]&lt;br /&gt;
                 [else]&lt;br /&gt;
                     [redraw][/redraw]&lt;br /&gt;
                     [message]&lt;br /&gt;
                         speaker=narrator&lt;br /&gt;
                         message=_ &amp;quot;*Oops!&lt;br /&gt;
 You moved to the wrong place! After this message, you can press 'u' to undo, then try again.&amp;quot; +&lt;br /&gt;
                         _ &amp;quot;&lt;br /&gt;
 *Left click or press spacebar to continue...&amp;quot;&lt;br /&gt;
                     [/message]&lt;br /&gt;
                 [/else]&lt;br /&gt;
             [/if]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
A Lua script that performs the same action is presented below.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [allow_undo][/allow_undo]&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
 &lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             local event_data = wesnoth.current.event_context&lt;br /&gt;
             if target_hex.is_set and&lt;br /&gt;
                (event_data.x1 ~= target_hex.x or event_data.y1 ~= target_hex.y)&lt;br /&gt;
             then&lt;br /&gt;
                 W.redraw()&lt;br /&gt;
                 narrator_says(_ &amp;quot;*Oops!\nYou moved to the wrong place! After this message, you can press 'u' to undo, then try again.&amp;quot;)&lt;br /&gt;
             end&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Here is a more detailed explanation of the Lua code. Its first line&lt;br /&gt;
&lt;br /&gt;
 local event_data = wesnoth.current.event_context&lt;br /&gt;
&lt;br /&gt;
puts the event data into the ''event_data'' local variable. Since it is a ''moveto'' event, the ''event_data'' table contains the destination of the unit in the ''x1'' and ''y1'' fields.&lt;br /&gt;
&lt;br /&gt;
The next two lines then test&lt;br /&gt;
&lt;br /&gt;
 if target_hex.is_set and&lt;br /&gt;
    (event_data.x1 ~= target_hex.x or event_data.y1 ~= target_hex.y)&lt;br /&gt;
&lt;br /&gt;
whether the variable ''target_hex'' matches the event parameters. Since ''target_hex'' is not a local variable, it is taken from the global environment (a table implicitly named ''_G'', so it is actually ''_G.target_hex''). The global environment is not persistent, so it cannot be used to store data. In order to make it useful, it was mapped to the storage of WML variables by the following ''preload'' event.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=preload&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             H = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
             -- skipping some other initializations&lt;br /&gt;
             -- ...&lt;br /&gt;
             H.set_wml_var_metatable(_G)&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Without a prelude redirecting ''_G'', the conditional would have been written&lt;br /&gt;
&lt;br /&gt;
 if wesnoth.get_variable(&amp;quot;target_hex.is_set&amp;quot;) and&lt;br /&gt;
    (event_data.x1 ~= wesnoth.get_variable(&amp;quot;target_hex.x&amp;quot;) or event_data.y1 ~= wesnoth.get_variable(&amp;quot;target_hex.y&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The body of the conditional then performs the [[InterfaceActionsWML#Other interface tags|[redraw]]] action.&lt;br /&gt;
&lt;br /&gt;
 W.redraw()&lt;br /&gt;
&lt;br /&gt;
Again, this short syntax is made possible by a line of the prelude that makes ''W'' a proxy for performing WML actions.&lt;br /&gt;
&lt;br /&gt;
 W = H.set_wml_action_metatable {}&lt;br /&gt;
&lt;br /&gt;
Without this shortcut, the first statement would have been written&lt;br /&gt;
&lt;br /&gt;
 wesnoth.fire(&amp;quot;redraw&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Finally the script displays a message by&lt;br /&gt;
&lt;br /&gt;
 narrator_says(_ &amp;quot;*Oops!\nYou moved to the wrong place! After this message, you can press 'u' to undo, then try again.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The ''narrator_says'' function is defined in the prelude too, since the construct behind it occurs several times in the tutorial. In plain WML, macros would have been used instead. The definition of the function is&lt;br /&gt;
&lt;br /&gt;
 function narrator_says(m)&lt;br /&gt;
     W.message { speaker=&amp;quot;narrator&amp;quot;,&lt;br /&gt;
                 message = m .. _ &amp;quot;\n*Left click or press spacebar to continue...&amp;quot; }&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The function fires a [[InterfaceActionsWML#.5Bmessage.5D|[message]]] action and passes a WML object containing the usual two fields to it. The second field is initialized by concatenating the function argument with another string. Both strings are prefixed by the ''_'' symbol to mark them as translatable. (Note that ''_'' is just a unary function, not a keyword.) Again, this is made possible by a specific line of the prelude:&lt;br /&gt;
&lt;br /&gt;
 _ = wesnoth.textdomain &amp;quot;wesnoth-tutorial&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A longer translation of the tutorial is available at [https://gna.org/patch/download.php?file_id=5483].&lt;br /&gt;
&lt;br /&gt;
== Interface to the engine and helper functions ==&lt;br /&gt;
&lt;br /&gt;
Functionalities of the game engine are available through the functions contained in the '''wesnoth''' global table. Some of these functions return proxy tables. Writes to fields marked &amp;quot;read-only&amp;quot; are ignored. The '''__cfg''' fields return plain tables; in particular, writes do not modify the original object, and reads return the values from the time the dump was performed.&lt;br /&gt;
&lt;br /&gt;
Some helper functions are provided by the '''lua/helper.lua''' library. They are stored inside a table that is returned when loading the library with [[LuaWML:Files#wesnoth.require|wesnoth.require]].&lt;br /&gt;
&lt;br /&gt;
 helper = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== WML variables ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Variables#wesnoth.get_variable|wesnoth.get_variable]]&lt;br /&gt;
* [[LuaWML:Variables#wesnoth.set_variable|wesnoth.set_variable]]&lt;br /&gt;
* [[LuaWML:Variables#helper.set_wml_var_metatable|helper.set_wml_var_metatable]]&lt;br /&gt;
* [[LuaWML:Variables#helper.get_child|helper.get_child]]&lt;br /&gt;
* [[LuaWML:Variables#helper.child_range|helper.child_range]]&lt;br /&gt;
* [[LuaWML:Variables#helper.get_variable_array|helper.get_variable_array]]&lt;br /&gt;
* [[LuaWML:Variables#helper.get_variable_proxy_array|helper.get_variable_proxy_array]]&lt;br /&gt;
* [[LuaWML:Variables#helper.set_variable_array|helper.set_variable_array]]&lt;br /&gt;
&lt;br /&gt;
=== Events and WML actions ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Events#wesnoth.fire|wesnoth.fire]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.register_wml_action|wesnoth.register_wml_action]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.wml_actions|wesnoth.wml_actions]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.game_events|wesnoth.game_events]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.fire_event|wesnoth.fire_event]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.eval_conditional|wesnoth.eval_conditional]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.tovconfig|wesnoth.tovconfig]]&lt;br /&gt;
* [[LuaWML:Events#helper.set_wml_action_metatable|helper.set_wml_action_metatable]]&lt;br /&gt;
* [[LuaWML:Events#helper.wml_error|helper.wml_error]]&lt;br /&gt;
* [[LuaWML:Events#helper.literal|helper.literal]]&lt;br /&gt;
* [[LuaWML:Events#helper.parsed|helper.parsed]]&lt;br /&gt;
* [[LuaWML:Events#helper.shallow_literal|helper.shallow_literal]]&lt;br /&gt;
* [[LuaWML:Events#helper.shallow_parsed|helper.shallow_parsed]]&lt;br /&gt;
&lt;br /&gt;
=== User interface ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Display#wesnoth.message|wesnoth.message]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.clear_messages|wesnoth.clear_messages]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.textdomain|wesnoth.textdomain]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.delay|wesnoth.delay]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.float_label|wesnoth.float_label]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.select_hex|wesnoth.select_hex]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.scroll_to_tile|wesnoth.scroll_to_tile]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.lock_view|wesnoth.lock_view]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.view_locked|wesnoth.view_locked]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.play_sound|wesnoth.play_sound]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_music|wesnoth.set_music]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.show_dialog|wesnoth.show_dialog]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_value|wesnoth.set_dialog_value]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.get_dialog_value|wesnoth.get_dialog_value]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_active|wesnoth.set_dialog_active]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_callback|wesnoth.set_dialog_callback]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_canvas|wesnoth.set_dialog_canvas]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.get_displayed_unit|wesnoth.get_displayed_unit]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.theme_items|wesnoth.theme_items]]&lt;br /&gt;
* [[LuaWML:Display#helper.get_user_choice|helper.get_user_choice]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.get_time_of_day|wesnoth.get_time_of_day]]&lt;br /&gt;
&lt;br /&gt;
=== Map and terrains ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_map_size|wesnoth.get_map_size]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_terrain|wesnoth.get_terrain]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.set_terrain|wesnoth.set_terrain]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_terrain_info|wesnoth.get_terrain_info]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_selected_tile|wesnoth.get_selected_tile]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_locations|wesnoth.get_locations]]&lt;br /&gt;
* {{DevFeature1.11}}[[LuaWML:Tiles#wesnoth.get_villages|wesnoth.get_villages]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.match_location|wesnoth.match_location]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.add_tile_overlay|wesnoth.add_tile_overlay]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.remove_tile_overlay|wesnoth.remove_tile_overlay]]&lt;br /&gt;
* [[LuaWML:Tiles#items.place_image|items.place_image]]&lt;br /&gt;
* [[LuaWML:Tiles#items.place_halo|items.place_halo]]&lt;br /&gt;
* [[LuaWML:Tiles#items.remove|items.remove]]&lt;br /&gt;
&lt;br /&gt;
=== Units ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_units|wesnoth.get_units]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_unit|wesnoth.get_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.match_unit|wesnoth.match_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.put_unit|wesnoth.put_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_recall_units|wesnoth.get_recall_units]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.put_recall_unit|wesnoth.put_recall_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.create_unit|wesnoth.create_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.copy_unit|wesnoth.copy_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.extract_unit|wesnoth.extract_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.add_modification|wesnoth.add_modification]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_resistance|wesnoth.unit_resistance]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_defense|wesnoth.unit_defense]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_movement_cost|wesnoth.unit_movement_cost]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_ability|wesnoth.unit_ability]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_unit_type_ids|wesnoth.get_unit_type_ids]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_unit_type|wesnoth.get_unit_type]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_types|wesnoth.unit_types]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.races|wesnoth.races]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_traits|wesnoth.get_traits]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.simulate_combat|wesnoth.simulate_combat]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.transform_unit|wesnoth.transform_unit]]&lt;br /&gt;
&lt;br /&gt;
=== Sides ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_side|wesnoth.get_side]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.sides|wesnoth.sides]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_sides|wesnoth.get_sides]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_village_owner|wesnoth.get_village_owner]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.set_village_owner|wesnoth.set_village_owner]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.is_enemy|wesnoth.is_enemy]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.match_side|wesnoth.match_side]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_starting_location|wesnoth.get_starting_location]]&lt;br /&gt;
* [[LuaWML:Sides#helper.all_teams|helper.all_teams]]&lt;br /&gt;
&lt;br /&gt;
=== Pathfinder ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Pathfinder#wesnoth.find_path|wesnoth.find_path]]&lt;br /&gt;
* [[LuaWML:Pathfinder#wesnoth.find_vacant_tile|wesnoth.find_vacant_tile]]&lt;br /&gt;
* [[LuaWML:Pathfinder#wesnoth.find_reach|wesnoth.find_reach]]&lt;br /&gt;
* [[LuaWML:Pathfinder#helper.distance_between|helper.distance_between]]&lt;br /&gt;
* [[LuaWML:Pathfinder#helper.adjacent_tiles|helper.adjacent_tiles]]&lt;br /&gt;
&lt;br /&gt;
=== Lua files ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Files#wesnoth.dofile|wesnoth.dofile]]&lt;br /&gt;
* [[LuaWML:Files#wesnoth.require|wesnoth.require]]&lt;br /&gt;
&lt;br /&gt;
=== Location sets ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Location_set#location_set.create|location_set.create]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set.of_pairs|location_set.of_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set.of_wml_var|location_set.of_wml_var]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:empty|location_set:empty]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:size|location_set:size]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:clear|location_set:clear]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:get|location_set:get]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:insert|location_set:insert]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:remove|location_set:remove]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:of_pairs|location_set:of_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:of_wml_var|location_set:of_wml_var]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:to_pairs|location_set:to_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:to_stable_pairs|location_set:to_stable_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:to_wml_var|location_set:to_wml_var]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:union|location_set:union]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:inter|location_set:inter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:iter|location_set:iter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:stable_iter|location_set:stable_iter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:filter|location_set:filter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:union_merge|location_set:union_merge]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:inter_merge|location_set:inter_merge]]&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.game_config|wesnoth.game_config]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.current|wesnoth.current]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.synchronize_choice|wesnoth.synchronize_choice]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.get_image_size|wesnoth.get_image_size]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.compare_versions|wesnoth.compare_versions]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.have_file|wesnoth.have_file]] {{DevFeature1.11}}&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.debug|wesnoth.debug]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.get_time_stamp|wesnoth.get_time_stamp]] {{DevFeature1.11}}&lt;br /&gt;
* [[LuaWML:Misc#helper.set_wml_tag_metatable|helper.set_wml_tag_metatable]]&lt;br /&gt;
* [[LuaWML:Misc#helper.modify_unit|helper.modify_unit]]&lt;br /&gt;
* [[LuaWML:Misc#helper.move_unit_fake|helper.move_unit_fake]]&lt;br /&gt;
* [[LuaWML:Misc#helper.rand|helper.rand]]&lt;br /&gt;
* [[LuaWML:Misc#helper.round|helper.round]] {{DevFeature1.11}}&lt;br /&gt;
* [[LuaWML:Misc#helper.shuffle|helper.shuffle]] {{DevFeature1.11}}&lt;br /&gt;
&lt;br /&gt;
== Encoding WML objects into Lua tables ==&lt;br /&gt;
&lt;br /&gt;
Function [[LuaWML:Events#wesnoth.fire|wesnoth.fire]] expects a table representing a WML object as its second argument (if needed). Function [[LuaWML:Variables#wesnoth.set_variable|wesnoth.set_variable]] allows to modify whole WML objects, again by passing it a table. Function [[LuaWML:Variables#wesnoth.get_variable|wesnoth.get_variable]] transforms a WML object into a table, if its second argument is not set to ''true''. All these tables have the same format.&lt;br /&gt;
&lt;br /&gt;
Scalar fields are transformed into WML attributes. For instance, the following Lua table&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
     a_bool = true,&lt;br /&gt;
     an_int = 42,&lt;br /&gt;
     a_float = 1.25,&lt;br /&gt;
     a_string = &amp;quot;scout&amp;quot;,&lt;br /&gt;
     a_translation = _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
is equivalent to the content of the following WML object&lt;br /&gt;
&lt;br /&gt;
 [dummy]&lt;br /&gt;
     a_bool = &amp;quot;yes&amp;quot;&lt;br /&gt;
     an_int = &amp;quot;42&amp;quot;&lt;br /&gt;
     a_float = &amp;quot;1.25&amp;quot;&lt;br /&gt;
     a_string = &amp;quot;scout&amp;quot;&lt;br /&gt;
     a_translation = _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
 [/dummy]&lt;br /&gt;
&lt;br /&gt;
WML child objects are not stored as Lua named fields, since several of them can have the same tag. Moreover, their tags can conflict with the attribute keys. So child objects are stored as pairs string + table in the unnamed fields in definition order. This means that for every subtag appearing in the wml code there is an additional table &amp;quot;layer&amp;quot; in the corresponding WML table of the form {[1] = &amp;quot;tag_name&amp;quot;, [2] = {}} which is equivalent to {&amp;quot;tag_name&amp;quot;, {}}. [1] etc are the unnamed fields (as opposed to wml attributes). The table under [2] in this subtable then holds the wml attributes from inside the wml subtag. So every subtag other than the toplevel tag corresponds to two nested tables each. For instance, the following Lua table&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
     foo = 42,&lt;br /&gt;
     { &amp;quot;bar&amp;quot;, { v = 1, w = 2 } },&lt;br /&gt;
     { &amp;quot;foo&amp;quot;, { x = false } },&lt;br /&gt;
     { &amp;quot;bar&amp;quot;, { y = &amp;quot;foo&amp;quot; } },&lt;br /&gt;
     { &amp;quot;foobar&amp;quot;, { z = 5, { &amp;quot;barfoo&amp;quot;, {} } } }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
is equivalent to the content of the following WML object&lt;br /&gt;
&lt;br /&gt;
 [dummy]&lt;br /&gt;
     foo = 42&lt;br /&gt;
     [bar]&lt;br /&gt;
         v = 1&lt;br /&gt;
         w = 2&lt;br /&gt;
     [/bar]&lt;br /&gt;
     [foo]&lt;br /&gt;
         x = no&lt;br /&gt;
     [/foo]&lt;br /&gt;
     [bar]&lt;br /&gt;
         y = foo&lt;br /&gt;
     [bar]&lt;br /&gt;
     [foobar]&lt;br /&gt;
         z = 5&lt;br /&gt;
         [barfoo]&lt;br /&gt;
         [/barfoo]&lt;br /&gt;
     [/foobar]&lt;br /&gt;
 [/dummy]&lt;br /&gt;
&lt;br /&gt;
Both tables above are also equivalent to this WML table, where all unnamed fields are displayed:&lt;br /&gt;
 {&lt;br /&gt;
     foo = 42,&lt;br /&gt;
     [1] = { [1] = &amp;quot;bar&amp;quot;, [2] = { v = 1, w = 2 } },&lt;br /&gt;
     [2] = { [1] = &amp;quot;foo&amp;quot;, [2] = { x = false } },&lt;br /&gt;
     [3] = { [1] = &amp;quot;bar&amp;quot;, [2] = { y = &amp;quot;foo&amp;quot; } },&lt;br /&gt;
     [4] = { [1] = &amp;quot;foobar&amp;quot;, [2] = { z = 5, [1] = { [1] = &amp;quot;barfoo&amp;quot;, [2] = {} } } }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
So assuming ''cfg'' contains the above WML object, the following accesses are possible:&lt;br /&gt;
&lt;br /&gt;
 a_int = cfg.foo        -- &amp;quot;dummy.foo&amp;quot;, 42&lt;br /&gt;
 a_string = cfg[3][2].y -- &amp;quot;dummy.bar[1].y&amp;quot;, &amp;quot;foo&amp;quot;&lt;br /&gt;
 a_table = cfg[4][2]    -- &amp;quot;dummy.foobar&amp;quot;, { z = 5, { &amp;quot;barfoo&amp;quot;, {} } }&lt;br /&gt;
&lt;br /&gt;
Consider using the [[LuaWML:Variables#helper.get_child|helper.get_child]] and [[LuaWML:Variables#helper.child_range|helper.child_range]] to ease the access to subtags.&lt;br /&gt;
&lt;br /&gt;
Functions registered by [[LuaWML:Events#wesnoth.register_wml_action|wesnoth.register_wml_action]] receive their data in a userdata object which has the exact same structure as above. It is read-only however. Accessing fields or children performs variable substitution on the fly. Its '''__parsed''' and '''__literal''' fields provide translations to plain tables (therefore writable). '''__literal''' returns the original text of the data (including dollar symbols in attributes and [insert_tag] children), while '''__parsed''' performs a variable substitution.&lt;br /&gt;
&lt;br /&gt;
For instance, if you cannot stand any longer the fact that '''first_time_only''' is set to yes by default for the '''[event]''' tag, you can redefine it. But we have to be careful not to cause variable substitution, since the engine would perform a second variable substitution afterwards.&lt;br /&gt;
&lt;br /&gt;
 local old_event_handler&lt;br /&gt;
 old_event_handler = register_wml_action(&amp;quot;event&amp;quot;,&lt;br /&gt;
     function(cfg)&lt;br /&gt;
         -- Get the plain text from the user.&lt;br /&gt;
         local new_cfg = cfg.__literal&lt;br /&gt;
         -- The expression below is equivalent to cfg.__parsed.first_time_only,&lt;br /&gt;
         -- only faster. It is needed, since the first_time_only attribute may&lt;br /&gt;
         -- reference variables.&lt;br /&gt;
         local first = cfg.first_time_only&lt;br /&gt;
         -- Modify the default behavior of first_time_only.&lt;br /&gt;
         if first == nil then first = false end&lt;br /&gt;
         new_cfg.first_time_only = first&lt;br /&gt;
         -- Call the engine handler.&lt;br /&gt;
         old_event_handler(new_cfg)&lt;br /&gt;
     end&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
Note that, since the object is a userdata and not a table, '''pairs''' and '''ipairs''' are unfortunately not usable on it. So scripts have to work at a lower level. For instance, the following function returns the first sub-tag with a given name and it works both on WML tables and WML userdata:&lt;br /&gt;
&lt;br /&gt;
 function get_child(cfg, name)&lt;br /&gt;
     for i = 1, #cfg do&lt;br /&gt;
         local v = cfg[i]&lt;br /&gt;
         if v[1] == name then return v[2] end&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Another approach for handling userdata and tables in the same way, would be to convert the former into the latter beforehand:&lt;br /&gt;
&lt;br /&gt;
 if getmetatable(cfg) == &amp;quot;wml object&amp;quot; then cfg = cfg.__parsed end&lt;br /&gt;
&lt;br /&gt;
The WML userdata provides two other special fields: '''__shallow_parsed''' and '''__shallow_literal'''. They return a table corresponding to the WML userdata with variable substitution performed on the attributes (or not). [insert_tag] tags have also been parsed, so the number of children is faithful. But contrarily to '''__parsed''' and '''__literal''', the process is not recursive: all the children are still WML userdata and variable substitution can still happen for them. These shallow translators are meant as optimized versions of the deep ones, when only the toplevel attributes need to be writable.&lt;br /&gt;
&lt;br /&gt;
== Skeleton of a preload event ==&lt;br /&gt;
&lt;br /&gt;
The following event is a skeleton for a prelude enabling Lua in your WML events. It creates a table ''H'' containing the functions from helper.lua and a table ''W'' that serves as a proxy for firing WML actions. It also sets up the global environment so that any access to an undefined global variable is redirected to the persistent WML storage.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=preload&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             H = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
             W = H.set_wml_action_metatable {}&lt;br /&gt;
             _ = wesnoth.textdomain &amp;quot;my-campaign&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
             -- Define your global constants here.&lt;br /&gt;
             -- ...&lt;br /&gt;
 &lt;br /&gt;
             H.set_wml_var_metatable(_G)&lt;br /&gt;
 &lt;br /&gt;
             -- Define your global functions here.&lt;br /&gt;
             -- ...&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
It may be worth putting the whole Lua script above inside a separate file and having the ''preload'' event load it:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=preload&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt; wesnoth.dofile &amp;quot;~add-ons/Whatever/file.lua&amp;quot; &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
The math.random function is not safe for replays and multiplayer games, since the random values will be different each time and on all the clients. Instead, the Lua code should rely on the [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] tag to synchronize random values.&lt;br /&gt;
&lt;br /&gt;
 function random(min, max)&lt;br /&gt;
   if not max then min, max = 1, min end&lt;br /&gt;
   wesnoth.fire(&amp;quot;set_variable&amp;quot;, { name = &amp;quot;LUA_random&amp;quot;, rand = string.format(&amp;quot;%d..%d&amp;quot;, min, max) })&lt;br /&gt;
   local res = wesnoth.get_variable &amp;quot;LUA_random&amp;quot;&lt;br /&gt;
   wesnoth.set_variable &amp;quot;LUA_random&amp;quot;&lt;br /&gt;
   return res&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
[[Category: Lua Reference|*]]&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaWML&amp;diff=49587</id>
		<title>LuaWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaWML&amp;diff=49587"/>
		<updated>2013-04-02T03:21:01Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Global environment */ Misc. minor editing (typos, grammar corrections)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
== The '''[lua]''' tag ==&lt;br /&gt;
&lt;br /&gt;
This tag is a part of [[ActionWML]], thus can be used inside [event] and at other places where [[ActionWML]] can be used. It makes it possible to write actions with the [http://www.lua.org Lua 5.2] language.&lt;br /&gt;
&lt;br /&gt;
The tag supports only the '''code''' key, which is a string containing the Lua scripts. Since Lua makes usage of the quotes and the { and } symbols, it is certainly wise to enclose the script between stronger quotes, as they prevent the preprocessor from performing macro expansion and tokenization.&lt;br /&gt;
&lt;br /&gt;
 [lua]&lt;br /&gt;
     code = &amp;lt;&amp;lt; wesnoth.message &amp;quot;Hello World!&amp;quot; &amp;gt;&amp;gt;&lt;br /&gt;
 [/lua]&lt;br /&gt;
&lt;br /&gt;
The Lua kernel can also be accessed from the [[CommandMode|command mode]]:&lt;br /&gt;
&lt;br /&gt;
 :lua local u = wesnoth.get_units({ id = &amp;quot;Konrad&amp;quot; })[1]; u.moves = 5&lt;br /&gt;
&lt;br /&gt;
The '''[args]''' sub-tag can be used to pass a WML object to the script via its variadic local variable &amp;quot;'''...'''&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
 [lua]&lt;br /&gt;
     code = &amp;lt;&amp;lt; local t = ...; wesnoth.message(tostring(t.text)) &amp;gt;&amp;gt;&lt;br /&gt;
     [args]&lt;br /&gt;
         text = _ &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
     [/args]&lt;br /&gt;
 [/lua]&lt;br /&gt;
&lt;br /&gt;
== Global environment ==&lt;br /&gt;
&lt;br /&gt;
All the Lua scripts of a scenario share the same global environment (aka Lua state). For instance, a function defined in an event can be used in all the events that happen after it.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name = preload&lt;br /&gt;
     first_time_only = no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             function narrator(t)&lt;br /&gt;
                 -- Behave like the [message] tag.&lt;br /&gt;
                 wesnoth.fire(&amp;quot;message&amp;quot;,&lt;br /&gt;
                   { speaker = &amp;quot;narrator&amp;quot;, message = t.sentence })&lt;br /&gt;
             end&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name = turn 1&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt; narrator(...) &amp;gt;&amp;gt;&lt;br /&gt;
         [args]&lt;br /&gt;
             sentence = _ &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
         [/args]&lt;br /&gt;
     [/lua]&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt; narrator(...) &amp;gt;&amp;gt;&lt;br /&gt;
         [args]&lt;br /&gt;
             sentence = _ &amp;quot;How are you today?&amp;quot;&lt;br /&gt;
         [/args]&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
In the example above, the redundant structure could be hidden behind macros. But it may be better to simply define a new WML tag.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name = preload&lt;br /&gt;
     first_time_only = no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             -- The function is now local, since its name does not have to be&lt;br /&gt;
             -- visible outside this Lua scripts.&lt;br /&gt;
             local function handler(t)&lt;br /&gt;
                 -- Behave like the [message] tag.&lt;br /&gt;
                 wesnoth.fire(&amp;quot;message&amp;quot;,&lt;br /&gt;
                   { speaker = &amp;quot;narrator&amp;quot;, message = t.sentence })&lt;br /&gt;
             end&lt;br /&gt;
             -- Create a new tag named [narrator].&lt;br /&gt;
             wesnoth.register_wml_action(&amp;quot;narrator&amp;quot;, handler)&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
 &lt;br /&gt;
 [event]&lt;br /&gt;
     name = turn 1&lt;br /&gt;
     [narrator]&lt;br /&gt;
         sentence = _ &amp;quot;Hello world!&amp;quot;&lt;br /&gt;
     [/narrator]&lt;br /&gt;
     [narrator]&lt;br /&gt;
         sentence = _ &amp;quot;How are you today?&amp;quot;&lt;br /&gt;
     [/narrator]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
The global environment is not preserved over save/load cycles. Therefore, storing values in the global environment is generally a bad idea (unless it has been redirected to WML variables, see [[LuaWML:Variables#set_wml_var_metatable|helper.set_wml_var_metatable]]). The only time assigning global variables (including function definitions) makes sense is during a [[EventWML#Predefined 'name' Key Values|preload]] event, as this event is always run. Therefore, helper functions defined at that time will be available to all the later scripts.&lt;br /&gt;
&lt;br /&gt;
The global environment initially contains the following modules: [http://www.lua.org/manual/5.1/manual.html#5.1 basic] (no name), [http://www.lua.org/manual/5.1/manual.html#5.4 string], [http://www.lua.org/manual/5.1/manual.html#5.5 table], and [http://www.lua.org/manual/5.1/manual.html#5.6 math]. A '''wesnoth''' module is also available, it provides access to the [[#Interface to the C++ engine|C++ engine]]. Additionally, the functions clock, date, time and difftime from the [http://www.lua.org/manual/5.1/manual.html#5.8 os] library (keep in mind that they aren't multiplayer- and replay-safe), as well as traceback from the [http://www.lua.org/manual/5.1/manual.html#5.9 debug] library are also available.&lt;br /&gt;
&lt;br /&gt;
At the start of a script, the variadic local variable '''...''' (three dots) is a proxy table representing [[#Encoding WML objects into Lua tables|WML data]]. This table is the content of the '''[args]''' sub-tag of the '''[lua]''' tag, if any.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
The following WML event is taken from Wesnoth' tutorial. It will serve as an example to present how Lua scripts are embedded into Wesnoth. The event is fired whenever a unit from side 1 (that is, the hero controlled by the user) moves to a tile that is not the one set in the WML variable ''target_hex''.&lt;br /&gt;
&lt;br /&gt;
 # General catch for them moving to the wrong place.&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [allow_undo][/allow_undo]&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=target_hex.is_set&lt;br /&gt;
             equals=yes&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [if]&lt;br /&gt;
                 [variable]&lt;br /&gt;
                     name=x1&lt;br /&gt;
                     equals=$target_hex.x&lt;br /&gt;
                 [/variable]&lt;br /&gt;
                 [variable]&lt;br /&gt;
                     name=y1&lt;br /&gt;
                     equals=$target_hex.y&lt;br /&gt;
                 [/variable]&lt;br /&gt;
                 [then]&lt;br /&gt;
                 [/then]&lt;br /&gt;
                 [else]&lt;br /&gt;
                     [redraw][/redraw]&lt;br /&gt;
                     [message]&lt;br /&gt;
                         speaker=narrator&lt;br /&gt;
                         message=_ &amp;quot;*Oops!&lt;br /&gt;
 You moved to the wrong place! After this message, you can press 'u' to undo, then try again.&amp;quot; +&lt;br /&gt;
                         _ &amp;quot;&lt;br /&gt;
 *Left click or press spacebar to continue...&amp;quot;&lt;br /&gt;
                     [/message]&lt;br /&gt;
                 [/else]&lt;br /&gt;
             [/if]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
A Lua script that performs the same action is presented below.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [allow_undo][/allow_undo]&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
 &lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             local event_data = wesnoth.current.event_context&lt;br /&gt;
             if target_hex.is_set and&lt;br /&gt;
                (event_data.x1 ~= target_hex.x or event_data.y1 ~= target_hex.y)&lt;br /&gt;
             then&lt;br /&gt;
                 W.redraw()&lt;br /&gt;
                 narrator_says(_ &amp;quot;*Oops!\nYou moved to the wrong place! After this message, you can press 'u' to undo, then try again.&amp;quot;)&lt;br /&gt;
             end&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Here is a more detailed explanation of the Lua code. Its first line&lt;br /&gt;
&lt;br /&gt;
 local event_data = wesnoth.current.event_context&lt;br /&gt;
&lt;br /&gt;
puts the event data into the ''event_data'' local variable. Since it is a ''moveto'' event, the ''event_data'' table contains the destination of the unit in the ''x1'' and ''y1'' fields.&lt;br /&gt;
&lt;br /&gt;
The next two lines then test&lt;br /&gt;
&lt;br /&gt;
 if target_hex.is_set and&lt;br /&gt;
    (event_data.x1 ~= target_hex.x or event_data.y1 ~= target_hex.y)&lt;br /&gt;
&lt;br /&gt;
whether the variable ''target_hex'' matches the event parameters. Since ''target_hex'' is not a local variable, it is taken from the global environment (a table implicitly named ''_G'', so it is actually ''_G.target_hex''). The global environment is not persistent, so it cannot be used to store data. In order to make it useful, it was mapped to the storage of WML variables by the following ''preload'' event.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=preload&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             H = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
             -- skipping some other initializations&lt;br /&gt;
             -- ...&lt;br /&gt;
             H.set_wml_var_metatable(_G)&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Without a prelude redirecting ''_G'', the conditional would have been written&lt;br /&gt;
&lt;br /&gt;
 if wesnoth.get_variable(&amp;quot;target_hex.is_set&amp;quot;) and&lt;br /&gt;
    (event_data.x1 ~= wesnoth.get_variable(&amp;quot;target_hex.x&amp;quot;) or event_data.y1 ~= wesnoth.get_variable(&amp;quot;target_hex.y&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The body of the conditional then performs the [[InterfaceActionsWML#Other interface tags|[redraw]]] action.&lt;br /&gt;
&lt;br /&gt;
 W.redraw()&lt;br /&gt;
&lt;br /&gt;
Again, this short syntax is made possible by a line of the prelude that makes ''W'' a proxy for performing WML actions.&lt;br /&gt;
&lt;br /&gt;
 W = H.set_wml_action_metatable {}&lt;br /&gt;
&lt;br /&gt;
Without this shortcut, the first statement would have been written&lt;br /&gt;
&lt;br /&gt;
 wesnoth.fire(&amp;quot;redraw&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Finally the script displays a message by&lt;br /&gt;
&lt;br /&gt;
 narrator_says(_ &amp;quot;*Oops!\nYou moved to the wrong place! After this message, you can press 'u' to undo, then try again.&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The ''narrator_says'' function is defined in the prelude too, since the construct behind it occurs several times in the tutorial. In plain WML, macros would have been used instead. The definition of the function is&lt;br /&gt;
&lt;br /&gt;
 function narrator_says(m)&lt;br /&gt;
     W.message { speaker=&amp;quot;narrator&amp;quot;,&lt;br /&gt;
                 message = m .. _ &amp;quot;\n*Left click or press spacebar to continue...&amp;quot; }&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The function fires a [[InterfaceActionsWML#.5Bmessage.5D|[message]]] action and passes a WML object containing the usual two fields to it. The second field is initialized by concatenating the function argument with another string. Both strings are prefixed by the ''_'' symbol to mark them as translatable. (Note that ''_'' is just a unary function, not a keyword.) Again, this is made possible by a specific line of the prelude:&lt;br /&gt;
&lt;br /&gt;
 _ = wesnoth.textdomain &amp;quot;wesnoth-tutorial&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A longer translation of the tutorial is available at [https://gna.org/patch/download.php?file_id=5483].&lt;br /&gt;
&lt;br /&gt;
== Interface to the engine and helper functions ==&lt;br /&gt;
&lt;br /&gt;
Functionalities of the game engine are available through the functions of the '''wesnoth''' global table. Some of these functions return proxy tables. Writes to fields marked &amp;quot;read-only&amp;quot; are ignored. The '''__cfg''' fields return plain tables; in particular, writes do not modify the original object, and reads return the values from the time the dump was performed.&lt;br /&gt;
&lt;br /&gt;
Some helper functions are provided by the '''lua/helper.lua''' library. They are stored inside a table that is returned when loading the library with [[LuaWML:Files#wesnoth.require|wesnoth.require]].&lt;br /&gt;
&lt;br /&gt;
 helper = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== WML variables ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Variables#wesnoth.get_variable|wesnoth.get_variable]]&lt;br /&gt;
* [[LuaWML:Variables#wesnoth.set_variable|wesnoth.set_variable]]&lt;br /&gt;
* [[LuaWML:Variables#helper.set_wml_var_metatable|helper.set_wml_var_metatable]]&lt;br /&gt;
* [[LuaWML:Variables#helper.get_child|helper.get_child]]&lt;br /&gt;
* [[LuaWML:Variables#helper.child_range|helper.child_range]]&lt;br /&gt;
* [[LuaWML:Variables#helper.get_variable_array|helper.get_variable_array]]&lt;br /&gt;
* [[LuaWML:Variables#helper.get_variable_proxy_array|helper.get_variable_proxy_array]]&lt;br /&gt;
* [[LuaWML:Variables#helper.set_variable_array|helper.set_variable_array]]&lt;br /&gt;
&lt;br /&gt;
=== Events and WML actions ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Events#wesnoth.fire|wesnoth.fire]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.register_wml_action|wesnoth.register_wml_action]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.wml_actions|wesnoth.wml_actions]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.game_events|wesnoth.game_events]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.fire_event|wesnoth.fire_event]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.eval_conditional|wesnoth.eval_conditional]]&lt;br /&gt;
* [[LuaWML:Events#wesnoth.tovconfig|wesnoth.tovconfig]]&lt;br /&gt;
* [[LuaWML:Events#helper.set_wml_action_metatable|helper.set_wml_action_metatable]]&lt;br /&gt;
* [[LuaWML:Events#helper.wml_error|helper.wml_error]]&lt;br /&gt;
* [[LuaWML:Events#helper.literal|helper.literal]]&lt;br /&gt;
* [[LuaWML:Events#helper.parsed|helper.parsed]]&lt;br /&gt;
* [[LuaWML:Events#helper.shallow_literal|helper.shallow_literal]]&lt;br /&gt;
* [[LuaWML:Events#helper.shallow_parsed|helper.shallow_parsed]]&lt;br /&gt;
&lt;br /&gt;
=== User interface ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Display#wesnoth.message|wesnoth.message]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.clear_messages|wesnoth.clear_messages]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.textdomain|wesnoth.textdomain]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.delay|wesnoth.delay]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.float_label|wesnoth.float_label]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.select_hex|wesnoth.select_hex]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.scroll_to_tile|wesnoth.scroll_to_tile]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.lock_view|wesnoth.lock_view]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.view_locked|wesnoth.view_locked]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.play_sound|wesnoth.play_sound]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_music|wesnoth.set_music]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.show_dialog|wesnoth.show_dialog]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_value|wesnoth.set_dialog_value]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.get_dialog_value|wesnoth.get_dialog_value]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_active|wesnoth.set_dialog_active]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_callback|wesnoth.set_dialog_callback]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.set_dialog_canvas|wesnoth.set_dialog_canvas]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.get_displayed_unit|wesnoth.get_displayed_unit]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.theme_items|wesnoth.theme_items]]&lt;br /&gt;
* [[LuaWML:Display#helper.get_user_choice|helper.get_user_choice]]&lt;br /&gt;
* [[LuaWML:Display#wesnoth.get_time_of_day|wesnoth.get_time_of_day]]&lt;br /&gt;
&lt;br /&gt;
=== Map and terrains ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_map_size|wesnoth.get_map_size]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_terrain|wesnoth.get_terrain]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.set_terrain|wesnoth.set_terrain]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_terrain_info|wesnoth.get_terrain_info]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_selected_tile|wesnoth.get_selected_tile]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.get_locations|wesnoth.get_locations]]&lt;br /&gt;
* {{DevFeature1.11}}[[LuaWML:Tiles#wesnoth.get_villages|wesnoth.get_villages]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.match_location|wesnoth.match_location]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.add_tile_overlay|wesnoth.add_tile_overlay]]&lt;br /&gt;
* [[LuaWML:Tiles#wesnoth.remove_tile_overlay|wesnoth.remove_tile_overlay]]&lt;br /&gt;
* [[LuaWML:Tiles#items.place_image|items.place_image]]&lt;br /&gt;
* [[LuaWML:Tiles#items.place_halo|items.place_halo]]&lt;br /&gt;
* [[LuaWML:Tiles#items.remove|items.remove]]&lt;br /&gt;
&lt;br /&gt;
=== Units ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_units|wesnoth.get_units]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_unit|wesnoth.get_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.match_unit|wesnoth.match_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.put_unit|wesnoth.put_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_recall_units|wesnoth.get_recall_units]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.put_recall_unit|wesnoth.put_recall_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.create_unit|wesnoth.create_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.copy_unit|wesnoth.copy_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.extract_unit|wesnoth.extract_unit]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.add_modification|wesnoth.add_modification]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_resistance|wesnoth.unit_resistance]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_defense|wesnoth.unit_defense]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_movement_cost|wesnoth.unit_movement_cost]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_ability|wesnoth.unit_ability]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_unit_type_ids|wesnoth.get_unit_type_ids]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_unit_type|wesnoth.get_unit_type]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.unit_types|wesnoth.unit_types]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.races|wesnoth.races]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.get_traits|wesnoth.get_traits]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.simulate_combat|wesnoth.simulate_combat]]&lt;br /&gt;
* [[LuaWML:Units#wesnoth.transform_unit|wesnoth.transform_unit]]&lt;br /&gt;
&lt;br /&gt;
=== Sides ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_side|wesnoth.get_side]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.sides|wesnoth.sides]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_sides|wesnoth.get_sides]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_village_owner|wesnoth.get_village_owner]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.set_village_owner|wesnoth.set_village_owner]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.is_enemy|wesnoth.is_enemy]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.match_side|wesnoth.match_side]]&lt;br /&gt;
* [[LuaWML:Sides#wesnoth.get_starting_location|wesnoth.get_starting_location]]&lt;br /&gt;
* [[LuaWML:Sides#helper.all_teams|helper.all_teams]]&lt;br /&gt;
&lt;br /&gt;
=== Pathfinder ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Pathfinder#wesnoth.find_path|wesnoth.find_path]]&lt;br /&gt;
* [[LuaWML:Pathfinder#wesnoth.find_vacant_tile|wesnoth.find_vacant_tile]]&lt;br /&gt;
* [[LuaWML:Pathfinder#wesnoth.find_reach|wesnoth.find_reach]]&lt;br /&gt;
* [[LuaWML:Pathfinder#helper.distance_between|helper.distance_between]]&lt;br /&gt;
* [[LuaWML:Pathfinder#helper.adjacent_tiles|helper.adjacent_tiles]]&lt;br /&gt;
&lt;br /&gt;
=== Lua files ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Files#wesnoth.dofile|wesnoth.dofile]]&lt;br /&gt;
* [[LuaWML:Files#wesnoth.require|wesnoth.require]]&lt;br /&gt;
&lt;br /&gt;
=== Location sets ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Location_set#location_set.create|location_set.create]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set.of_pairs|location_set.of_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set.of_wml_var|location_set.of_wml_var]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:empty|location_set:empty]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:size|location_set:size]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:clear|location_set:clear]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:get|location_set:get]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:insert|location_set:insert]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:remove|location_set:remove]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:of_pairs|location_set:of_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:of_wml_var|location_set:of_wml_var]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:to_pairs|location_set:to_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:to_stable_pairs|location_set:to_stable_pairs]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:to_wml_var|location_set:to_wml_var]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:union|location_set:union]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:inter|location_set:inter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:iter|location_set:iter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:stable_iter|location_set:stable_iter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:filter|location_set:filter]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:union_merge|location_set:union_merge]]&lt;br /&gt;
* [[LuaWML:Location_set#location_set:inter_merge|location_set:inter_merge]]&lt;br /&gt;
&lt;br /&gt;
=== Miscellaneous ===&lt;br /&gt;
&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.game_config|wesnoth.game_config]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.current|wesnoth.current]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.synchronize_choice|wesnoth.synchronize_choice]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.get_image_size|wesnoth.get_image_size]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.compare_versions|wesnoth.compare_versions]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.have_file|wesnoth.have_file]] {{DevFeature1.11}}&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.debug|wesnoth.debug]]&lt;br /&gt;
* [[LuaWML:Misc#wesnoth.get_time_stamp|wesnoth.get_time_stamp]] {{DevFeature1.11}}&lt;br /&gt;
* [[LuaWML:Misc#helper.set_wml_tag_metatable|helper.set_wml_tag_metatable]]&lt;br /&gt;
* [[LuaWML:Misc#helper.modify_unit|helper.modify_unit]]&lt;br /&gt;
* [[LuaWML:Misc#helper.move_unit_fake|helper.move_unit_fake]]&lt;br /&gt;
* [[LuaWML:Misc#helper.rand|helper.rand]]&lt;br /&gt;
* [[LuaWML:Misc#helper.round|helper.round]] {{DevFeature1.11}}&lt;br /&gt;
* [[LuaWML:Misc#helper.shuffle|helper.shuffle]] {{DevFeature1.11}}&lt;br /&gt;
&lt;br /&gt;
== Encoding WML objects into Lua tables ==&lt;br /&gt;
&lt;br /&gt;
Function [[LuaWML:Events#wesnoth.fire|wesnoth.fire]] expects a table representing a WML object as its second argument (if needed). Function [[LuaWML:Variables#wesnoth.set_variable|wesnoth.set_variable]] allows to modify whole WML objects, again by passing it a table. Function [[LuaWML:Variables#wesnoth.get_variable|wesnoth.get_variable]] transforms a WML object into a table, if its second argument is not set to ''true''. All these tables have the same format.&lt;br /&gt;
&lt;br /&gt;
Scalar fields are transformed into WML attributes. For instance, the following Lua table&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
     a_bool = true,&lt;br /&gt;
     an_int = 42,&lt;br /&gt;
     a_float = 1.25,&lt;br /&gt;
     a_string = &amp;quot;scout&amp;quot;,&lt;br /&gt;
     a_translation = _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
is equivalent to the content of the following WML object&lt;br /&gt;
&lt;br /&gt;
 [dummy]&lt;br /&gt;
     a_bool = &amp;quot;yes&amp;quot;&lt;br /&gt;
     an_int = &amp;quot;42&amp;quot;&lt;br /&gt;
     a_float = &amp;quot;1.25&amp;quot;&lt;br /&gt;
     a_string = &amp;quot;scout&amp;quot;&lt;br /&gt;
     a_translation = _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
 [/dummy]&lt;br /&gt;
&lt;br /&gt;
WML child objects are not stored as Lua named fields, since several of them can have the same tag. Moreover, their tags can conflict with the attribute keys. So child objects are stored as pairs string + table in the unnamed fields in definition order. This means that for every subtag appearing in the wml code there is an additional table &amp;quot;layer&amp;quot; in the corresponding WML table of the form {[1] = &amp;quot;tag_name&amp;quot;, [2] = {}} which is equivalent to {&amp;quot;tag_name&amp;quot;, {}}. [1] etc are the unnamed fields (as opposed to wml attributes). The table under [2] in this subtable then holds the wml attributes from inside the wml subtag. So every subtag other than the toplevel tag corresponds to two nested tables each. For instance, the following Lua table&lt;br /&gt;
&lt;br /&gt;
 {&lt;br /&gt;
     foo = 42,&lt;br /&gt;
     { &amp;quot;bar&amp;quot;, { v = 1, w = 2 } },&lt;br /&gt;
     { &amp;quot;foo&amp;quot;, { x = false } },&lt;br /&gt;
     { &amp;quot;bar&amp;quot;, { y = &amp;quot;foo&amp;quot; } },&lt;br /&gt;
     { &amp;quot;foobar&amp;quot;, { z = 5, { &amp;quot;barfoo&amp;quot;, {} } } }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
is equivalent to the content of the following WML object&lt;br /&gt;
&lt;br /&gt;
 [dummy]&lt;br /&gt;
     foo = 42&lt;br /&gt;
     [bar]&lt;br /&gt;
         v = 1&lt;br /&gt;
         w = 2&lt;br /&gt;
     [/bar]&lt;br /&gt;
     [foo]&lt;br /&gt;
         x = no&lt;br /&gt;
     [/foo]&lt;br /&gt;
     [bar]&lt;br /&gt;
         y = foo&lt;br /&gt;
     [bar]&lt;br /&gt;
     [foobar]&lt;br /&gt;
         z = 5&lt;br /&gt;
         [barfoo]&lt;br /&gt;
         [/barfoo]&lt;br /&gt;
     [/foobar]&lt;br /&gt;
 [/dummy]&lt;br /&gt;
&lt;br /&gt;
Both tables above are also equivalent to this WML table, where all unnamed fields are displayed:&lt;br /&gt;
 {&lt;br /&gt;
     foo = 42,&lt;br /&gt;
     [1] = { [1] = &amp;quot;bar&amp;quot;, [2] = { v = 1, w = 2 } },&lt;br /&gt;
     [2] = { [1] = &amp;quot;foo&amp;quot;, [2] = { x = false } },&lt;br /&gt;
     [3] = { [1] = &amp;quot;bar&amp;quot;, [2] = { y = &amp;quot;foo&amp;quot; } },&lt;br /&gt;
     [4] = { [1] = &amp;quot;foobar&amp;quot;, [2] = { z = 5, [1] = { [1] = &amp;quot;barfoo&amp;quot;, [2] = {} } } }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
So assuming ''cfg'' contains the above WML object, the following accesses are possible:&lt;br /&gt;
&lt;br /&gt;
 a_int = cfg.foo        -- &amp;quot;dummy.foo&amp;quot;, 42&lt;br /&gt;
 a_string = cfg[3][2].y -- &amp;quot;dummy.bar[1].y&amp;quot;, &amp;quot;foo&amp;quot;&lt;br /&gt;
 a_table = cfg[4][2]    -- &amp;quot;dummy.foobar&amp;quot;, { z = 5, { &amp;quot;barfoo&amp;quot;, {} } }&lt;br /&gt;
&lt;br /&gt;
Consider using the [[LuaWML:Variables#helper.get_child|helper.get_child]] and [[LuaWML:Variables#helper.child_range|helper.child_range]] to ease the access to subtags.&lt;br /&gt;
&lt;br /&gt;
Functions registered by [[LuaWML:Events#wesnoth.register_wml_action|wesnoth.register_wml_action]] receive their data in a userdata object which has the exact same structure as above. It is read-only however. Accessing fields or children performs variable substitution on the fly. Its '''__parsed''' and '''__literal''' fields provide translations to plain tables (therefore writable). '''__literal''' returns the original text of the data (including dollar symbols in attributes and [insert_tag] children), while '''__parsed''' performs a variable substitution.&lt;br /&gt;
&lt;br /&gt;
For instance, if you cannot stand any longer the fact that '''first_time_only''' is set to yes by default for the '''[event]''' tag, you can redefine it. But we have to be careful not to cause variable substitution, since the engine would perform a second variable substitution afterwards.&lt;br /&gt;
&lt;br /&gt;
 local old_event_handler&lt;br /&gt;
 old_event_handler = register_wml_action(&amp;quot;event&amp;quot;,&lt;br /&gt;
     function(cfg)&lt;br /&gt;
         -- Get the plain text from the user.&lt;br /&gt;
         local new_cfg = cfg.__literal&lt;br /&gt;
         -- The expression below is equivalent to cfg.__parsed.first_time_only,&lt;br /&gt;
         -- only faster. It is needed, since the first_time_only attribute may&lt;br /&gt;
         -- reference variables.&lt;br /&gt;
         local first = cfg.first_time_only&lt;br /&gt;
         -- Modify the default behavior of first_time_only.&lt;br /&gt;
         if first == nil then first = false end&lt;br /&gt;
         new_cfg.first_time_only = first&lt;br /&gt;
         -- Call the engine handler.&lt;br /&gt;
         old_event_handler(new_cfg)&lt;br /&gt;
     end&lt;br /&gt;
 )&lt;br /&gt;
&lt;br /&gt;
Note that, since the object is a userdata and not a table, '''pairs''' and '''ipairs''' are unfortunately not usable on it. So scripts have to work at a lower level. For instance, the following function returns the first sub-tag with a given name and it works both on WML tables and WML userdata:&lt;br /&gt;
&lt;br /&gt;
 function get_child(cfg, name)&lt;br /&gt;
     for i = 1, #cfg do&lt;br /&gt;
         local v = cfg[i]&lt;br /&gt;
         if v[1] == name then return v[2] end&lt;br /&gt;
     end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Another approach for handling userdata and tables in the same way, would be to convert the former into the latter beforehand:&lt;br /&gt;
&lt;br /&gt;
 if getmetatable(cfg) == &amp;quot;wml object&amp;quot; then cfg = cfg.__parsed end&lt;br /&gt;
&lt;br /&gt;
The WML userdata provides two other special fields: '''__shallow_parsed''' and '''__shallow_literal'''. They return a table corresponding to the WML userdata with variable substitution performed on the attributes (or not). [insert_tag] tags have also been parsed, so the number of children is faithful. But contrarily to '''__parsed''' and '''__literal''', the process is not recursive: all the children are still WML userdata and variable substitution can still happen for them. These shallow translators are meant as optimized versions of the deep ones, when only the toplevel attributes need to be writable.&lt;br /&gt;
&lt;br /&gt;
== Skeleton of a preload event ==&lt;br /&gt;
&lt;br /&gt;
The following event is a skeleton for a prelude enabling Lua in your WML events. It creates a table ''H'' containing the functions from helper.lua and a table ''W'' that serves as a proxy for firing WML actions. It also sets up the global environment so that any access to an undefined global variable is redirected to the persistent WML storage.&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=preload&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt;&lt;br /&gt;
             H = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
             W = H.set_wml_action_metatable {}&lt;br /&gt;
             _ = wesnoth.textdomain &amp;quot;my-campaign&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
             -- Define your global constants here.&lt;br /&gt;
             -- ...&lt;br /&gt;
 &lt;br /&gt;
             H.set_wml_var_metatable(_G)&lt;br /&gt;
 &lt;br /&gt;
             -- Define your global functions here.&lt;br /&gt;
             -- ...&lt;br /&gt;
         &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
It may be worth putting the whole Lua script above inside a separate file and having the ''preload'' event load it:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=preload&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [lua]&lt;br /&gt;
         code = &amp;lt;&amp;lt; wesnoth.dofile &amp;quot;~add-ons/Whatever/file.lua&amp;quot; &amp;gt;&amp;gt;&lt;br /&gt;
     [/lua]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
== Remarks ==&lt;br /&gt;
&lt;br /&gt;
The math.random function is not safe for replays and multiplayer games, since the random values will be different each time and on all the clients. Instead, the Lua code should rely on the [[InternalActionsWML#.5Bset_variable.5D|[set_variable]]] tag to synchronize random values.&lt;br /&gt;
&lt;br /&gt;
 function random(min, max)&lt;br /&gt;
   if not max then min, max = 1, min end&lt;br /&gt;
   wesnoth.fire(&amp;quot;set_variable&amp;quot;, { name = &amp;quot;LUA_random&amp;quot;, rand = string.format(&amp;quot;%d..%d&amp;quot;, min, max) })&lt;br /&gt;
   local res = wesnoth.get_variable &amp;quot;LUA_random&amp;quot;&lt;br /&gt;
   wesnoth.set_variable &amp;quot;LUA_random&amp;quot;&lt;br /&gt;
   return res&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
[[Category: Lua Reference|*]]&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=47976</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=47976"/>
		<updated>2012-11-30T14:59:29Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Started on the section about loops&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder about the purpose of this tutorial. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
The specific demographic for which this tutorial is intended is users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder paths and locate specific directories. In this tutorial you will learn the fundamentals of WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming in WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML (in fact, it is recommended that you ''avoid'' using those fancy word processors); a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without being required to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_first_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.&lt;br /&gt;
&lt;br /&gt;
===Creating Your Custom Unit's .cfg File===&lt;br /&gt;
&lt;br /&gt;
===Including the Custom Unit In Your Campaign===&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without having to wade through a quagmire of if codeblocks. This is done via the switch/case codeblock, which tests the value of a variable for multiple conditions, and determines the action performed as a result of that evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
I was a very messy child, much to the distress of my mother, who was the epitome of cleanliness and couldn't for the life of her understand how she could have raised such an untidy child as me. Occasionally she'd work up enough courage to venture into the land of chaos that was my room, and then she'd tell me not leave my room until it was picked up.&lt;br /&gt;
&lt;br /&gt;
Okay, intimate family analogies aside, pay attention to how my mother told me to clean up my room: I was not to leave my room until it was clean. Whether or not the room was clean was the condition on which my permission to leave my room depended. So each time I put something away (which, more often then not, I did by stuffing the item under the bed), I would have to check to see that condition was met. If the room wasn't clean, then my mother's condition wasn't met and I had to keep cleaning. If the room was clean, then my mother's condition was met and I was free to leave my room.&lt;br /&gt;
&lt;br /&gt;
Talk about basic parts of loops, variations of loops (do/while, etc.)&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaWML/Display&amp;diff=46709</id>
		<title>LuaWML/Display</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaWML/Display&amp;diff=46709"/>
		<updated>2012-06-20T22:30:23Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* wesnoth.play_sound */ Minor rewording/clarifications&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the [[LuaWML]] functions and helpers for interfacing with the user.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.message ====&lt;br /&gt;
&lt;br /&gt;
Displays a string in the chat window and dumps it to the lua/info log domain (''--log-info=scripting/lua'' on the command-line).&lt;br /&gt;
&lt;br /&gt;
 wesnoth.message &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The chat line header is &amp;quot;&amp;lt;Lua&amp;gt;&amp;quot; by default, but it can be changed by passing a string before the message.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.message(&amp;quot;Big Brother&amp;quot;, &amp;quot;I'm watching you.&amp;quot;) -- will result in &amp;quot;&amp;amp;lt;Big Brother&amp;amp;gt; I'm watching you.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See also [[LuaWML:Events#helper.wml_error|helper.wml_error]] for displaying error messages.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.clear_messages ====&lt;br /&gt;
&lt;br /&gt;
Removes all messages from the chat window. No argument or returned values.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.textdomain ====&lt;br /&gt;
&lt;br /&gt;
Creates a function proxy for lazily translating strings from the given domain.&lt;br /&gt;
&lt;br /&gt;
 -- #textdomain &amp;quot;my-campaign&amp;quot;&lt;br /&gt;
 -- the comment above ensures the subsequent strings will be extracted to the proper domain&lt;br /&gt;
 _ = wesnoth.textdomain &amp;quot;my-campaign&amp;quot;&lt;br /&gt;
 wesnoth.set_variable(&amp;quot;my_unit.description&amp;quot;, _ &amp;quot;the unit formerly known as Hero&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The metatable of the function proxy appears as '''&amp;quot;message domain&amp;quot;'''. The metatable of the translatable strings (results of the proxy) appears as '''&amp;quot;translatable string&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
The translatable strings can be appended to other strings/numbers with the standard '''..''' operator. Translation can be forced with the standard '''tostring''' operator in order to get a plain string.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.message(string.format(tostring(_ &amp;quot;You gain %d gold.&amp;quot;), amount))&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.delay ====&lt;br /&gt;
&lt;br /&gt;
Delays the engine like the [delay] tag. one argument: time to delay in milliseconds&lt;br /&gt;
&lt;br /&gt;
 wesnoth.delay(500)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.float_label ====&lt;br /&gt;
&lt;br /&gt;
Pops some text above a map tile.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.float_label(unit.x, unit.y, &amp;quot;&amp;amp;lt;span color='#ff0000'&amp;amp;gt;Ouch&amp;amp;lt;/span&amp;amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.get_time_of_day ====&lt;br /&gt;
&lt;br /&gt;
Returns schedule information. First parameter (optional) is the turn number for which to return the information, if unspecified: the current turn ($turn_number). Second argument is an optional table. If present, first and second fields must be valid on-map coordinates and all current time_areas in the scenario are taken into account (if a time area happens to contain the passed hex). If the table isn't present, the scenario main schedule is returned. The table has an optional third parameter (boolean). If true (default: false), time of day modifying units (such as MoL) are taken into account (if the passed hex happens to be affected). The units placement being considered is always the current one.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.get_time_of_day(2, { 37, 3, true })&lt;br /&gt;
&lt;br /&gt;
The function returns a table with these named fields:&lt;br /&gt;
* '''id''': string (as in [time])&lt;br /&gt;
* '''lawful_bonus''': integer (as in [time])&lt;br /&gt;
* '''bonus_modified''': integer (bonus change by units)&lt;br /&gt;
* '''image''': string (tod image in sidebar)&lt;br /&gt;
* '''name''': translatable string&lt;br /&gt;
* '''red, green, blue''': integers (color adjustment for this time)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.select_hex ====&lt;br /&gt;
&lt;br /&gt;
Selects the given location in the game map as if the player would have clicked onto it.&lt;br /&gt;
Argument 3: boolean, whether to show the movement range of any unit on that location (def: true)&lt;br /&gt;
Argument 4: boolean, whether to fire any select events (def: false)&lt;br /&gt;
&lt;br /&gt;
 wesnoth.select_hex(14,6, true, true)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.scroll_to_tile ====&lt;br /&gt;
&lt;br /&gt;
Scrolls the map to the given location. If true is passed as the third parameter, scrolling is disabled if the tile is hidden under the fog. If true is passed as the fourth parameter {{DevFeature1.11}}, the view instantly warps to the location regardless of the scroll speed setting in Preferences.&lt;br /&gt;
&lt;br /&gt;
 local u = wesnoth.get_units({ id = &amp;quot;hero&amp;quot; })[1]&lt;br /&gt;
 wesnoth.scroll_to_tile(u.x, u.y)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.lock_view ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.11}} Locks or unlocks gamemap view scrolling for human players. If true is passed as the first parameter, the view is locked; pass false to unlock.&lt;br /&gt;
&lt;br /&gt;
Human players cannot scroll the gamemap view as long as it is locked, but Lua or WML actions such as wesnoth.scroll_to_tile still can; 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.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.lock_view(true)&lt;br /&gt;
 wesnoth.scroll_to_tile(12, 14, false, true)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.view_locked ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.11}} Returns a boolean indicating whether gamemap view scrolling is currently locked.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.play_sound ====&lt;br /&gt;
&lt;br /&gt;
Plays the given sound file once, optionally repeating it one or more more times if an integer value is provided as a second argument (note that the sound is ''repeated'' the number of times specified in the second argument, i.e. a second argument of 4 will cause the sound to be played once and then repeated four more times for a total of 5 plays. See the example below).&lt;br /&gt;
&lt;br /&gt;
 wesnoth.play_sound &amp;quot;ambient/birds1.ogg&amp;quot;&lt;br /&gt;
 wesnoth.play_sound(&amp;quot;magic-holy-miss-3.ogg&amp;quot;, 4) -- played 1 + 4 = 5 times&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_music ====&lt;br /&gt;
&lt;br /&gt;
Sets the given table as an entry into the music list. See [[MusicListWML]] for the recognized attributes.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.set_music { name = &amp;quot;traveling_minstrels.ogg&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
Passing no argument forces the engine to take into account all the recent changes to the music list. (Note: this is done automatically when sequences of WML commands end, so it is useful only for long events.)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.show_dialog ====&lt;br /&gt;
&lt;br /&gt;
Displays a dialog box described by a WML table and returns:&lt;br /&gt;
* if the dialog was dismissed by a button click, the integer value associated to the button via the &amp;quot;return_value&amp;quot; keyword.&lt;br /&gt;
* if the dialog was closed with the enter key, -1.&lt;br /&gt;
* if the dialog was closed with the escape key, -2.&lt;br /&gt;
&lt;br /&gt;
The dialog box is equivalent to the resolution section of a GUI window as described in [[GUIToolkitWML#Window_definition|GUIToolkitWML]] and must therefore contain at least the following children: '''[tooltip]''', '''[helptip]''', and '''[grid]'''. The [grid] must contain nested [row], [column] and [grid] tags which describe the layout of the window. (More information can be found in [[GUILayout]]; suffice to say that the basic structure is grid -&amp;gt; row -&amp;gt; column -&amp;gt; widget, where the widget is considered to be in a cell defined by the row and column of the grid. A list of widgets can be found at [[GUIWidgetInstanceWML]].)&lt;br /&gt;
&lt;br /&gt;
Two optional functions can be passed as second and third arguments; the first one is called once the dialog is created and before it is shown; the second one is called once the dialog is closed. These functions are helpful in setting the initial values of the fields and in recovering the final user values. These functions can call the [[#wesnoth.set_dialog_value]], [[#wesnoth.get_dialog_value]], and [[#wesnoth.set_dialog_callback]] functions for this purpose.&lt;br /&gt;
&lt;br /&gt;
This function should be called in conjunction with [[LuaWML:Misc#wesnoth.synchronize_choice|#wesnoth.synchronize_choice]], in order to ensure that only one client displays the dialog and that the other ones recover the same input values from this single client.&lt;br /&gt;
&lt;br /&gt;
The example below defines a dialog with a list and two buttons on the left, and a big image on the right. The ''preshow'' function fills the list and defines a callback on it. This ''select'' callback changes the displayed image whenever a new list item is selected. The ''postshow'' function recovers the selected item before the dialog is destroyed.&lt;br /&gt;
&lt;br /&gt;
 local helper = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
 local T = helper.set_wml_tag_metatable {}&lt;br /&gt;
 local _ = wesnoth.textdomain &amp;quot;wesnoth&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 local dialog = {&lt;br /&gt;
   T.tooltip { id = &amp;quot;tooltip_large&amp;quot; },&lt;br /&gt;
   T.helptip { id = &amp;quot;tooltip_large&amp;quot; },&lt;br /&gt;
   T.grid { T.row {&lt;br /&gt;
     T.column { T.grid {&lt;br /&gt;
       T.row { T.column { horizontal_grow = true, T.listbox { id = &amp;quot;the_list&amp;quot;,&lt;br /&gt;
         T.list_definition { T.row { T.column { horizontal_grow = true,&lt;br /&gt;
           T.toggle_panel { T.grid { T.row {&lt;br /&gt;
             T.column { horizontal_alignment = &amp;quot;left&amp;quot;, T.label { id = &amp;quot;the_label&amp;quot; } },&lt;br /&gt;
             T.column { T.image { id = &amp;quot;the_icon&amp;quot; } }&lt;br /&gt;
           } } }&lt;br /&gt;
         } } }&lt;br /&gt;
       } } },&lt;br /&gt;
       T.row { T.column { T.grid { T.row {&lt;br /&gt;
         T.column { T.button { id = &amp;quot;ok&amp;quot;, label = _&amp;quot;OK&amp;quot; } },&lt;br /&gt;
         T.column { T.button { id = &amp;quot;cancel&amp;quot;, label = _&amp;quot;Cancel&amp;quot; } }&lt;br /&gt;
       } } } }&lt;br /&gt;
     } },&lt;br /&gt;
     T.column { T.image { id = &amp;quot;the_image&amp;quot; } }&lt;br /&gt;
   } }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 local function preshow()&lt;br /&gt;
     local t = { &amp;quot;Ancient Lich&amp;quot;, &amp;quot;Ancient Wose&amp;quot;, &amp;quot;Elvish Avenger&amp;quot; }&lt;br /&gt;
     local function select()&lt;br /&gt;
         local i = wesnoth.get_dialog_value &amp;quot;the_list&amp;quot;&lt;br /&gt;
         local ut = wesnoth.unit_types[t[i]].__cfg&lt;br /&gt;
         wesnoth.set_dialog_value(string.gsub(ut.profile, &amp;quot;([^/]+)$&amp;quot;, &amp;quot;transparent/%1&amp;quot;), &amp;quot;the_image&amp;quot;)&lt;br /&gt;
     end&lt;br /&gt;
     wesnoth.set_dialog_callback(select, &amp;quot;the_list&amp;quot;)&lt;br /&gt;
     for i,v in ipairs(t) do&lt;br /&gt;
         local ut = wesnoth.unit_types[v].__cfg&lt;br /&gt;
         wesnoth.set_dialog_value(ut.name, &amp;quot;the_list&amp;quot;, i, &amp;quot;the_label&amp;quot;)&lt;br /&gt;
         wesnoth.set_dialog_value(ut.image, &amp;quot;the_list&amp;quot;, i, &amp;quot;the_icon&amp;quot;)&lt;br /&gt;
     end&lt;br /&gt;
     wesnoth.set_dialog_value(2, &amp;quot;the_list&amp;quot;)&lt;br /&gt;
     select()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local li = 0&lt;br /&gt;
 local function postshow()&lt;br /&gt;
     li = wesnoth.get_dialog_value &amp;quot;the_list&amp;quot;&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local r = wesnoth.show_dialog(dialog, preshow, postshow)&lt;br /&gt;
 wesnoth.message(string.format(&amp;quot;Button %d pressed. Item %d selected.&amp;quot;, r, li))&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_value ====&lt;br /&gt;
&lt;br /&gt;
Sets the value of a widget on the current dialog. The value is given by the first argument; its semantic depends on the type of widget it is applied to. The last argument is the ''id'' of the widget. If it does not point to a unique widget in the dialog, some discriminating parents should be given on its left, making a path that is read from left to right by the engine. The row of a list is specified by giving the ''id' of the list as a first argument and the 1-based row number as the next argument.&lt;br /&gt;
&lt;br /&gt;
 -- sets the value of a widget &amp;quot;bar&amp;quot; in the 7th row of the list &amp;quot;foo&amp;quot;&lt;br /&gt;
 wesnoth.set_value(_&amp;quot;Hello world&amp;quot;, &amp;quot;foo&amp;quot;, 7, &amp;quot;bar&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Notes: When the row of a list does not exist, it is created. The value associated to a list is the selected row.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.get_dialog_value ====&lt;br /&gt;
&lt;br /&gt;
Gets the value of a widget on the current dialog. The arguments described the path for reaching the widget (see [[#wesnoth.set_dialog_value]]).&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_active ====&lt;br /&gt;
&lt;br /&gt;
Enables or disables a widget.  The first argument is a boolean specifying whether the widget should be active (true) or inactive (false).  The remaining arguments are the path to locate the widget in question (see [[#wesnoth.set_dialog_value]]).&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_callback ====&lt;br /&gt;
&lt;br /&gt;
Sets the first argument as a callback function for the widget obtained by following the path of the other arguments (see [[#wesnoth.set_dialog_value]]). This function will be called whenever the user modifies something about the widget, so that the dialog can react to it.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_canvas ====&lt;br /&gt;
&lt;br /&gt;
Sets the WML passed as the second argument as the canvas content (index given by the first argument) of the widget obtained by following the path of the other arguments (see [[#wesnoth.set_dialog_value]]). The content of the WML table is described at [[GUICanvasWML]].&lt;br /&gt;
&lt;br /&gt;
 -- draw two rectangles in the upper-left corner of the window (empty path = window widget)&lt;br /&gt;
 wesnoth.set_dialog_canvas(2, {&lt;br /&gt;
     T.rectangle { x = 20, y = 20, w = 20, h = 20, fill_color= &amp;quot;0,0,255,255&amp;quot; },&lt;br /&gt;
     T.rectangle { x = 30, y = 30, w = 20, h = 20, fill_color = &amp;quot;255,0,0,255&amp;quot; }&lt;br /&gt;
 })&lt;br /&gt;
&lt;br /&gt;
The meaning of the canvas index depends on the chosen widget. It may be the disabled / enabled states of the widget, or its background / foreground planes, or... For instance, overwriting canvas 1 of the window with an empty canvas causes the window to become transparent.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.get_displayed_unit ====&lt;br /&gt;
&lt;br /&gt;
Returns a proxy to the unit currently displayed in the side pane of the user interface, if any.&lt;br /&gt;
&lt;br /&gt;
 local name = tostring(wesnoth.get_displayed_unit().name)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.theme_items ====&lt;br /&gt;
&lt;br /&gt;
This field is not a function but an associative table. It links item names to the functions that describe their content. These functions are called whenever the user interface is refreshed. The description of an item is a WML table containing '''[element]''' children. Each subtag shall contain either a '''text''' or an '''image''' field that is displayed to the user. It can also contain a '''tooltip''' field that is displayed to the user when moused over, and a &amp;quot;help&amp;quot; field that points to the help section that is displayed when the user clicks on the theme item.&lt;br /&gt;
&lt;br /&gt;
Note that the ''wesnoth.theme_items'' table is originally empty and using ''pairs'' or ''next'' on it will not return the items from the current theme. Its metatable ensures that the drawing functions of existing items can be recovered though, as long as their name is known. The example below shows how to modify the ''unit_status'' item to display a custom status:&lt;br /&gt;
&lt;br /&gt;
 local old_unit_status = wesnoth.theme_items.unit_status&lt;br /&gt;
 function wesnoth.theme_items.unit_status()&lt;br /&gt;
     local u = wesnoth.get_displayed_unit()&lt;br /&gt;
     if not u then return {} end&lt;br /&gt;
         local s = old_unit_status()&lt;br /&gt;
         if u.status.entangled then&lt;br /&gt;
             table.insert(s, { &amp;quot;element&amp;quot;, {&lt;br /&gt;
                 image = &amp;quot;entangled.png&amp;quot;,&lt;br /&gt;
                 tooltip = _&amp;quot;entangled: This unit is entangled. It cannot move but it can still attack.&amp;quot;&lt;br /&gt;
             } })&lt;br /&gt;
         end&lt;br /&gt;
     return s&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==== helper.get_user_choice ====&lt;br /&gt;
&lt;br /&gt;
Displays a WML message box querying a choice from the user. Attributes and options are taken from given tables (see [[InterfaceActionsWML#.5Bmessage.5D|[message]]]). The index of the selected option is returned.&lt;br /&gt;
&lt;br /&gt;
 local result = helper.get_user_choice({ speaker = &amp;quot;narrator&amp;quot; }, { &amp;quot;Choice 1&amp;quot;, &amp;quot;Choice 2&amp;quot; })&lt;br /&gt;
&lt;br /&gt;
[[Category: Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=LuaWML/Display&amp;diff=46706</id>
		<title>LuaWML/Display</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=LuaWML/Display&amp;diff=46706"/>
		<updated>2012-06-19T01:25:15Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* wesnoth.play_sound */ Clarified the way the repetition argument is used in the function&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the [[LuaWML]] functions and helpers for interfacing with the user.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.message ====&lt;br /&gt;
&lt;br /&gt;
Displays a string in the chat window and dumps it to the lua/info log domain (''--log-info=scripting/lua'' on the command-line).&lt;br /&gt;
&lt;br /&gt;
 wesnoth.message &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
The chat line header is &amp;quot;&amp;lt;Lua&amp;gt;&amp;quot; by default, but it can be changed by passing a string before the message.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.message(&amp;quot;Big Brother&amp;quot;, &amp;quot;I'm watching you.&amp;quot;) -- will result in &amp;quot;&amp;amp;lt;Big Brother&amp;amp;gt; I'm watching you.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
See also [[LuaWML:Events#helper.wml_error|helper.wml_error]] for displaying error messages.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.clear_messages ====&lt;br /&gt;
&lt;br /&gt;
Removes all messages from the chat window. No argument or returned values.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.textdomain ====&lt;br /&gt;
&lt;br /&gt;
Creates a function proxy for lazily translating strings from the given domain.&lt;br /&gt;
&lt;br /&gt;
 -- #textdomain &amp;quot;my-campaign&amp;quot;&lt;br /&gt;
 -- the comment above ensures the subsequent strings will be extracted to the proper domain&lt;br /&gt;
 _ = wesnoth.textdomain &amp;quot;my-campaign&amp;quot;&lt;br /&gt;
 wesnoth.set_variable(&amp;quot;my_unit.description&amp;quot;, _ &amp;quot;the unit formerly known as Hero&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
The metatable of the function proxy appears as '''&amp;quot;message domain&amp;quot;'''. The metatable of the translatable strings (results of the proxy) appears as '''&amp;quot;translatable string&amp;quot;'''.&lt;br /&gt;
&lt;br /&gt;
The translatable strings can be appended to other strings/numbers with the standard '''..''' operator. Translation can be forced with the standard '''tostring''' operator in order to get a plain string.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.message(string.format(tostring(_ &amp;quot;You gain %d gold.&amp;quot;), amount))&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.delay ====&lt;br /&gt;
&lt;br /&gt;
Delays the engine like the [delay] tag. one argument: time to delay in milliseconds&lt;br /&gt;
&lt;br /&gt;
 wesnoth.delay(500)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.float_label ====&lt;br /&gt;
&lt;br /&gt;
Pops some text above a map tile.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.float_label(unit.x, unit.y, &amp;quot;&amp;amp;lt;span color='#ff0000'&amp;amp;gt;Ouch&amp;amp;lt;/span&amp;amp;gt;&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.get_time_of_day ====&lt;br /&gt;
&lt;br /&gt;
Returns schedule information. First parameter (optional) is the turn number for which to return the information, if unspecified: the current turn ($turn_number). Second argument is an optional table. If present, first and second fields must be valid on-map coordinates and all current time_areas in the scenario are taken into account (if a time area happens to contain the passed hex). If the table isn't present, the scenario main schedule is returned. The table has an optional third parameter (boolean). If true (default: false), time of day modifying units (such as MoL) are taken into account (if the passed hex happens to be affected). The units placement being considered is always the current one.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.get_time_of_day(2, { 37, 3, true })&lt;br /&gt;
&lt;br /&gt;
The function returns a table with these named fields:&lt;br /&gt;
* '''id''': string (as in [time])&lt;br /&gt;
* '''lawful_bonus''': integer (as in [time])&lt;br /&gt;
* '''bonus_modified''': integer (bonus change by units)&lt;br /&gt;
* '''image''': string (tod image in sidebar)&lt;br /&gt;
* '''name''': translatable string&lt;br /&gt;
* '''red, green, blue''': integers (color adjustment for this time)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.select_hex ====&lt;br /&gt;
&lt;br /&gt;
Selects the given location in the game map as if the player would have clicked onto it.&lt;br /&gt;
Argument 3: boolean, whether to show the movement range of any unit on that location (def: true)&lt;br /&gt;
Argument 4: boolean, whether to fire any select events (def: false)&lt;br /&gt;
&lt;br /&gt;
 wesnoth.select_hex(14,6, true, true)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.scroll_to_tile ====&lt;br /&gt;
&lt;br /&gt;
Scrolls the map to the given location. If true is passed as the third parameter, scrolling is disabled if the tile is hidden under the fog. If true is passed as the fourth parameter {{DevFeature1.11}}, the view instantly warps to the location regardless of the scroll speed setting in Preferences.&lt;br /&gt;
&lt;br /&gt;
 local u = wesnoth.get_units({ id = &amp;quot;hero&amp;quot; })[1]&lt;br /&gt;
 wesnoth.scroll_to_tile(u.x, u.y)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.lock_view ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.11}} Locks or unlocks gamemap view scrolling for human players. If true is passed as the first parameter, the view is locked; pass false to unlock.&lt;br /&gt;
&lt;br /&gt;
Human players cannot scroll the gamemap view as long as it is locked, but Lua or WML actions such as wesnoth.scroll_to_tile still can; 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.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.lock_view(true)&lt;br /&gt;
 wesnoth.scroll_to_tile(12, 14, false, true)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.view_locked ====&lt;br /&gt;
&lt;br /&gt;
{{DevFeature1.11}} Returns a boolean indicating whether gamemap view scrolling is currently locked.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.play_sound ====&lt;br /&gt;
&lt;br /&gt;
Plays the given sound file once, optionally repeating it one or more more times if a integer is provided as a second argument (note that the sound is ''repeated'' the number of times specified in the second argument, i.e. a second argument of 4 will cause the sound to be played once and then repeated four more times. See the example below).&lt;br /&gt;
&lt;br /&gt;
 wesnoth.play_sound &amp;quot;ambient/birds1.ogg&amp;quot;&lt;br /&gt;
 wesnoth.play_sound(&amp;quot;magic-holy-miss-3.ogg&amp;quot;, 4) -- played 1 + 4 = 5 times&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_music ====&lt;br /&gt;
&lt;br /&gt;
Sets the given table as an entry into the music list. See [[MusicListWML]] for the recognized attributes.&lt;br /&gt;
&lt;br /&gt;
 wesnoth.set_music { name = &amp;quot;traveling_minstrels.ogg&amp;quot; }&lt;br /&gt;
&lt;br /&gt;
Passing no argument forces the engine to take into account all the recent changes to the music list. (Note: this is done automatically when sequences of WML commands end, so it is useful only for long events.)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.show_dialog ====&lt;br /&gt;
&lt;br /&gt;
Displays a dialog box described by a WML table and returns:&lt;br /&gt;
* if the dialog was dismissed by a button click, the integer value associated to the button via the &amp;quot;return_value&amp;quot; keyword.&lt;br /&gt;
* if the dialog was closed with the enter key, -1.&lt;br /&gt;
* if the dialog was closed with the escape key, -2.&lt;br /&gt;
&lt;br /&gt;
The dialog box is equivalent to the resolution section of a GUI window as described in [[GUIToolkitWML#Window_definition|GUIToolkitWML]] and must therefore contain at least the following children: '''[tooltip]''', '''[helptip]''', and '''[grid]'''. The [grid] must contain nested [row], [column] and [grid] tags which describe the layout of the window. (More information can be found in [[GUILayout]]; suffice to say that the basic structure is grid -&amp;gt; row -&amp;gt; column -&amp;gt; widget, where the widget is considered to be in a cell defined by the row and column of the grid. A list of widgets can be found at [[GUIWidgetInstanceWML]].)&lt;br /&gt;
&lt;br /&gt;
Two optional functions can be passed as second and third arguments; the first one is called once the dialog is created and before it is shown; the second one is called once the dialog is closed. These functions are helpful in setting the initial values of the fields and in recovering the final user values. These functions can call the [[#wesnoth.set_dialog_value]], [[#wesnoth.get_dialog_value]], and [[#wesnoth.set_dialog_callback]] functions for this purpose.&lt;br /&gt;
&lt;br /&gt;
This function should be called in conjunction with [[LuaWML:Misc#wesnoth.synchronize_choice|#wesnoth.synchronize_choice]], in order to ensure that only one client displays the dialog and that the other ones recover the same input values from this single client.&lt;br /&gt;
&lt;br /&gt;
The example below defines a dialog with a list and two buttons on the left, and a big image on the right. The ''preshow'' function fills the list and defines a callback on it. This ''select'' callback changes the displayed image whenever a new list item is selected. The ''postshow'' function recovers the selected item before the dialog is destroyed.&lt;br /&gt;
&lt;br /&gt;
 local helper = wesnoth.require &amp;quot;lua/helper.lua&amp;quot;&lt;br /&gt;
 local T = helper.set_wml_tag_metatable {}&lt;br /&gt;
 local _ = wesnoth.textdomain &amp;quot;wesnoth&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 local dialog = {&lt;br /&gt;
   T.tooltip { id = &amp;quot;tooltip_large&amp;quot; },&lt;br /&gt;
   T.helptip { id = &amp;quot;tooltip_large&amp;quot; },&lt;br /&gt;
   T.grid { T.row {&lt;br /&gt;
     T.column { T.grid {&lt;br /&gt;
       T.row { T.column { horizontal_grow = true, T.listbox { id = &amp;quot;the_list&amp;quot;,&lt;br /&gt;
         T.list_definition { T.row { T.column { horizontal_grow = true,&lt;br /&gt;
           T.toggle_panel { T.grid { T.row {&lt;br /&gt;
             T.column { horizontal_alignment = &amp;quot;left&amp;quot;, T.label { id = &amp;quot;the_label&amp;quot; } },&lt;br /&gt;
             T.column { T.image { id = &amp;quot;the_icon&amp;quot; } }&lt;br /&gt;
           } } }&lt;br /&gt;
         } } }&lt;br /&gt;
       } } },&lt;br /&gt;
       T.row { T.column { T.grid { T.row {&lt;br /&gt;
         T.column { T.button { id = &amp;quot;ok&amp;quot;, label = _&amp;quot;OK&amp;quot; } },&lt;br /&gt;
         T.column { T.button { id = &amp;quot;cancel&amp;quot;, label = _&amp;quot;Cancel&amp;quot; } }&lt;br /&gt;
       } } } }&lt;br /&gt;
     } },&lt;br /&gt;
     T.column { T.image { id = &amp;quot;the_image&amp;quot; } }&lt;br /&gt;
   } }&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 local function preshow()&lt;br /&gt;
     local t = { &amp;quot;Ancient Lich&amp;quot;, &amp;quot;Ancient Wose&amp;quot;, &amp;quot;Elvish Avenger&amp;quot; }&lt;br /&gt;
     local function select()&lt;br /&gt;
         local i = wesnoth.get_dialog_value &amp;quot;the_list&amp;quot;&lt;br /&gt;
         local ut = wesnoth.unit_types[t[i]].__cfg&lt;br /&gt;
         wesnoth.set_dialog_value(string.gsub(ut.profile, &amp;quot;([^/]+)$&amp;quot;, &amp;quot;transparent/%1&amp;quot;), &amp;quot;the_image&amp;quot;)&lt;br /&gt;
     end&lt;br /&gt;
     wesnoth.set_dialog_callback(select, &amp;quot;the_list&amp;quot;)&lt;br /&gt;
     for i,v in ipairs(t) do&lt;br /&gt;
         local ut = wesnoth.unit_types[v].__cfg&lt;br /&gt;
         wesnoth.set_dialog_value(ut.name, &amp;quot;the_list&amp;quot;, i, &amp;quot;the_label&amp;quot;)&lt;br /&gt;
         wesnoth.set_dialog_value(ut.image, &amp;quot;the_list&amp;quot;, i, &amp;quot;the_icon&amp;quot;)&lt;br /&gt;
     end&lt;br /&gt;
     wesnoth.set_dialog_value(2, &amp;quot;the_list&amp;quot;)&lt;br /&gt;
     select()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local li = 0&lt;br /&gt;
 local function postshow()&lt;br /&gt;
     li = wesnoth.get_dialog_value &amp;quot;the_list&amp;quot;&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local r = wesnoth.show_dialog(dialog, preshow, postshow)&lt;br /&gt;
 wesnoth.message(string.format(&amp;quot;Button %d pressed. Item %d selected.&amp;quot;, r, li))&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_value ====&lt;br /&gt;
&lt;br /&gt;
Sets the value of a widget on the current dialog. The value is given by the first argument; its semantic depends on the type of widget it is applied to. The last argument is the ''id'' of the widget. If it does not point to a unique widget in the dialog, some discriminating parents should be given on its left, making a path that is read from left to right by the engine. The row of a list is specified by giving the ''id' of the list as a first argument and the 1-based row number as the next argument.&lt;br /&gt;
&lt;br /&gt;
 -- sets the value of a widget &amp;quot;bar&amp;quot; in the 7th row of the list &amp;quot;foo&amp;quot;&lt;br /&gt;
 wesnoth.set_value(_&amp;quot;Hello world&amp;quot;, &amp;quot;foo&amp;quot;, 7, &amp;quot;bar&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
Notes: When the row of a list does not exist, it is created. The value associated to a list is the selected row.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.get_dialog_value ====&lt;br /&gt;
&lt;br /&gt;
Gets the value of a widget on the current dialog. The arguments described the path for reaching the widget (see [[#wesnoth.set_dialog_value]]).&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_active ====&lt;br /&gt;
&lt;br /&gt;
Enables or disables a widget.  The first argument is a boolean specifying whether the widget should be active (true) or inactive (false).  The remaining arguments are the path to locate the widget in question (see [[#wesnoth.set_dialog_value]]).&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_callback ====&lt;br /&gt;
&lt;br /&gt;
Sets the first argument as a callback function for the widget obtained by following the path of the other arguments (see [[#wesnoth.set_dialog_value]]). This function will be called whenever the user modifies something about the widget, so that the dialog can react to it.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.set_dialog_canvas ====&lt;br /&gt;
&lt;br /&gt;
Sets the WML passed as the second argument as the canvas content (index given by the first argument) of the widget obtained by following the path of the other arguments (see [[#wesnoth.set_dialog_value]]). The content of the WML table is described at [[GUICanvasWML]].&lt;br /&gt;
&lt;br /&gt;
 -- draw two rectangles in the upper-left corner of the window (empty path = window widget)&lt;br /&gt;
 wesnoth.set_dialog_canvas(2, {&lt;br /&gt;
     T.rectangle { x = 20, y = 20, w = 20, h = 20, fill_color= &amp;quot;0,0,255,255&amp;quot; },&lt;br /&gt;
     T.rectangle { x = 30, y = 30, w = 20, h = 20, fill_color = &amp;quot;255,0,0,255&amp;quot; }&lt;br /&gt;
 })&lt;br /&gt;
&lt;br /&gt;
The meaning of the canvas index depends on the chosen widget. It may be the disabled / enabled states of the widget, or its background / foreground planes, or... For instance, overwriting canvas 1 of the window with an empty canvas causes the window to become transparent.&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.get_displayed_unit ====&lt;br /&gt;
&lt;br /&gt;
Returns a proxy to the unit currently displayed in the side pane of the user interface, if any.&lt;br /&gt;
&lt;br /&gt;
 local name = tostring(wesnoth.get_displayed_unit().name)&lt;br /&gt;
&lt;br /&gt;
==== wesnoth.theme_items ====&lt;br /&gt;
&lt;br /&gt;
This field is not a function but an associative table. It links item names to the functions that describe their content. These functions are called whenever the user interface is refreshed. The description of an item is a WML table containing '''[element]''' children. Each subtag shall contain either a '''text''' or an '''image''' field that is displayed to the user. It can also contain a '''tooltip''' field that is displayed to the user when moused over, and a &amp;quot;help&amp;quot; field that points to the help section that is displayed when the user clicks on the theme item.&lt;br /&gt;
&lt;br /&gt;
Note that the ''wesnoth.theme_items'' table is originally empty and using ''pairs'' or ''next'' on it will not return the items from the current theme. Its metatable ensures that the drawing functions of existing items can be recovered though, as long as their name is known. The example below shows how to modify the ''unit_status'' item to display a custom status:&lt;br /&gt;
&lt;br /&gt;
 local old_unit_status = wesnoth.theme_items.unit_status&lt;br /&gt;
 function wesnoth.theme_items.unit_status()&lt;br /&gt;
     local u = wesnoth.get_displayed_unit()&lt;br /&gt;
     if not u then return {} end&lt;br /&gt;
         local s = old_unit_status()&lt;br /&gt;
         if u.status.entangled then&lt;br /&gt;
             table.insert(s, { &amp;quot;element&amp;quot;, {&lt;br /&gt;
                 image = &amp;quot;entangled.png&amp;quot;,&lt;br /&gt;
                 tooltip = _&amp;quot;entangled: This unit is entangled. It cannot move but it can still attack.&amp;quot;&lt;br /&gt;
             } })&lt;br /&gt;
         end&lt;br /&gt;
     return s&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
==== helper.get_user_choice ====&lt;br /&gt;
&lt;br /&gt;
Displays a WML message box querying a choice from the user. Attributes and options are taken from given tables (see [[InterfaceActionsWML#.5Bmessage.5D|[message]]]). The index of the selected option is returned.&lt;br /&gt;
&lt;br /&gt;
 local result = helper.get_user_choice({ speaker = &amp;quot;narrator&amp;quot; }, { &amp;quot;Choice 1&amp;quot;, &amp;quot;Choice 2&amp;quot; })&lt;br /&gt;
&lt;br /&gt;
[[Category: Lua Reference]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Creating_Unit_Art&amp;diff=46646</id>
		<title>Creating Unit Art</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Creating_Unit_Art&amp;diff=46646"/>
		<updated>2012-05-31T13:25:04Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: Changed spellings of &amp;quot;colour&amp;quot; to &amp;quot;color&amp;quot;, clarified some information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here's the information needed to start doing units art for Wesnoth. Please update the wiki with links to examples and other tips and tricks realted to unit art. This page started from [http://www.wesnoth.org/forum/viewtopic.php?p=104809#104809 this forum thread]. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' The Medium '''&lt;br /&gt;
&lt;br /&gt;
The medium used to create unit art is known as 'pixel art'. If you do not understand what pixel art is, or if you have only a general understanding of what it is, I suggest reading [http://www.pixeljoint.com/forum/forum_posts.asp?TID=11299 The Pixel Art Tutorial] by Cure. It is a tutorial comprised of a series of sequential forum posts on the www.pixeljoint.com forum and gives an in-depth overview of pixel art, explaining in detail what pixel art is and what it is not. Using other mediums (such as brush art) to create unit art is fine if you are creating unit art for [[WesnothAcronyms|UMC]] add-ons (although it is still strongly recommended that you use pixel art for the sake of consistency with mainline units), but only units drawn in pure pixel art will be accepted into mainline.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Basic unit image specifications '''&lt;br /&gt;
&lt;br /&gt;
Wesnoth can only use two kinds of graphic files:  PNGs, or JPEGs.  JPEGs aren't suitable for unit images, because they can't store transparency data (and are lossy).  Because of this, we always use PNGs for unit images.&lt;br /&gt;
*Final format: transparent PNG&lt;br /&gt;
** Color depth should be 24-bit (8 bits per RGB channel).  This may be listed as &amp;quot;PNG-24&amp;quot; or &amp;quot;8-bit RGBA&amp;quot;.&lt;br /&gt;
** Be aware that &amp;quot;Indexed color&amp;quot;, &amp;quot;color map&amp;quot;, or &amp;quot;PNG-8&amp;quot; is a different format.  Although it might work in a buggy way, we strongly recommend you not use these.&lt;br /&gt;
*  Canvas size is 72 x 72 pixels (it can actually be slightly wider, and can fit in the area of a hex and its immediately surrounding tiles, but try not to do this if at all possible, because it has performance and graphical glitch issues).&lt;br /&gt;
*All but exceptionally large units should be contained in the hex if possible (the white in the attached template)&lt;br /&gt;
*Compare the size of your unit to the size of similar existing core units&lt;br /&gt;
*Light comes from the artist's (''not'' the unit's!) upper right (for shading and highlights) &lt;br /&gt;
*Unit must look in the lower right (again, the artist's lower right, not the unit's) direction&lt;br /&gt;
*Units are centered horizontally &lt;br /&gt;
*Unit's feet are positioned around 55 pixel down from the top edge of the canvas, lower for taller units if necessary&lt;br /&gt;
*Shadows at 60 opacity, using a specific dark blue color (see [[Creating_Shadows_Under_Units|Creating Shadows Under Units]]). &lt;br /&gt;
*Outlines should be used, made with a darker, but similar color to what they're surrounding, this makes the unit feel bigger then the amount of pixels you'd use for the same with a black outline. Note that pure black (RGB #000000) should ''never'' be used to outline a sprite.&lt;br /&gt;
*Use consistent names for your files, beginning with the unit name, so that they are kept together when browsing the files.  Try to imitate the naming scheme used for mainline units.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Unit animation specifications '''&lt;br /&gt;
&lt;br /&gt;
You can have as many frames for animations as you like, and in fact, for any given cue, you can have more than one animation, which will be randomly chosen by the game.  Images and animations must be done for: &lt;br /&gt;
*base frame (1 frame) &lt;br /&gt;
*attack for each type (at least 4 frames, about 6 frames is optimal depending on the type of attack and the weapon(s) involved) &lt;br /&gt;
*directional attacks (generally are desired for any attack that's a straight motion, rather than a slash.  I.e. spears and thundersticks) &lt;br /&gt;
*defense (usually 2 frames long not including the base frame, separate animations may be drawn for ranged and melee defense animations)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''' Additional Notes '''&lt;br /&gt;
&lt;br /&gt;
*Test early with different backgrounds. Go to your game terrain files, pick, say, 3 terrains, preferably with different colors, and have a look what they look like against the background, because that way if you have used alpha channels, it may look better in game than as the average standard sprite. &lt;br /&gt;
&lt;br /&gt;
*Test your unit early in the game. Replacing an existing unit graphic with yours is the fastest way (be sure to make a copy of the originals so you don't lose them.) &lt;br /&gt;
&lt;br /&gt;
*Test your unit next to mainline units in-game. This will help you ensure that your unit matches the style and proportions of the mainline units as closely as possible.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[BuildingUnits]]&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[Create Art and Music]]&lt;br /&gt;
* [[Art Tutorials]]&lt;br /&gt;
&lt;br /&gt;
[[Category: Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=AnimationWML&amp;diff=46524</id>
		<title>AnimationWML</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=AnimationWML&amp;diff=46524"/>
		<updated>2012-04-27T16:22:44Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Field Description */ Clarified that directional_x and directional_y offsets are measured in pixels&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{WML Tags}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This page covers unit animations. At any point in game, units are playing an animation. Even when the unit is standing, it is actually playing a single frame animation.&lt;br /&gt;
&lt;br /&gt;
This page will deal with the two problems of animations&lt;br /&gt;
* How are animations chosen&lt;br /&gt;
* What exactly is drawn&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How animations are drawn ==&lt;br /&gt;
=== Animations ===&lt;br /&gt;
Any unit has a huge set of animations to choose from. Animations are WML blocks in the unit type, enclosed in either the generic type '''[animation]''' or some more specific tags such as '''[attack_anim]''' '''[idle_anim]''' and the like. An animation is what a unit displays when a given event is triggered, and a certain set of conditions are met such as&lt;br /&gt;
* unit is attacking&lt;br /&gt;
* unit is idling&lt;br /&gt;
* unit is attacking (event) and uses a melee weapon (condition)&lt;br /&gt;
* unit is attacking (event) and uses a melee weapon (condition) and opponent can't retaliate (condition)&lt;br /&gt;
&lt;br /&gt;
events and conditions are described entirely in the [animation] block, and will be discussed in the animation choice section.&lt;br /&gt;
&lt;br /&gt;
=== Frames ===&lt;br /&gt;
    &lt;br /&gt;
An animation is cut in frames. Frames are WML blocks that are contained either in '''[frame]''' WML blocks or in generic '''[xxx_frame]''' block. (the xxx part can be any string not starting with an underscore) the xxx part in the frame name is called the frame prefix. frames of the type '''[frame]''' are said to have an empty prefix&lt;br /&gt;
&lt;br /&gt;
A frame typically describes an image, where an how to render it. It can contain such things as&lt;br /&gt;
* the image to display&lt;br /&gt;
* how transparent should that image be&lt;br /&gt;
* where to draw that image.&lt;br /&gt;
&lt;br /&gt;
At any given time, an animation will display one frame for each frame prefix it can find. I.e if your animation has both '''[frame]''' and '''[missile_frame]''' blocks, both will be displayed at the same time&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The frame with the empty prefix is special in many way. It is assumed to contain the image representing the unit itself, and as such the engine will heavily temper with it in multiple ways, such as providing a default image if none is available, or forcing the image to be green when the unit is poisoned&lt;br /&gt;
&lt;br /&gt;
=== Timing, Clock, Multiple animations ===&lt;br /&gt;
When an animation is played it has an internal clock that is run. The step of this clock is the milisecond, and each frame is played for a given duration. Each animation also has a starting time which tells the animation engine at what value the animation clock should start&lt;br /&gt;
&lt;br /&gt;
This starting time is very important when multiple animations from different units are played synchronously  Typically a fight involves a unit playing its defense animation while the opponent plays it's attack animation (and a third might play its leading animation, too). In that case all animations have a common clock, and are played concurrently.&lt;br /&gt;
&lt;br /&gt;
The convention is that the &amp;quot;important time&amp;quot; (usually the time of the hit) is at time 0. everything before should be at negative time, everything after at positive time. This is a WML convention that is not enforced by the engine&lt;br /&gt;
&lt;br /&gt;
In that case, it is very important that these animations (which can have different lengths) be synchronized. Fight animations are synchronized around the point of impact, so they all reach time 0 when the attack lands (or misses). This is accomplished through the use of the '''start_time''' key of the '''[animation]''' tag.&lt;br /&gt;
&lt;br /&gt;
Just like the '''[frame]''' tag can have a prefix, so can the '''start_time''' key. A '''start_time''' key without prefix will affect a '''[frame]''' tag without prefix, while a '''start_time''' key with a prefix will affect a '''[frame]''' tag with the same prefix.&lt;br /&gt;
&lt;br /&gt;
==== Example Syntax ====&lt;br /&gt;
    [attack_anim]&lt;br /&gt;
        [filter_attack]&lt;br /&gt;
            name=bow&lt;br /&gt;
        [/filter_attack]&lt;br /&gt;
        '''start_time'''=-350&lt;br /&gt;
        '''missile_start_time'''=-150&lt;br /&gt;
        [missile_frame]&lt;br /&gt;
            duration=150&lt;br /&gt;
            image=&amp;quot;projectiles/missile-n.png&amp;quot;&lt;br /&gt;
            image_diagonal=&amp;quot;projectiles/missile-ne.png&amp;quot;&lt;br /&gt;
        [/missile_frame]&lt;br /&gt;
        [if]&lt;br /&gt;
            hits=yes&lt;br /&gt;
            [frame]&lt;br /&gt;
                duration=350&lt;br /&gt;
                sound=bow.ogg&lt;br /&gt;
            [/frame]&lt;br /&gt;
        [/if]&lt;br /&gt;
        [else]&lt;br /&gt;
            hits=no&lt;br /&gt;
            [frame]&lt;br /&gt;
                duration=350&lt;br /&gt;
                sound=bow-miss.ogg&lt;br /&gt;
            [/frame]&lt;br /&gt;
        [/else]&lt;br /&gt;
    [/attack_anim]&lt;br /&gt;
&lt;br /&gt;
=== The content of a frame ===&lt;br /&gt;
==== Syntax summary ====&lt;br /&gt;
 [frame]&lt;br /&gt;
    duration=&amp;lt;integer&amp;gt;&lt;br /&gt;
    begin=&amp;lt;deprecated,integer&amp;gt;&lt;br /&gt;
    end=&amp;lt;deprecated,integer&amp;gt;&lt;br /&gt;
    image=&amp;lt;string&amp;gt;&lt;br /&gt;
    image_diagonal=&amp;lt;string&amp;gt;&lt;br /&gt;
    image_mod=&amp;lt;string&amp;gt;&lt;br /&gt;
    sound=&amp;lt;string&amp;gt;&lt;br /&gt;
    halo=&amp;lt;progressive string&amp;gt;&lt;br /&gt;
    halo_x=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
    halo_y=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
    halo_mod=&amp;lt;string&amp;gt;&lt;br /&gt;
    alpha=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
    offset=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
    blend_color=&amp;lt;red, green, blue&amp;gt;&lt;br /&gt;
    blend_ratio=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
    text=&amp;lt;string&amp;gt;&lt;br /&gt;
    text_color=&amp;lt; red, green, blue &amp;gt;&lt;br /&gt;
    submerge=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
    x=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
    y=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
    directional_x=&amp;lt;dev feature 1.9,progressive int&amp;gt;&lt;br /&gt;
    directional_y=&amp;lt;dev feature 1.9,progressive int&amp;gt;&lt;br /&gt;
    layer=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
    auto_hflip=&amp;lt;dev feature 1.9, boolean&amp;gt;&lt;br /&gt;
    auto_vflip=&amp;lt;dev feature 1.9, boolean&amp;gt;&lt;br /&gt;
    primary=&amp;lt;dev feature 1.9, boolean&amp;gt;&lt;br /&gt;
 [/frame]&lt;br /&gt;
&lt;br /&gt;
==== Progressive parameters ====&lt;br /&gt;
&lt;br /&gt;
Some parameters above are marked as ''progressive'' This means that you can specify that during the time the frame is displayed, the parameter should smoothly slide from one value to an other.&lt;br /&gt;
&lt;br /&gt;
A typical example would be a unit progressively fading out, becoming transparent&lt;br /&gt;
&lt;br /&gt;
To do that, you could use:&lt;br /&gt;
&lt;br /&gt;
 alpha=1~0&lt;br /&gt;
&lt;br /&gt;
To make a frame, which is 900ms long, slide to transparent for 300ms, stay transparent for another 300ms and finally fade back to normal for 300ms, use:&lt;br /&gt;
&lt;br /&gt;
 alpha=1~0:300,0:300,0~1:300&lt;br /&gt;
&lt;br /&gt;
you could also specify it like that&lt;br /&gt;
&lt;br /&gt;
 alpha=1~0,0,0~1&lt;br /&gt;
&lt;br /&gt;
when a timing is missing, the engine will do its best to fill in in a fair way. &lt;br /&gt;
&lt;br /&gt;
a progressive string has a similar syntax&lt;br /&gt;
&lt;br /&gt;
 halo=halo1.png:300,halo2.png:300,halo2.png:300&lt;br /&gt;
&lt;br /&gt;
==== Field Description ====&lt;br /&gt;
&lt;br /&gt;
** '''begin''': (deprecated) will be replaced by '''duration= &amp;lt;end - begin &amp;gt;'''&lt;br /&gt;
** '''end''': (deprecated) see '''begin''' and also [[AnimationWML#Timing.2C_Clock.2C_Multiple_animations|Timing, Clock, Multiple animations]] section for coverage of '''start_time''' which combines with '''duration''' to replace '''begin=''' '''end='''.&lt;br /&gt;
** '''duration''': how long the frame should be displayed. Use instead of '''begin=''' and '''end='''.&lt;br /&gt;
** '''image''': the image to display during the frame.&lt;br /&gt;
** '''image_diagonal''': the image to display when the attack occurs diagonally (directions ne,se,sw,nw).&lt;br /&gt;
** '''image_mod''': a string modifications (see [[ImagePathFunctionWML]] ) that will be applied to all images&lt;br /&gt;
** '''sound''': the sound to play when the frame begins. Can be a comma-separated list of sounds, in which case one of them is chosen randomly every time.&lt;br /&gt;
** '''halo''': the halo to display at the time.&lt;br /&gt;
** '''halo_x''': the position the halo is displayed in pixel relative to the unit's center.&lt;br /&gt;
** '''halo_y''': the position the halo is displayed in pixel relative to the unit's center.&lt;br /&gt;
** '''halo_mod''': a string modifications (see [[ImagePathFunctionWML]] ) that will be applied to all haloes&lt;br /&gt;
** '''alpha''': transparency level to apply to the frame. This is a floating point progressive parameter ranging from 0.0 to 1.0.&lt;br /&gt;
** '''offset''': the position of the image relative to the hex the unit is facing, 0.0 will display the unit in the center of the hex, 1.0 in the center of the faced hex, -1.0 at the center of the hex behind you. This is a progressive parameter.&lt;br /&gt;
** '''blend_color''': a comma separated list of numbers representing a color in RGB (0-255); this color will be mixed to the frame to give it a tint.&lt;br /&gt;
** '''blend_ratio''': this is a progressive parameter ranging from 0 to 1: 0 means no tint, 1 means target color only.&lt;br /&gt;
** '''text''': if specified, floats a label with the given text above the unit (identical to the floating damage and healing numbers).&lt;br /&gt;
** '''text_color''': the color of the above floating label.&lt;br /&gt;
** '''submerge''': the part of the unit that should drawn with 50% opacity (for units in water)&lt;br /&gt;
** '''x''': x offset applied to the frame&lt;br /&gt;
** '''y''': y offset applied to the frame&lt;br /&gt;
** '''directional_x''': the x offset, in pixels, applied to the frame in the direction the unit is facing&lt;br /&gt;
** '''directional_y''': the y offset, in pixels, applied to the frame in the direction the unit is facing&lt;br /&gt;
** '''layer''': layer used to draw the frame, see discussion bellow&lt;br /&gt;
** '''auto_hflip''': should the image flip horizontally depending on sprite orientation&lt;br /&gt;
** '''auto_vflip''': should the image flip vertically depending on sprite orientation&lt;br /&gt;
** '''primary''': should the engine consider that frame as a primary frame (affected by visual effects like stone and poison)&lt;br /&gt;
&lt;br /&gt;
=== Drawing related animation content ===&lt;br /&gt;
==== Syntax summary ====&lt;br /&gt;
 [animation]&lt;br /&gt;
   &amp;lt;animation choice related content&amp;gt;&lt;br /&gt;
   [frame]&lt;br /&gt;
     &amp;lt;frame content&amp;gt;&lt;br /&gt;
   [/frame]&lt;br /&gt;
   [frame]&lt;br /&gt;
     &amp;lt;frame content&amp;gt;&lt;br /&gt;
   [/frame]&lt;br /&gt;
   start_time=&amp;lt;integer&amp;gt;&lt;br /&gt;
   offset=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
   image_mod=&amp;lt;string&amp;gt;&lt;br /&gt;
   blend_color=&amp;lt;r,g,b&amp;gt;&lt;br /&gt;
   blend_ratio=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
   halo=&amp;lt;progressive_string&amp;gt;&lt;br /&gt;
   halo_x=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   halo_y=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   halo_mod=&amp;lt;string&amp;gt;&lt;br /&gt;
   submerge=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
   x=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   y=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   directional_x=&amp;lt;dev1.9,progressive int&amp;gt;&lt;br /&gt;
   directional_y=&amp;lt;dev1.9,progressive int&amp;gt;&lt;br /&gt;
   layer=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
   [xxx_frame]&lt;br /&gt;
     &amp;lt;frame content&amp;gt;&lt;br /&gt;
   [/xxx_frame]&lt;br /&gt;
   xxx_start_time=&amp;lt;integer&amp;gt;&lt;br /&gt;
   xxx_image_mod=&amp;lt;string&amp;gt;&lt;br /&gt;
   xxx_offset=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
   xxx_blend_color=&amp;lt;r,g,b&amp;gt;&lt;br /&gt;
   xxx_blend_ratio=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
   xxx_halo=&amp;lt;progressive_string&amp;gt;&lt;br /&gt;
   xxx_halo_x=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   xxx_halo_y=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   xxx_halo_mod=&amp;lt;string&amp;gt;&lt;br /&gt;
   xxx_submerge=&amp;lt;progressive float&amp;gt;&lt;br /&gt;
   xxx_x=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   xxx_y=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
   xxx_directional_x=&amp;lt;dev1.9,progressive int&amp;gt;&lt;br /&gt;
   xxx_directional_y=&amp;lt;dev1.9,progressive int&amp;gt;&lt;br /&gt;
   xxx_layer=&amp;lt;progressive int&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 [/animation]&lt;br /&gt;
&lt;br /&gt;
==== Parameter handling ====&lt;br /&gt;
All drawing related parameters in '''[animation]''' can be matched with a corresponding parameter in  a '''[frame]''' block (or a '''[xxx_frame]''' block) The value provided in the animation will be used if no value is provided in the frame. &lt;br /&gt;
&lt;br /&gt;
The point of these two level of parameters is to easily be able to specify a parameter at the animation level and override it for a special case of frame.&lt;br /&gt;
&lt;br /&gt;
== How animations are chosen ==&lt;br /&gt;
Within a unit description block there are multiple animations. Each animation is meant to be played in a very special set of circumstances. We will discuss here how to tell the animation engine when a given animation should be played. &lt;br /&gt;
&lt;br /&gt;
Let's take an example. Suppose we have a unit which has the skirmisher ability. We have the following movement animations :&lt;br /&gt;
* a normal walking animation&lt;br /&gt;
* a swimming animation when the unit is in water&lt;br /&gt;
* a tiptoeing animation when moving next to an enemy unit&lt;br /&gt;
&lt;br /&gt;
Ok. most of the time it's easy to guess what animation should be. However if you are both in water and next to an enemy unit, the animation to play is not obvious.&lt;br /&gt;
&lt;br /&gt;
To solve that question, each animation has a number of filtering criteria. The engine follow the following rules to select an animation&lt;br /&gt;
* Start with all animations&lt;br /&gt;
* Drop all animations with a criteria that fails on the current situation&lt;br /&gt;
* Take the animations that have the most matching criteria&lt;br /&gt;
* If there are more than one animation remaining, take an animation randomly&lt;br /&gt;
* If all animations have been dropped, the engine will provide a smart default.&lt;br /&gt;
    &lt;br /&gt;
here is a pseudo-code explanation of this algorithm:&lt;br /&gt;
&lt;br /&gt;
 foreach animation&lt;br /&gt;
    animation_score = 0&lt;br /&gt;
    foreach filter-criteria&lt;br /&gt;
      if &amp;lt;criteria-fails&amp;gt; &lt;br /&gt;
          animation_score = -1;&lt;br /&gt;
          break;&lt;br /&gt;
      elsif &amp;lt;criteria-matches&amp;gt; &lt;br /&gt;
          animation_score++&lt;br /&gt;
    endfor&lt;br /&gt;
    if animation_score &amp;gt; max_score&lt;br /&gt;
        &amp;lt;empty animation list&amp;gt;&lt;br /&gt;
        max_score = animation_score;&lt;br /&gt;
        push(animation,animation_list);&lt;br /&gt;
    elsif animation_score = max_score&lt;br /&gt;
        push(animation,animation_list);&lt;br /&gt;
 endfor&lt;br /&gt;
 &amp;lt;choose an animation randomly from animation_list&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
Note that all animations don't have all the filters...&lt;br /&gt;
&lt;br /&gt;
so, if we have a unit with&lt;br /&gt;
# an animation for water terrain&lt;br /&gt;
# an animation for SE on grassland&lt;br /&gt;
# an animation with no criteria&lt;br /&gt;
# an animation for N,NE,NW,S,SW,SE&lt;br /&gt;
# an animation for NW&lt;br /&gt;
&lt;br /&gt;
* 3. will never be taken, because 4. will always trump it&lt;br /&gt;
* on water going NW, it can be 1. 4. 5.&lt;br /&gt;
* on water, any direction but NW, it will be 1. or 4.&lt;br /&gt;
* on SE grassland it will be 2.&lt;br /&gt;
* on other grasslands, it will be 4. (4. or 5. if NW)&lt;br /&gt;
&lt;br /&gt;
=== Generic animation filters available for all animations ===&lt;br /&gt;
* '''apply_to''': a list of comma separated keywords describing what event should trigger the animation (movement, attack...) the complete list is given below&lt;br /&gt;
* '''value''': a list of comma separated integer, the meaning depends on the triggering event. the meaning is given with the list of event&lt;br /&gt;
* '''value_second''': a list of comma separated integer, the meaning depends on the triggering event. the meaning is given with the list of event&lt;br /&gt;
* '''terrain''': a list of comma separated terrain letters, the animation will only be used on these terrains.  See [[FilterWML#Filtering Terrains|Filtering Terrains]].  this has been replaced by '''terrain_type'''&lt;br /&gt;
* '''terrain_type''': a list of comma separated terrain codes, the animation will only be used on matching terrains.  See [[FilterWML#Filtering Terrains|Filtering Terrains]].&lt;br /&gt;
* '''[filter]''': this will filter using a [[StandardUnitFilter|standard unit filter]] on the animated unit. Note that matching all criterias in the filter will only earn you one point for animation selection, but that you can have multiple '''[filter]''' blocks in an animation.&lt;br /&gt;
* '''[filter_second]''': this will filter using a [[StandardUnitFilter|standard unit filter]] on the unit in the hex faced. Note that matching all criteria in the filter will only earn you one point for animation selection, but that you can have multiple '''[filter_second]''' blocks in an animation. Also note that if the faced hex is empty, the whole filter will fail.&lt;br /&gt;
* '''direction''': a list of directions (n,ne,se,s,sw,nw), the animation will only be used when acting or moving in this direction (the attack direction for attack animations, moving direction for movement animations, direction of lead unit for leading animations, and so on).&lt;br /&gt;
* '''frequency''': this integer value allows to easily tweak the matching frequency of animations. The filter will fail n-1 times out of n, randomly. Note that unlike every other filter, matching this filter won't give an extra point.&lt;br /&gt;
* '''[filter_attack]''': a standard attack filter to match on the attacker's attack. See  [[FilterWML#Filtering Weapons|Filtering Weapons]]. &lt;br /&gt;
* '''[filter_second_attack]''': a standard attack filter to match on the defender's attack. See [[FilterWML#Filtering Weapons|Filtering Weapons]]. Also note that if the defender doesn't have any weapon to retaliate with, this filter will always fail. &lt;br /&gt;
* '''hits''': filters attack animations based on whether the attack hits, misses or kills. Accepts a list of the following:&lt;br /&gt;
** '''hit''': the attack hits, defender survives.&lt;br /&gt;
** '''no''' or '''miss''': the attack misses.&lt;br /&gt;
** '''kill''': the attack hits, defender dies.&lt;br /&gt;
** '''yes''': is an alias of '''hit,kill'''.&lt;br /&gt;
* '''swing''': a list of numbers representing the swing numbers this animation should match (numbered from 1). this has been replaced by value_second&lt;br /&gt;
* '''base_score''': a number that will always be added to the score. Use with caution&lt;br /&gt;
&lt;br /&gt;
=== Events triggering animations and default animations ===&lt;br /&gt;
==== standing ====&lt;br /&gt;
This animation is triggered whenever any other animation is finished, and is played in loop until another animation is triggered&lt;br /&gt;
&lt;br /&gt;
this is the default &amp;quot;standing image&amp;quot; for the unit&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no standing animation is set a single frame animation based on the enclosing unit's '''image=''' field is used&lt;br /&gt;
==== selected ====&lt;br /&gt;
This animation is triggered whenever the unit is selected&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''blend_ratio=&amp;quot;0.0~0.3:100,0.3~0.0:200&amp;quot; blend_color=255,255,255''&lt;br /&gt;
==== recruited ====&lt;br /&gt;
This animation is triggered whenever the unit is recruited or recalled&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''alpha=0~1:600''&lt;br /&gt;
&lt;br /&gt;
==== recruiting ====&lt;br /&gt;
&lt;br /&gt;
This animation is triggered for the leader when a unit is recruited or recalled&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
no default animation is needed&lt;br /&gt;
&lt;br /&gt;
note that is not triggered for WML triggered animations&lt;br /&gt;
&lt;br /&gt;
==== levelout ====&lt;br /&gt;
This animation is triggered whenever the unit levels, before the unit is replaced by the new unit.&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''blend_ratio=&amp;quot;0~1:600&amp;quot; blend_color=255,255,255''&lt;br /&gt;
&lt;br /&gt;
==== levelin ====&lt;br /&gt;
This animation is triggered whenever the unit levels, after the unit is replaced by the new unit.&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''blend_ratio=&amp;quot;1~0:600&amp;quot; blend_color=255,255,255''&lt;br /&gt;
&lt;br /&gt;
==== movement ====&lt;br /&gt;
This animation is used whenever a unit moves. There are multiple things to consider when dealing with movement animation&lt;br /&gt;
* unit stay ''exactly'' 150ms in each hex. so you typically want to have an offset of ''0~1:150,0~1:150,0~1:150,0~1:150,0~1:150'' or something similar&lt;br /&gt;
* when a unit enters a hex, the current anim is tested again.&lt;br /&gt;
** if the current animation is still valid (i.e it passes all its filter) it is kept, whatever the final score is&lt;br /&gt;
** if it fails, a new movement anim is searched&lt;br /&gt;
&lt;br /&gt;
''value='' contains the number of steps already taken&lt;br /&gt;
&lt;br /&gt;
''value_second='' contains the number of steps left&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''offset=&amp;quot;0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
==== pre_movement ====&lt;br /&gt;
This animation is used before any unit movement&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0 &lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0 &lt;br /&gt;
&lt;br /&gt;
==== post_movement ====&lt;br /&gt;
This animation is used after any unit movement&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0 &lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
==== pre_teleport ====&lt;br /&gt;
This animation is triggered whenever the unit teleports, but before it has moved to the target hex&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''blend_ratio=&amp;quot;1~0:150&amp;quot; blend_color=255,255,255''&lt;br /&gt;
==== post_teleport ====&lt;br /&gt;
This animation is triggered whenever the unit teleports, but after it has moved to the target hex&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''blend_ratio=&amp;quot;0~1:150&amp;quot; blend_color=255,255,255''&lt;br /&gt;
==== healing ====&lt;br /&gt;
This animation is triggered when the unit has healing powers and uses them&lt;br /&gt;
&lt;br /&gt;
''value='' is the number of points healed&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
==== healed ====&lt;br /&gt;
This animation is triggered whenever the unit is healed for any reason&lt;br /&gt;
&lt;br /&gt;
''value='' is the number of points healed&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''blend_ratio=&amp;quot;0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30&amp;quot; blend_color=255,255,255''&lt;br /&gt;
and plays the sound ''heal.wav''&lt;br /&gt;
==== poisoned ====&lt;br /&gt;
This animation is triggered whenever the unit suffers poison dammage&lt;br /&gt;
&lt;br /&gt;
''value='' is the number of points lost&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''blend_ratio=&amp;quot;0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30,0.5:30,0:30&amp;quot; blend_color=0,255,0''&lt;br /&gt;
and plays the sound 'poison.ogg''&lt;br /&gt;
==== defend ====&lt;br /&gt;
This animation is triggered during a strike, of the unit receiving the blow&lt;br /&gt;
&lt;br /&gt;
''value='' is the number of point lost, if any&lt;br /&gt;
&lt;br /&gt;
''value_second='' is the number of the swing, starting from 1&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
==== attack ====&lt;br /&gt;
This animation is triggered during a strike, of the unit giving the blow&lt;br /&gt;
&lt;br /&gt;
''value='' is the number of damage dealt, if any&lt;br /&gt;
&lt;br /&gt;
''value_second='' is the number of the swing, starting from 1&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''offset=&amp;quot;0~0.6:150,0.6~0:150&amp;quot;'' for melee attacks&lt;br /&gt;
No default is provided for range attacks&lt;br /&gt;
==== leading ====&lt;br /&gt;
This animation is triggered for units with the leading special ability, when the unit they are leading is attacking&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is the number of the swing, starting from 1&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== resistance ====&lt;br /&gt;
This animation is triggered for units with the resistance special ability affecting neighbouring fights, when the unit they are helping is defending&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is the number of the swing, starting from 1&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
&lt;br /&gt;
==== death ====&lt;br /&gt;
This animation is triggered when a unit die.&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
if no animation is available, the default uses the standing animation(s) with ''alpha=1~0:600'' and plays the sound in ''die_sound='' of the enclosing unit&lt;br /&gt;
==== victory ====&lt;br /&gt;
This animation is triggered when a unit finishes a fight by killing the other unit&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
==== idling ====&lt;br /&gt;
This animation is called when the unit has been using its standing animation for a random duration.&lt;br /&gt;
&lt;br /&gt;
''value='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
''value_second='' is not used, and always contains 0&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
&lt;br /&gt;
==== draw_weapon ====&lt;br /&gt;
This animation is played before a fight&lt;br /&gt;
&lt;br /&gt;
''hit='' is set to HIT for the attacker and MISS for the defender&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
&lt;br /&gt;
==== sheath_weapon ====&lt;br /&gt;
This animation is played after a fight simultaneously for all surviving units&lt;br /&gt;
&lt;br /&gt;
No default is provided by the engine&lt;br /&gt;
&lt;br /&gt;
==== default ====&lt;br /&gt;
&lt;br /&gt;
This animation is never triggered, but is used as a base to create new animations&lt;br /&gt;
&lt;br /&gt;
''value='' is used depending of the type of animation it replaces&lt;br /&gt;
&lt;br /&gt;
''value_second='' is used depending of the type of animation it replaces&lt;br /&gt;
&lt;br /&gt;
A single animation made of the base frame is provided by the engine if no default animation is available&lt;br /&gt;
&lt;br /&gt;
==== extra animations ====&lt;br /&gt;
Other values are never called by the engine. However they can be triggered by WML events allowing custom animations.&lt;br /&gt;
&lt;br /&gt;
Note that WML events can also trigger standard animations.&lt;br /&gt;
''value='' is set from the WML event&lt;br /&gt;
&lt;br /&gt;
''value_second='' is set from the WML event&lt;br /&gt;
&lt;br /&gt;
== Shortcuts, tricks and quirks ==&lt;br /&gt;
&lt;br /&gt;
=== ''[if]'' and ''[else]'' ===&lt;br /&gt;
&lt;br /&gt;
Often, you need to do very slight variations in an animation (like a different sound depending on whether the unit hits or misses its attack), the '''[if]''' and '''[else]''' tags are meant to help you do that.  ('''Attention:''' These do not have the same syntax as the action tag [if] and its subtag [else] in [[ConditionalActionsWML]].)&lt;br /&gt;
    &lt;br /&gt;
Using these in an animation is equivalent to having multiple animations, one with the '''[if]''' block and one with each of the ''[else]'' blocks. Any filtering flags in these blocks will replace the toplevel filters. You can have multiple '''[if]''' blocks in an animation, but you can't nest an '''[if]''' inside another. These should be written directly inside the '''[animation]''' block. The following example would make the '''[frame]''' inside the '''[if]''' be played when the attack misses, and the '''[frame]''' inside the '''[else]''' be played when the attack hits (producing a different sound):&lt;br /&gt;
&lt;br /&gt;
    [if]&lt;br /&gt;
        hits=no&lt;br /&gt;
        [frame]&lt;br /&gt;
            begin=-100&lt;br /&gt;
            end=100&lt;br /&gt;
            image=&amp;quot;units/dwarves/lord-attack.png&amp;quot;&lt;br /&gt;
            sound={SOUND_LIST:MISS}&lt;br /&gt;
        [/frame]&lt;br /&gt;
    [/if]&lt;br /&gt;
    [else]&lt;br /&gt;
        hits=yes&lt;br /&gt;
        [frame]&lt;br /&gt;
            begin=-100&lt;br /&gt;
            end=100&lt;br /&gt;
            image=&amp;quot;units/dwarves/lord-attack.png&amp;quot;&lt;br /&gt;
            sound=axe.ogg&lt;br /&gt;
        [/frame]&lt;br /&gt;
    [/else]&lt;br /&gt;
&lt;br /&gt;
note that this is very close to preprocessing and should be considered as such, especially with regard to scoring and animation selection&lt;br /&gt;
&lt;br /&gt;
=== Simplified animation blocks ===&lt;br /&gt;
To simplify the most common animation cases, you can use different blocks instead of the generic '''[animation]''' block. These are also here for backward compatibility, but are not deprecated and fully supported&lt;br /&gt;
&lt;br /&gt;
some of these use extra tags which are translated in the normal ''value='' tag&lt;br /&gt;
&lt;br /&gt;
some of these define '''[xxx_frame]''' blocks where the frame prefix starts with an underscore. This is not allowed in normal WML (prefix starting with underscore is reserved for the engine internal use). It is here for clarity purpose&lt;br /&gt;
&lt;br /&gt;
* '''[leading_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=leading&lt;br /&gt;
* '''[recruit_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=recruited&lt;br /&gt;
* '''[recruiting_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=recruiting&lt;br /&gt;
* '''[standing_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=standing,default&lt;br /&gt;
note for 1.4 :''default'' doesn't exist in 1.4, but the semantic is the same.&lt;br /&gt;
&lt;br /&gt;
i.e: the animation will be used to build default animations&lt;br /&gt;
* '''[idle_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=idling&lt;br /&gt;
* '''[levelout_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=levelout&lt;br /&gt;
* '''[levelin_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=levelin&lt;br /&gt;
* '''[healing_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=healing&lt;br /&gt;
 value=&amp;lt;damage= value&amp;gt;&lt;br /&gt;
* '''[healed_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=healed&lt;br /&gt;
 value=&amp;lt;healing= value&amp;gt;&lt;br /&gt;
 [_healed_sound_frame]&lt;br /&gt;
    sound=heal.wav&lt;br /&gt;
 [/_healed_sound_frame]&lt;br /&gt;
* '''[poison_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=poisoned&lt;br /&gt;
 value=&amp;lt;damage= value&amp;gt;&lt;br /&gt;
 [_poison_sound_frame]&lt;br /&gt;
    sound=poison.ogg&lt;br /&gt;
 [/_poison_sound_frame]&lt;br /&gt;
* '''[movement_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=movement&lt;br /&gt;
 offset=&amp;quot;0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150,0~1:150&amp;quot;&lt;br /&gt;
* '''[pre_movement_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=pre_movement&lt;br /&gt;
* '''[post_movement_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=post_movement&lt;br /&gt;
* '''[draw_weapon_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=draw_weapon&lt;br /&gt;
* '''[sheath_weapon_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=sheath_weapon_movement&lt;br /&gt;
* '''[defend]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=defend&lt;br /&gt;
 value=&amp;lt;damage= value&amp;gt;&lt;br /&gt;
 &amp;lt;WML content&amp;gt;&lt;br /&gt;
 [frame]&lt;br /&gt;
    blend_color=255,0,0&lt;br /&gt;
    blend_ratio=&amp;quot;0.5:50,0.0:50&amp;quot;&lt;br /&gt;
 [/frame]&lt;br /&gt;
&lt;br /&gt;
there are some subtil change compared to what is described above to avoid the red flash when value=0, but it should work as expected as far as WML author are concerned&lt;br /&gt;
 &lt;br /&gt;
* '''[attack_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
if the animation contains a missile frame&lt;br /&gt;
&lt;br /&gt;
 apply_to=attack&lt;br /&gt;
 missile_offset=&amp;quot;0~0.8&amp;quot;&lt;br /&gt;
&lt;br /&gt;
else&lt;br /&gt;
&lt;br /&gt;
 apply_to=attack&lt;br /&gt;
 offset=&amp;quot;0~0.6,0.6~0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* '''[death]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=death&lt;br /&gt;
 [_death_sound_frame]&lt;br /&gt;
    sound=&amp;lt;die_sound= of the enclosing [unit] tag&amp;gt;&lt;br /&gt;
 [/_death_sound_frame]&lt;br /&gt;
* '''[victory_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=victory&lt;br /&gt;
* '''[extra_anim]''' is an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=&amp;lt;flag= value of the anim&amp;gt;&lt;br /&gt;
* '''[teleport_anim]''' will be cut into two at the clock-time 0&lt;br /&gt;
everything before zero becomes an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=pre_teleport&lt;br /&gt;
everything after zero becomes an animation with the following parameters automatically set&lt;br /&gt;
 apply_to=post_teleport&lt;br /&gt;
&lt;br /&gt;
== Layering ==&lt;br /&gt;
The ''layer'' progressive parameter allows the animation writer to choose in what order the animation should be drawn.&lt;br /&gt;
&lt;br /&gt;
this value must be between 0 and 100&lt;br /&gt;
&lt;br /&gt;
* the back of haloes is drawn with a value of 10&lt;br /&gt;
* when unspecified, a animation is drawn with a value of 40&lt;br /&gt;
* terrain elements that are supposed to go in front of units (castles) are drawn with a value of 50&lt;br /&gt;
* orbs and status bars are drawn on layer 80&lt;br /&gt;
* when unspecified missile frames are drawn on layer 90&lt;br /&gt;
&lt;br /&gt;
by changing these values, it is easy to have the unit display the way you want&lt;br /&gt;
&lt;br /&gt;
== Optimization ==&lt;br /&gt;
&lt;br /&gt;
there is a special flag that goes into the animation block (not the frame) &lt;br /&gt;
&lt;br /&gt;
* ''offscreen'' a boolean saying if the unit's animation should be played when the unit is offscreen. You want the animation to play offscreen if the animation contains some usefull sound effects.This attribute defaults to true (play offscreen) except for standing and idle animations where it defaults to false&lt;br /&gt;
&lt;br /&gt;
== Cycling ==&lt;br /&gt;
&lt;br /&gt;
there is a special boolean parameter that can be put in an animation block (not the frame)&lt;br /&gt;
&lt;br /&gt;
* ''cycles'' a boolean value. if set to true the animation will cycles forever until it is replaced. That animation will not influence the end time of all related animations (for example a cycling defense animation will play normally but the overall duration of the fight animation will be only decided by the attack animation)&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[UnitTypeWML]]&lt;br /&gt;
* [[ReferenceWML]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: WML Reference]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46444</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46444"/>
		<updated>2012-04-14T21:09:34Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* So What Exactly is WML? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder about the purpose of this tutorial. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
The specific demographic for which this tutorial is intended is users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder paths and locate specific directories. In this tutorial you will learn the fundamentals of WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming in WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML (in fact, it is recommended that you ''avoid'' using those fancy word processors); a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without being required to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_first_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.&lt;br /&gt;
&lt;br /&gt;
===Creating Your Custom Unit's .cfg File===&lt;br /&gt;
&lt;br /&gt;
===Including the Custom Unit In Your Campaign===&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without having to wade through a quagmire of if codeblocks. This is done via the switch/case codeblock, which tests the value of a variable for multiple conditions, and determines the action performed as a result of that evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46443</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46443"/>
		<updated>2012-04-14T21:08:43Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder about the purpose of this tutorial. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
The specific demographic for which this tutorial is intended is users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder paths and locate specific directories. In this tutorial you will learn the fundamentals of WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming in WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML (in fact, it is recommended that you ''avoid'' using those fancy word processors); a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_first_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.&lt;br /&gt;
&lt;br /&gt;
===Creating Your Custom Unit's .cfg File===&lt;br /&gt;
&lt;br /&gt;
===Including the Custom Unit In Your Campaign===&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without having to wade through a quagmire of if codeblocks. This is done via the switch/case codeblock, which tests the value of a variable for multiple conditions, and determines the action performed as a result of that evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46441</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46441"/>
		<updated>2012-04-14T21:03:30Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Chapter 6: Building and Including a Custom Unit */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder what the purpose of this tutorial is. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
This tutorial is aimed at users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder directories. In this tutorial you will learn WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML; a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_first_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
Sometimes campaign authors only use mainline units in their campaigns. Other times, however, they may want to include a custom unit that isn't found in default Wesnoth. Thankfully, including a custom unit is quite easy.&lt;br /&gt;
&lt;br /&gt;
===Creating Your Custom Unit's .cfg File===&lt;br /&gt;
&lt;br /&gt;
===Including the Custom Unit In Your Campaign===&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without having to wade through a quagmire of if codeblocks. This is done via the switch/case codeblock, which tests the value of a variable for multiple conditions, and determines the action performed as a result of that evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46436</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46436"/>
		<updated>2012-04-14T20:52:23Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* The Campaign Folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder what the purpose of this tutorial is. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
This tutorial is aimed at users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder directories. In this tutorial you will learn WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML; a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_first_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without having to wade through a quagmire of if codeblocks. This is done via the switch/case codeblock, which tests the value of a variable for multiple conditions, and determines the action performed as a result of that evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=46389</id>
		<title>Create Art</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=46389"/>
		<updated>2012-04-11T14:10:47Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Sprite Art */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;float:right; margin-left:1em;&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Graphic artists working on artwork intended for mainline Wesnoth usually meet on the [http://forums.wesnoth.org/viewforum.php?f=9 Art Contributions forum] or on the [http://forums.wesnoth.org/viewforum.php?f=18 restricted Art Development forum] (&amp;quot;restricted&amp;quot; meaning that only those users with special permissions - such as art contributors and developers - can post there). The former is a great place to post and discuss new and current mainline Wesnoth art and graphics, and the latter to see what the art development team is working on. Artists working on graphics for [[WesnothAcronyms|UMC]] add-ons meet in the [http://forums.wesnoth.org/viewforum.php?f=23 Art Workshop forum].&lt;br /&gt;
&lt;br /&gt;
Unit and terrain art is stored in the lossless ''Portable Network Graphics'' (PNG) format. Each frame of a unit animation, and each variation of a terrain is stored as a separate .png file in ''data/core/images'' under the [[EditingWesnoth#Where_is_my_game_data_directory.3F|main data directory]] of the game, and generally these files will be 72 x 72 pixels (the size of Wesnoth's basic hexagonal tile) with an alpha channel (a part of the file that indicates how transparent each pixel is). When creating your own images, you can test them without overwriting any game data by putting them in your [[EditingWesnoth#Where_is_my_user_data_directory.3F|user data directory]]. The game also supports JPEG images, although these are better suited for story art.&lt;br /&gt;
&lt;br /&gt;
To edit these graphics, you'll need some program capable of creating PNG's - some of the programs in the following list are free, open-source software, and will do the job nicely: [[Art Programs]]&lt;br /&gt;
&lt;br /&gt;
If you need some inspiration, we have a (no longer maintained) [[GraphicLibrary|Graphics Library]] which collects art posted on the forum. You can use this for ideas, and as a scrap heap for different parts of unit images (a technique described [[Give Your Hero A Personality|here]]).&lt;br /&gt;
&lt;br /&gt;
== Art Tutorials ==&lt;br /&gt;
&lt;br /&gt;
These are a work-in-progress, and describe both how to make art fit into Wesnoth's style, as well as giving some considerable tips on drawing in general.  Especially useful is the [[External Tutorials]] page which lists a large number of art tutorials available on the web.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General Art and Computer Graphics ===&lt;br /&gt;
* [[Using the Levels Adjustment]] - How to make scanned pencil drawings ''not'' look washed out.&lt;br /&gt;
* [[Extending dynamic range]] - The Grooviest (so far) tutorial about extending the dynamic range of images and how this technique can be used to make better scans of pencil drawings.&lt;br /&gt;
* [[Scanning with camera]] - How to transfer real-life art to computer using a digital camera instead of a scanner.&lt;br /&gt;
* [[Art Supplies]] - What physical items you need to do larger cell-shaded art like that of Jetrel/Jormungadr/et al.&lt;br /&gt;
* [[Inking With Pencils|Computer Inking a Sketch]] - Info from Jason Lutes on his portrait workflow.&lt;br /&gt;
* [[Scaling Digital Images]] - How to properly resize an image on a computer.&lt;br /&gt;
* [[How to Shade]] - An attempt at tackling a very complicated topic.&lt;br /&gt;
* [[Cartography for Wesnoth|How to make Wesnoth-style Maps ]] - Kestenvarn's tricks of the trade.&lt;br /&gt;
* [[Designing weapons and armour]] - Advice from zookeeper on designing realistic weapons for your characters.&lt;br /&gt;
* [[Portrait Tutorial]] - A guide on how to draw unit/character portraits by Kitty.&lt;br /&gt;
* [[Armour_Tutorial]] A tutorial on how to shade metallic armour by LordBob.&lt;br /&gt;
====Vector Art====&lt;br /&gt;
Sgt. Groovy's vector workshop - Tips and tricks for drawing with Inkscape.&lt;br /&gt;
:* [[Z-order tricks]] - A few methods for faking overlapping shapes.&lt;br /&gt;
:* [[Variable-width strokes]] - How to make the strokes vary in width, like being drawn with a flat-tipped pen &amp;amp;mdash; no tablet needed!&lt;br /&gt;
:* [[Shaped gradients with Gaussian blur]] - How to make gradients in other shapes than linear or radial.&lt;br /&gt;
:* [[Smooth shading in vector]] - The basic vector techniques for smooth shading, employing Gaussian blur and clipping/masking.&lt;br /&gt;
:* [[Vector Inking]] - Vector techniques, including mouse-only, for inking your sketches.&lt;br /&gt;
:* [[Making portrait art in vector]] - A complete tutorial for making Wesnoth unit portraits in vector graphics.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Terrain|Terrain Graphics]] ===&lt;br /&gt;
&lt;br /&gt;
The following is information specific to drawing terrain for Wesnoth.  Read Frame's &amp;quot;Tiles Tutorial&amp;quot; for a good overview of how terrain graphics work.&lt;br /&gt;
&lt;br /&gt;
* [[Mesilliac's Essay on Terrain Perspective]] - The geometry behind the perspective used for terrain tiles in Wesnoth.&lt;br /&gt;
* [[Tiles Tutorial]] - Frame's tutorial describing the process of making terrain tiles in Wesnoth, and how they interact with adjacent tiles.&lt;br /&gt;
* [[How To Make Seamless Tiles]] - The tutorial is aimed at Photoshop users, but the technique is similar with GIMP.&lt;br /&gt;
* [[Seamless Tiles Using Inkscape]] - This tutorial teaches a method for making seamless hex tiles in vector craphics (to be rendered in raster).&lt;br /&gt;
* [[Turning Square Tiles into Hex]] - Nifty tricks for transforming square (or any rectangle) shaped seamless tiles into hexagon seamless tiles.&lt;br /&gt;
* [[CastleTutorial|Castle Tutorial]] - A description of how Wesnoth's castle tiles work (needs updating, but useful nonetheless).&lt;br /&gt;
* [[MultiHexTutorial|Multi-Hex Tiling Tutorial]] - A description of how multi-hex tiles work.&lt;br /&gt;
* [[Editing Castles]] - Instructions for how to make/edit castles (and other corner-based terrains) using yobbo's GIMP script.&lt;br /&gt;
&lt;br /&gt;
These describe the system used to specify how terrains behave in game:&lt;br /&gt;
* [[TerrainCodesWML]] - A list of the letters used to represent terrain types.&lt;br /&gt;
* [[TerrainGraphicsWML]] - If you really need to get technical, start here.&lt;br /&gt;
* [http://www.anathas.org/ayin/wesnoth/doc/terrain_graphics_wml Ayin's Terrain Graphics document] - If you really, ''really'' need to get technical, this describes the terrain graphics WML system in depth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sprite Art ===&lt;br /&gt;
The following are different tutorials about sprite work compiled by various Wesnoth sprite artists.  These will give you the most specific-to-Wesnoth information about making sprites, and are well worth a read.&lt;br /&gt;
 &lt;br /&gt;
* [[Creating Unit Art]] - A list of specifications you will need to match.&lt;br /&gt;
* [[Give Your Hero A Personality]] - Tricks for editing existing images, including some clip art.&lt;br /&gt;
* [[Team Color Shifting]] - How to create art that uses our new team color system.&lt;br /&gt;
* [[TeamColoring]] - How to automatically team-color sprites to see what they look like in various colors.&lt;br /&gt;
* [[Creating Shadows Under Units]] - How we create the shadows for the units in-game.&lt;br /&gt;
* [[How to Anti-Alias Sprite Art]] - A means of removing the jagged edges on pixel lines.&lt;br /&gt;
* [[Rotate Pixel Art Without Blurring]]&lt;br /&gt;
* [http://forums.wesnoth.org/download/file.php?id=56284 Zerovirus's Spriting Workflow] - Wesnoth artist Zerovirus explains step-by-step his methodology for creating Wesnoth sprites from scratch (.png file).&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
* [[FrankenPacks]] - A quick and dirty way to create sprites for [[WesnothAcronyms|UMC]].&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
====Animation====&lt;br /&gt;
:* [[Basic Animation Tutorial]] - Or &amp;quot;How to Animate Sprites for Dummies,&amp;quot; covering the basic theory, and all of the mistakes to avoid.&lt;br /&gt;
:* [[From Base Frame To Full Animation]] - A solid method of moving baseframes forward towards full animation.&lt;br /&gt;
:* [[How to create motion blurs]] - A simple explanation on how to create attack animation weapon blurs.&lt;br /&gt;
:* [[Making Bow Animations]] - The current standard for how we want bow animations to work.&lt;br /&gt;
:* [[Fire Animation]] - A great guide to creating fire FX by rhyging5.&lt;br /&gt;
&lt;br /&gt;
=== External Tutorials ===&lt;br /&gt;
The following page contains dozens of links to tutorials covering all manner of artwork, including sprite art.  These were not made by Wesnoth artists, but should prove very useful for general instruction.&lt;br /&gt;
&lt;br /&gt;
* [[External Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
* [[GraphicLibrary]] - Lots of usercontributed graphics (most should be GPL'ed)&lt;br /&gt;
* [[Project]]&lt;br /&gt;
* [http://wesnoth.dbzer0.com/blog/wpg2 External Graphic Library] - A project to better organize the art of Wesnoth.&lt;br /&gt;
&lt;br /&gt;
[[Category:Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=46388</id>
		<title>Create Art</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=46388"/>
		<updated>2012-04-11T14:10:08Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;float:right; margin-left:1em;&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Graphic artists working on artwork intended for mainline Wesnoth usually meet on the [http://forums.wesnoth.org/viewforum.php?f=9 Art Contributions forum] or on the [http://forums.wesnoth.org/viewforum.php?f=18 restricted Art Development forum] (&amp;quot;restricted&amp;quot; meaning that only those users with special permissions - such as art contributors and developers - can post there). The former is a great place to post and discuss new and current mainline Wesnoth art and graphics, and the latter to see what the art development team is working on. Artists working on graphics for [[WesnothAcronyms|UMC]] add-ons meet in the [http://forums.wesnoth.org/viewforum.php?f=23 Art Workshop forum].&lt;br /&gt;
&lt;br /&gt;
Unit and terrain art is stored in the lossless ''Portable Network Graphics'' (PNG) format. Each frame of a unit animation, and each variation of a terrain is stored as a separate .png file in ''data/core/images'' under the [[EditingWesnoth#Where_is_my_game_data_directory.3F|main data directory]] of the game, and generally these files will be 72 x 72 pixels (the size of Wesnoth's basic hexagonal tile) with an alpha channel (a part of the file that indicates how transparent each pixel is). When creating your own images, you can test them without overwriting any game data by putting them in your [[EditingWesnoth#Where_is_my_user_data_directory.3F|user data directory]]. The game also supports JPEG images, although these are better suited for story art.&lt;br /&gt;
&lt;br /&gt;
To edit these graphics, you'll need some program capable of creating PNG's - some of the programs in the following list are free, open-source software, and will do the job nicely: [[Art Programs]]&lt;br /&gt;
&lt;br /&gt;
If you need some inspiration, we have a (no longer maintained) [[GraphicLibrary|Graphics Library]] which collects art posted on the forum. You can use this for ideas, and as a scrap heap for different parts of unit images (a technique described [[Give Your Hero A Personality|here]]).&lt;br /&gt;
&lt;br /&gt;
== Art Tutorials ==&lt;br /&gt;
&lt;br /&gt;
These are a work-in-progress, and describe both how to make art fit into Wesnoth's style, as well as giving some considerable tips on drawing in general.  Especially useful is the [[External Tutorials]] page which lists a large number of art tutorials available on the web.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General Art and Computer Graphics ===&lt;br /&gt;
* [[Using the Levels Adjustment]] - How to make scanned pencil drawings ''not'' look washed out.&lt;br /&gt;
* [[Extending dynamic range]] - The Grooviest (so far) tutorial about extending the dynamic range of images and how this technique can be used to make better scans of pencil drawings.&lt;br /&gt;
* [[Scanning with camera]] - How to transfer real-life art to computer using a digital camera instead of a scanner.&lt;br /&gt;
* [[Art Supplies]] - What physical items you need to do larger cell-shaded art like that of Jetrel/Jormungadr/et al.&lt;br /&gt;
* [[Inking With Pencils|Computer Inking a Sketch]] - Info from Jason Lutes on his portrait workflow.&lt;br /&gt;
* [[Scaling Digital Images]] - How to properly resize an image on a computer.&lt;br /&gt;
* [[How to Shade]] - An attempt at tackling a very complicated topic.&lt;br /&gt;
* [[Cartography for Wesnoth|How to make Wesnoth-style Maps ]] - Kestenvarn's tricks of the trade.&lt;br /&gt;
* [[Designing weapons and armour]] - Advice from zookeeper on designing realistic weapons for your characters.&lt;br /&gt;
* [[Portrait Tutorial]] - A guide on how to draw unit/character portraits by Kitty.&lt;br /&gt;
* [[Armour_Tutorial]] A tutorial on how to shade metallic armour by LordBob.&lt;br /&gt;
====Vector Art====&lt;br /&gt;
Sgt. Groovy's vector workshop - Tips and tricks for drawing with Inkscape.&lt;br /&gt;
:* [[Z-order tricks]] - A few methods for faking overlapping shapes.&lt;br /&gt;
:* [[Variable-width strokes]] - How to make the strokes vary in width, like being drawn with a flat-tipped pen &amp;amp;mdash; no tablet needed!&lt;br /&gt;
:* [[Shaped gradients with Gaussian blur]] - How to make gradients in other shapes than linear or radial.&lt;br /&gt;
:* [[Smooth shading in vector]] - The basic vector techniques for smooth shading, employing Gaussian blur and clipping/masking.&lt;br /&gt;
:* [[Vector Inking]] - Vector techniques, including mouse-only, for inking your sketches.&lt;br /&gt;
:* [[Making portrait art in vector]] - A complete tutorial for making Wesnoth unit portraits in vector graphics.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Terrain|Terrain Graphics]] ===&lt;br /&gt;
&lt;br /&gt;
The following is information specific to drawing terrain for Wesnoth.  Read Frame's &amp;quot;Tiles Tutorial&amp;quot; for a good overview of how terrain graphics work.&lt;br /&gt;
&lt;br /&gt;
* [[Mesilliac's Essay on Terrain Perspective]] - The geometry behind the perspective used for terrain tiles in Wesnoth.&lt;br /&gt;
* [[Tiles Tutorial]] - Frame's tutorial describing the process of making terrain tiles in Wesnoth, and how they interact with adjacent tiles.&lt;br /&gt;
* [[How To Make Seamless Tiles]] - The tutorial is aimed at Photoshop users, but the technique is similar with GIMP.&lt;br /&gt;
* [[Seamless Tiles Using Inkscape]] - This tutorial teaches a method for making seamless hex tiles in vector craphics (to be rendered in raster).&lt;br /&gt;
* [[Turning Square Tiles into Hex]] - Nifty tricks for transforming square (or any rectangle) shaped seamless tiles into hexagon seamless tiles.&lt;br /&gt;
* [[CastleTutorial|Castle Tutorial]] - A description of how Wesnoth's castle tiles work (needs updating, but useful nonetheless).&lt;br /&gt;
* [[MultiHexTutorial|Multi-Hex Tiling Tutorial]] - A description of how multi-hex tiles work.&lt;br /&gt;
* [[Editing Castles]] - Instructions for how to make/edit castles (and other corner-based terrains) using yobbo's GIMP script.&lt;br /&gt;
&lt;br /&gt;
These describe the system used to specify how terrains behave in game:&lt;br /&gt;
* [[TerrainCodesWML]] - A list of the letters used to represent terrain types.&lt;br /&gt;
* [[TerrainGraphicsWML]] - If you really need to get technical, start here.&lt;br /&gt;
* [http://www.anathas.org/ayin/wesnoth/doc/terrain_graphics_wml Ayin's Terrain Graphics document] - If you really, ''really'' need to get technical, this describes the terrain graphics WML system in depth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sprite Art ===&lt;br /&gt;
The following are different tutorials about sprite work compiled by various Wesnoth sprite artists.  These will give you the most specific-to-Wesnoth information about making sprites, and are well worth a read.&lt;br /&gt;
 &lt;br /&gt;
* [[Creating Unit Art]] - A list of specifications you will need to match.&lt;br /&gt;
* [[Give Your Hero A Personality]] - Tricks for editing existing images, including some clip art.&lt;br /&gt;
* [[Team Color Shifting]] - How to create art that uses our new team color system.&lt;br /&gt;
* [[TeamColoring]] - How to automatically team-color sprites to see what they look like in various colors.&lt;br /&gt;
* [[Creating Shadows Under Units]] - How we create the shadows for the units in-game.&lt;br /&gt;
* [[How to Anti-Alias Sprite Art]] - A means of removing the jagged edges on pixel lines.&lt;br /&gt;
* [[Rotate Pixel Art Without Blurring]]&lt;br /&gt;
* [http://forums.wesnoth.org/download/file.php?id=56284 Zerovirus's Spriting Workflow] - Wesnoth artist Zerovirus explains step-by-step his methodology for creating Wesnoth sprites (.png file)&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
* [[FrankenPacks]] - A quick and dirty way to create sprites for [[WesnothAcronyms|UMC]].&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
====Animation====&lt;br /&gt;
:* [[Basic Animation Tutorial]] - Or &amp;quot;How to Animate Sprites for Dummies,&amp;quot; covering the basic theory, and all of the mistakes to avoid.&lt;br /&gt;
:* [[From Base Frame To Full Animation]] - A solid method of moving baseframes forward towards full animation.&lt;br /&gt;
:* [[How to create motion blurs]] - A simple explanation on how to create attack animation weapon blurs.&lt;br /&gt;
:* [[Making Bow Animations]] - The current standard for how we want bow animations to work.&lt;br /&gt;
:* [[Fire Animation]] - A great guide to creating fire FX by rhyging5.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== External Tutorials ===&lt;br /&gt;
The following page contains dozens of links to tutorials covering all manner of artwork, including sprite art.  These were not made by Wesnoth artists, but should prove very useful for general instruction.&lt;br /&gt;
&lt;br /&gt;
* [[External Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
* [[GraphicLibrary]] - Lots of usercontributed graphics (most should be GPL'ed)&lt;br /&gt;
* [[Project]]&lt;br /&gt;
* [http://wesnoth.dbzer0.com/blog/wpg2 External Graphic Library] - A project to better organize the art of Wesnoth.&lt;br /&gt;
&lt;br /&gt;
[[Category:Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Art_Programs&amp;diff=46362</id>
		<title>Art Programs</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Art_Programs&amp;diff=46362"/>
		<updated>2012-04-09T17:16:41Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;float:right; margin-left:1em;&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|}&lt;br /&gt;
'''Big Note:''' It is mostly-possible to make wesnoth graphics with nothing more than MSPaint or Appleworks.  However, there are two major and '''vital''' things lacking in those programs - first, these programs cannot make images with transparent pixels, and second, they may not be able to save in the PNG format used by Wesnoth.  A program capable of those will have to be applied to images made with MSPaint when they are finished.&lt;br /&gt;
&lt;br /&gt;
=== Free Image Editors ===&lt;br /&gt;
The following are free image editing programs which can be used to create graphics for wesnoth.  These programs are Open-Source Software, like wesnoth, meaning they are free to use, and that you are free to look at the sourcecode.&lt;br /&gt;
&lt;br /&gt;
[http://www.gimp.org '''The GIMP'''] (Windows, Linux &amp;amp; Mac OS X); the &amp;quot;Gnu Image Manipulation Program&amp;quot; is recommended.  &lt;br /&gt;
&lt;br /&gt;
[http://seashore.sourceforge.net/ '''Seashore'''] (Mac OS X) this port of the the GIMP to a cocoa-based gui is recommended.  Seashore provides the basic features of GIMP.&lt;br /&gt;
&lt;br /&gt;
[http://www.opensword.org/ '''Pixen'''] (Mac OS X) is the OpenSword Group's tool for traditional SNES style sprite art - unlike most other editors, it has been designed for that specific task, and users may find it much less daunting than the Gimp or Photoshop.  This program was written in cocoa, and has a very good interface - version 3 will even include built-in support for making animations.&lt;br /&gt;
&lt;br /&gt;
[http://jdraw.sourceforge.net/index.php?page=6'''JDraw'''] (for anything that can run Java - mac and windows included) is an image editor which has a subset of the features of Pixen, and a superset of the features of MSPaint.  It is a simple, straightforward pixel editing program.  If you use a mac, Pixen is probably a better idea.&lt;br /&gt;
&lt;br /&gt;
[http://www.eecs.wsu.edu/paint.net/ '''Paint.net'''] (Windows) is generally regarded as inferior to the Gimp or Photoshop, but is easier to look at for those with shorter attention spans, so some might find it of interest.&lt;br /&gt;
&lt;br /&gt;
[http://ase.sourceforge.net/ '''Allegro Sprite Editor'''] (Windows and Linux) is a sprite editing program.  Free/OSS, note that it is NOT capable of saving PNGs.&lt;br /&gt;
&lt;br /&gt;
[http://paintbrush.sourceforge.net/ '''Paintbrush'''] (Mac OS X) is a program intended to be a slightly modernized clone of the old MacPaint/MSPaint.  Free/OSS, but note that though it is capable of saving PNGs, it is not capable of handling transparency.&lt;br /&gt;
&lt;br /&gt;
=== Free Image Post-Processors ===&lt;br /&gt;
&lt;br /&gt;
[http://www.amake.us/software/pngcrusher/ '''PNGCrusher'''] (Mac OS X) is a handy lightweight tool that will compress your PNGs much more efficiently than Photoshop.  It is best used in tandem with saving the files from GraphicConverter, with the PNG filtering options on.  The tool it is based on, OptiPNG, is open source, and runs on both linux and windows.&lt;br /&gt;
&lt;br /&gt;
[http://imageoptim.pornel.net/ '''ImageOptim'''] (Mac OS X) optimizes images so they take up less disk space and load faster. It provides GUI for various optimisation tools: AdvPNG from AdvanceCOMP, OptiPNG, Pngcrush, JpegOptim, jpegtran from libjpeg, Gifsicle and optionally PNGOUT.&lt;br /&gt;
&lt;br /&gt;
=== Proprietary Image Editors ===&lt;br /&gt;
&lt;br /&gt;
==== Shareware ====&lt;br /&gt;
[http://www.lemkesoft.de/ '''GraphicConverter'''] (Mac OS X) by Lemkesoft is an excellent program for preparing and compressing png images for the game, and may also be useful for the creation of images.  The shareware fee is $30, although large parts of the program are fully functional for free.&lt;br /&gt;
&lt;br /&gt;
[http://www.kanzelsberger.com/pixel/ '''Pixel Image Editor'''] (Mac OS X, Windows, Linux, BeOS, and others) is a very full-featured program, intended to fulfill the same function that photoshop does.  It currently has a shareware fee of $32, though the final price once the product reaches v2.0, will be $79.&lt;br /&gt;
&lt;br /&gt;
[http://www.ultimatepaint.com/ '''JTL Ultimate Paint'''] (Windows) is a basic painting program, following the tradition of the earlier &amp;quot;DeluxePaint&amp;quot;.  Geared at painting, it can use photoshop plugins. It currently costs $34 for a basic version.  I do not know if this program can export PNG images, so ''caveat emptor''.&lt;br /&gt;
&lt;br /&gt;
[http://www.cosmigo.com/promotion/ '''Pro Motion'''] (Windows) is a commercial pixel editing program.  It has many features tailored for animation and seamless square-tile creation, as well as features designed to ease the creation of images that would run in a game on the Game Boy Advance or a Mobile Phone platform.  The price of the normal version is $78.&lt;br /&gt;
&lt;br /&gt;
[http://www.humanbalance.net/gale/us/index.html '''GraphicsGale'''] (Windows) is a pixel editing program designed for animation.  It has both a freeware version, and a 1995¥ (roughly $20) shareware version.  Be warned that it can '''not''' save files in the PNG format.&lt;br /&gt;
&lt;br /&gt;
==== Non-shareware ====&lt;br /&gt;
[http://www.adobe.com/ '''Photoshop or Photoshop Elements'''] (Windows and Mac OS X), these industry standard Adobe applications are available for approximately USD $100 and $700, respectively, depending on what version of the software you purchase and where you purchase it. You may be able acquire the use of these programs through a business or academic situation. Adobe Photoshop is extremely powerful, and is more than capable of some very advanced sprite techniques which elude simple bitmap programs - the price, however, can be a barrier to entry for some contributors.  More advanced (and therefore more expensive) version of Photoshop should have little advantage over Elements (the entry-level version, usually available for approximately USD $100) for creating unit and terrain art. Photoshop (and presumably Elements) does not compactly save PNG files. For space savings, Adobe users are recommended to resave final PNGs through Adobe's companion application ImageReady, or another application such as GraphicConverter or PNGCrusher.  Note - the ImageReady compression can also be used by saving the files through the &amp;quot;Save for Web...&amp;quot; menu command within Photoshop, if ImageReady is installed.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[Art Tutorials]]&lt;br /&gt;
&lt;br /&gt;
[[Category: Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46143</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46143"/>
		<updated>2012-04-05T14:18:57Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Cases */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder what the purpose of this tutorial is. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
This tutorial is aimed at users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder directories. In this tutorial you will learn WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML; a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without having to wade through a quagmire of if codeblocks. This is done via the switch/case codeblock, which tests the value of a variable for multiple conditions, and determines the action performed as a result of that evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46142</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46142"/>
		<updated>2012-04-05T14:11:07Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* The Toplevel Tagset and Attributes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder what the purpose of this tutorial is. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
This tutorial is aimed at users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder directories. In this tutorial you will learn WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML; a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario (including underscores, capitalization, spelling, etc.), otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without. Instead of using multiple [if] codeblocks, you could simply use the switch/case codeblock to evaluate the value of a variable and determine the action performed as a result of the evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46141</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=46141"/>
		<updated>2012-04-05T14:07:45Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* The Text Domain */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder what the purpose of this tutorial is. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
This tutorial is aimed at users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder directories. In this tutorial you will learn WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML; a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign values to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario, otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without. Instead of using multiple [if] codeblocks, you could simply use the switch/case codeblock to evaluate the value of a variable and determine the action performed as a result of the evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=45909</id>
		<title>Create Art</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=Create_Art&amp;diff=45909"/>
		<updated>2012-03-28T19:27:57Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;float:right; margin-left:1em;&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Graphic artists working on artwork intended for mainline Wesnoth usually meet on the [http://forums.wesnoth.org/viewforum.php?f=9 Art Contributions forum] or on the [http://forums.wesnoth.org/viewforum.php?f=18 restricted Art Development forum] (&amp;quot;restricted&amp;quot; meaning that only those users with special permissions - such as art contributors and developers - can post there). The former is a great place to post and discuss new and current mainline Wesnoth art and graphics, and the latter to see what the art development team is working on. Artists working on graphics for [[WesnothAcronyms|UMC]] add-ons meet in the [http://forums.wesnoth.org/viewforum.php?f=23 Art Workshop forum].&lt;br /&gt;
&lt;br /&gt;
Unit and terrain art is stored in the lossless ''Portable Network Graphics'' (PNG) format. Each frame of a unit animation, and each variation of a terrain is stored as a separate .png file in ''data/core/images'' under the [[EditingWesnoth#Where_is_my_game_data_directory.3F|main data directory]] of the game, and generally these files will be 72 x 72 pixels (the size of Wesnoth's basic hexagonal tile) with an alpha channel (a part of the file that indicates how transparent each pixel is). When creating your own images, you can test them without overwriting any game data by putting them in your [[EditingWesnoth#Where_is_my_user_data_directory.3F|user data directory]]. The game also supports JPEG images, although these are better suited for story art.&lt;br /&gt;
&lt;br /&gt;
To edit these graphics, you'll need some program capable of creating PNG's - some of the programs in the following list are free, open-source software, and will do the job nicely: [[Art Programs]]&lt;br /&gt;
&lt;br /&gt;
If you need some inspiration, we have a (no longer maintained) [[GraphicLibrary|Graphics Library]] which collects art posted on the forum. You can use this for ideas, and as a scrap heap for different parts of unit images (a technique described [[Give Your Hero A Personality|here]]).&lt;br /&gt;
&lt;br /&gt;
== Art Tutorials ==&lt;br /&gt;
&lt;br /&gt;
These are a work-in-progress, and describe both how to make art fit into Wesnoth's style, as well as giving some considerable tips on drawing in general.  Especially useful is the [[External Tutorials]] page which lists a large number of art tutorials available on the web.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General Art and Computer Graphics ===&lt;br /&gt;
* [[Using the Levels Adjustment]] - How to make scanned pencil drawings ''not'' look washed out.&lt;br /&gt;
* [[Extending dynamic range]] - The Grooviest (so far) tutorial about extending the dynamic range of images and how this technique can be used to make better scans of pencil drawings.&lt;br /&gt;
* [[Scanning with camera]] - How to transfer real-life art to computer using a digital camera instead of a scanner.&lt;br /&gt;
* [[Art Supplies]] - What physical items you need to do larger cell-shaded art like that of Jetrel/Jormungadr/et al.&lt;br /&gt;
* [[Inking With Pencils|Computer Inking a Sketch]] - Info from Jason Lutes on his portrait workflow.&lt;br /&gt;
* [[Scaling Digital Images]] - How to properly resize an image on a computer.&lt;br /&gt;
* [[How to Shade]] - An attempt at tackling a very complicated topic.&lt;br /&gt;
* [[Cartography for Wesnoth|How to make Wesnoth-style Maps ]] - Kestenvarn's tricks of the trade.&lt;br /&gt;
* [[Designing weapons and armour]] - Advice from zookeeper on designing realistic weapons for your characters.&lt;br /&gt;
* [[Portrait Tutorial]] - A guide on how to draw unit/character portraits by Kitty.&lt;br /&gt;
* [[Armour_Tutorial]] A tutorial on how to shade metallic armour by LordBob.&lt;br /&gt;
====Vector Art====&lt;br /&gt;
Sgt. Groovy's vector workshop - Tips and tricks for drawing with Inkscape.&lt;br /&gt;
:* [[Z-order tricks]] - A few methods for faking overlapping shapes.&lt;br /&gt;
:* [[Variable-width strokes]] - How to make the strokes vary in width, like being drawn with a flat-tipped pen &amp;amp;mdash; no tablet needed!&lt;br /&gt;
:* [[Shaped gradients with Gaussian blur]] - How to make gradients in other shapes than linear or radial.&lt;br /&gt;
:* [[Smooth shading in vector]] - The basic vector techniques for smooth shading, employing Gaussian blur and clipping/masking.&lt;br /&gt;
:* [[Vector Inking]] - Vector techniques, including mouse-only, for inking your sketches.&lt;br /&gt;
:* [[Making portrait art in vector]] - A complete tutorial for making Wesnoth unit portraits in vector graphics.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== [[Terrain|Terrain Graphics]] ===&lt;br /&gt;
&lt;br /&gt;
The following is information specific to drawing terrain for Wesnoth.  Read Frame's &amp;quot;Tiles Tutorial&amp;quot; for a good overview of how terrain graphics work.&lt;br /&gt;
&lt;br /&gt;
* [[Mesilliac's Essay on Terrain Perspective]] - The geometry behind the perspective used for terrain tiles in Wesnoth.&lt;br /&gt;
* [[Tiles Tutorial]] - Frame's tutorial describing the process of making terrain tiles in Wesnoth, and how they interact with adjacent tiles.&lt;br /&gt;
* [[How To Make Seamless Tiles]] - The tutorial is aimed at Photoshop users, but the technique is similar with GIMP.&lt;br /&gt;
* [[Seamless Tiles Using Inkscape]] - This tutorial teaches a method for making seamless hex tiles in vector craphics (to be rendered in raster).&lt;br /&gt;
* [[Turning Square Tiles into Hex]] - Nifty tricks for transforming square (or any rectangle) shaped seamless tiles into hexagon seamless tiles.&lt;br /&gt;
* [[CastleTutorial|Castle Tutorial]] - A description of how Wesnoth's castle tiles work (needs updating, but useful nonetheless).&lt;br /&gt;
* [[MultiHexTutorial|Multi-Hex Tiling Tutorial]] - A description of how multi-hex tiles work.&lt;br /&gt;
* [[Editing Castles]] - Instructions for how to make/edit castles (and other corner-based terrains) using yobbo's GIMP script.&lt;br /&gt;
&lt;br /&gt;
These describe the system used to specify how terrains behave in game:&lt;br /&gt;
* [[TerrainCodesWML]] - A list of the letters used to represent terrain types.&lt;br /&gt;
* [[TerrainGraphicsWML]] - If you really need to get technical, start here.&lt;br /&gt;
* [http://www.anathas.org/ayin/wesnoth/doc/terrain_graphics_wml Ayin's Terrain Graphics document] - If you really, ''really'' need to get technical, this describes the terrain graphics WML system in depth.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Sprite Art ===&lt;br /&gt;
The following are different tutorials about sprite work compiled by various Wesnoth sprite artists.  These will give you the most specific-to-Wesnoth information about making sprites, and are well worth a read.&lt;br /&gt;
 &lt;br /&gt;
* [[Creating Unit Art]] - A list of specifications you will need to match.&lt;br /&gt;
* [[Give Your Hero A Personality]] - Tricks for editing existing images, including some clip art.&lt;br /&gt;
* [[Team Color Shifting]] - How to create art that uses our new team color system.&lt;br /&gt;
* [[TeamColoring]] - How to automatically team-color sprites to see what they look like in various colors.&lt;br /&gt;
* [[Creating Shadows Under Units]] - How we create the shadows for the units in-game.&lt;br /&gt;
* [[How to Anti-Alias Sprite Art]] - A means of removing the jagged edges on pixel lines.&lt;br /&gt;
* [[Rotate Pixel Art Without Blurring]]&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
* [[FrankenPacks]] - A quick and dirty way to create sprites for [[WesnothAcronyms|UMC]].&lt;br /&gt;
* [[Creating a scratch built sprite]] - An attempt to show some ways creating a sprite from scratch.&lt;br /&gt;
====Animation====&lt;br /&gt;
:* [[Basic Animation Tutorial]] - Or &amp;quot;How to Animate Sprites for Dummies,&amp;quot; covering the basic theory, and all of the mistakes to avoid.&lt;br /&gt;
:* [[From Base Frame To Full Animation]] - A solid method of moving baseframes forward towards full animation.&lt;br /&gt;
:* [[How to create motion blurs]] - A simple explanation on how to create attack animation weapon blurs.&lt;br /&gt;
:* [[Making Bow Animations]] - The current standard for how we want bow animations to work.&lt;br /&gt;
:* [[Fire Animation]] - A great guide to creating fire FX by rhyging5.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== External Tutorials ===&lt;br /&gt;
The following page contains dozens of links to tutorials covering all manner of artwork, including sprite art.  These were not made by Wesnoth artists, but should prove very useful for general instruction.&lt;br /&gt;
&lt;br /&gt;
* [[External Tutorials]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[EditingWesnoth]]&lt;br /&gt;
* [[GraphicLibrary]] - Lots of usercontributed graphics (most should be GPL'ed)&lt;br /&gt;
* [[Project]]&lt;br /&gt;
* [http://wesnoth.dbzer0.com/blog/wpg2 External Graphic Library] - A project to better organize the art of Wesnoth.&lt;br /&gt;
&lt;br /&gt;
[[Category:Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=External_Tutorials&amp;diff=45832</id>
		<title>External Tutorials</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=External_Tutorials&amp;diff=45832"/>
		<updated>2012-03-26T14:11:26Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Sprite Art */ Added link to Neoriceisgood's mini-tutorial (a .png file hosted on deviantart) on his sprite workflow&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| style=&amp;quot;float:right; margin-left:1em;&amp;quot;&lt;br /&gt;
|__TOC__&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
On this page, there are links to several tutorials covering all manner of artwork, including sprite art.  No guarantees on how long the links will last, but then, the beauty of using a wiki is that anyone can submit corrections to them.  Hopefully, this should provide a very good base of knowledge to work from.  None of these can substitute for practice, rather these exist to guide your practice, and help it to improve your skill rapidly, rather than having you flog away at simple cartoon forms for years and not learn anything.&lt;br /&gt;
&lt;br /&gt;
As stated in some of Jetrel's other tutorials here, ''do not'' jump into the sprite tutorials and ignore the works on general or figure drawing.  If you intend to draw sprites well, the ability to draw and visualize the subject in a general sense is an absolute prerequisite.  Without exception, the best sprite artists are such because they have good basic art skills; understanding of shading, light, proportion, edging, foreshortening, etc.&lt;br /&gt;
&lt;br /&gt;
You can't fake those - even if you never practice anything but spritework, the tutorials for &amp;quot;higher art&amp;quot; are very applicable, and will improve your spriting skill considerably.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== General Art Instruction ==&lt;br /&gt;
&lt;br /&gt;
Andrew Loomis is a master of his field.  ''READ HIS BOOKS.''  They are classics, and are of pristine educational calibre, but unfortunately have been out of print for a long time now and will not enter the public domain any time soon.  If you have any interest in drawing human beings though, they will help you more than the rest of the tutorials on this page, combined.&lt;br /&gt;
&lt;br /&gt;
Copies are highly priced and hard to find in most cases, however due to demand pirated copies are widely available online. While we don't endorse piracy, his books are a great resource and should not be missed.&lt;br /&gt;
&lt;br /&gt;
I personally recommend starting with &amp;quot;Fun with a Pencil&amp;quot; and &amp;quot;Figure Drawing for all it's Worth&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
http://acid.noobgrinder.com/Loomis/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For anatomy George B. Bridgman actually taught Andrew Loomis and is was well regarded for his contributions to art education, his books are still in print and pretty cheap, if you can pick up the smaller individual books I highly recommend doing so, &amp;quot;Bridgman's Complete Guide to Drawing from Life&amp;quot; is a large collection comprising of most of the same drawings and text but due to the changed order and layout is not nearly as good as the originals, luckily some of them have recently entered the public domain and are available from the Internet Archive.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Constructive Anatomy&amp;quot; seems a good place to start, &amp;quot;The Human Machine&amp;quot; is much more useful as a reference.&lt;br /&gt;
&lt;br /&gt;
http://www.archive.org/details/constructiveanat00briduoft&lt;br /&gt;
&lt;br /&gt;
http://www.archive.org/details/humanmachinethea009564mbp&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Condensed human figure tutorial by DeviantArt member coelasquid.&lt;br /&gt;
&lt;br /&gt;
http://coelasquid.deviantart.com/art/How-to-draw-all-sorts-of-crap-104342407&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The Kodak company made the following, very comprehensive introduction to composition.  These rules apply to pictures as well, and will help you when laying out the subjects in a picture.&lt;br /&gt;
&lt;br /&gt;
http://asp.photo.free.fr/Composition/photoProgramCompMainClass.shtml&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following site has a very high-level and overbearing tutorial on color theory.  It's quite useful to experts, but will probably confuse a beginner.&lt;br /&gt;
&lt;br /&gt;
http://handprint.com/HP/WCL/wcolor.html&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Itchy Animation has, amongst other things, a tutorial on the rarely-covered subject of the behaviour of light and its effects on color (rarely covered from an artists' perspective, that is).&lt;br /&gt;
&lt;br /&gt;
http://www.itchy-animation.co.uk/&lt;br /&gt;
&lt;br /&gt;
http://www.itchy-animation.co.uk/tutorials/light01.htm&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GFXartist.com has several tutorials from different artists, including the painter Craig Mullins, who has, for nearly a decade, been the favorite artist of wesnoth's art slave &amp;quot;Jetrel,&amp;quot; and has a good chance of keeping that position for the rest of either fellow's time on this earth.  (J- I can't say enough good things about that guy; I would honestly rank him among the greats, like Rembrandt, or Picasso - he's *that* good.  The tutorials posted on that site do him little justice - for a better sample, his personal site is http://www.goodbrush.com/ , which has over a thousand of his works.)&lt;br /&gt;
&lt;br /&gt;
http://www.gfxartist.com/features/tutorials&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The excellent pencil artist Mike Sibley has a series of tutorials on techniques he uses on his site.  Though some are a bit specific to drawing with graphite, his discussion of negative drawing is very useful to any artist.&lt;br /&gt;
&lt;br /&gt;
http://www.sibleyfineart.com/index.htm?tipsndx.htm&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following website, titled &amp;quot;portrait-artist.org&amp;quot;, offers quite a few good tutorials on portrait drawing.  Though it might not live up to the 'tall order' implied by its name, it's fairly comprehensive:&lt;br /&gt;
&lt;br /&gt;
http://www.portrait-artist.org/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An excellent skin tutorial by DeviantArt member acidlullaby.&lt;br /&gt;
&lt;br /&gt;
http://acidlullaby.deviantart.com/art/Skin-Tutorial-90966884&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This website already features a couple of great painting tutorials and has potential to grow.&lt;br /&gt;
&lt;br /&gt;
http://www.outofpaint.com&lt;br /&gt;
&lt;br /&gt;
== Tutorials on using Computer Graphics Software ==&lt;br /&gt;
&lt;br /&gt;
Good-tutorials.com has over 8000 various tutorials covering different aspects of the popular program, &amp;quot;Adobe® Photoshop®.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
http://www.good-tutorials.com/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The official collection of GIMP tutorials on www.gimp.org. Includes tutorials for users of all skill levels, from beginner through expert.&lt;br /&gt;
&lt;br /&gt;
http://www.gimp.org/tutorials/&lt;br /&gt;
&lt;br /&gt;
== Sprite Art ==&lt;br /&gt;
&lt;br /&gt;
The medium used to create sprite art is known as 'pixel art'. If you do not understand what pixel art is, or if you have only a general understanding of what it is, I suggest reading [http://www.pixeljoint.com/forum/forum_posts.asp?TID=11299 The Pixel Art Tutorial] by Cure. It is comprised of a series of sequential forum posts on the www.pixeljoint.com forum and gives an in-depth overview of pixel art, explaining in detail what pixel art is and what it is not. Although aimed primarily at those who are new to pixel art, the tutorial can also be helpful to more advanced pixel artists. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
An excellent pixel art tutorial that covers a lot of fundamental spriting and pixel art concepts, from sketching and selout to palettes and antialiasing. HIGHLY recommended for pixel artists of all skill levels.&lt;br /&gt;
&lt;br /&gt;
http://purloux.com/artwork/tutorials/rundown/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A very worthwhile mini-tutorial by veteran spriter and pixel artist (and Wesnoth contributor) Neoriceisgood, in which he explains his spriting workflow step-by-step, from the initial sketch to the finished product. (Note: the tutorial is in the form of a 1208x1660 .png file.)&lt;br /&gt;
&lt;br /&gt;
[http://fc01.deviantart.net/fs15/f/2007/063/e/a/How_to_make_sprite_by_Neoriceisgood.png How_to_make_sprite_by_Neoriceisgood.png]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Zoggles has a wealth of tutorials made by many different people, some good, some bad.&lt;br /&gt;
&lt;br /&gt;
http://www.zoggles.co.uk/asp/tutorials.asp?show=index&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A Russian site featuring several tutorials - you may need to click on the &amp;quot;English&amp;quot; link to view the site in a language you can understand, unless you have the privilege of knowing Russian.&lt;br /&gt;
&lt;br /&gt;
http://www.gas13.ru/tutorials/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A fellow named mark posted several tutorials at the following site.  Most of them are fairly decent:&lt;br /&gt;
&lt;br /&gt;
http://www.natomic.com/hosted/marks/mpat/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following is a forum post on some spriting forum containing a list of links to different pixel tutorials.  Some are of banal quality, your mileage may vary.&lt;br /&gt;
&lt;br /&gt;
http://pixeljoint.com/forum/forum_posts.asp?TID=706&amp;amp;PN=1&lt;br /&gt;
&lt;br /&gt;
== Animation ==&lt;br /&gt;
&lt;br /&gt;
Carin Perron has posted an excellent tutorial on the basic principles of animation.&lt;br /&gt;
&lt;br /&gt;
http://www.writer2001.com/animprin.htm&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A very worthwhile tutorial on creating walking animations, covers essential details such as rotation, movement arcs, etc.&lt;br /&gt;
&lt;br /&gt;
http://www.angryanimator.com/word/2010/11/26/tutorial-2-walk-cycle/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another walking animation tutorial:&lt;br /&gt;
&lt;br /&gt;
http://www.dungeoncraftgame.com/blog/?p=39#more-39&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[Art Tutorials]]&lt;br /&gt;
&lt;br /&gt;
[[Category: Art Tutorials]]&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=45629</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=45629"/>
		<updated>2012-03-14T23:38:50Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Chapter 5: Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder what the purpose of this tutorial is. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
This tutorial is aimed at users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder directories. In this tutorial you will learn WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML; a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign attributes to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario, otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Common Events====&lt;br /&gt;
&lt;br /&gt;
Now, I'm not going to supply you with an exhaustive list of every kind of predefined event and what each does, that's what the [[EventWML]] page is for. I will, however, provide you with a list of the most frequently used predefined events and what they do, since we will be using these events in our campaign scenarios later on.&lt;br /&gt;
&lt;br /&gt;
(list these events: prestart, start, moveto, time over, die, last breath)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without. Instead of using multiple [if] codeblocks, you could simply use the switch/case codeblock to evaluate the value of a variable and determine the action performed as a result of the evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=45628</id>
		<title>WML for Complete Beginners</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=WML_for_Complete_Beginners&amp;diff=45628"/>
		<updated>2012-03-14T23:28:14Z</updated>

		<summary type="html">&lt;p&gt;Artisticdude: /* Attributes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Template for future &amp;quot;WML for Complete Beginners&amp;quot; tutorial'''&lt;br /&gt;
&lt;br /&gt;
'''Note: this is a work in progress.'''&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
TODO:&lt;br /&gt;
&lt;br /&gt;
1. Move the &amp;quot;objectives&amp;quot; section and make it a subsection of the &amp;quot;events&amp;quot; section, since objectives are defined within a prestart event.&lt;br /&gt;
2. Add to the numbers definition that numbers can include decimal point values (and reference the fact that WML will remove any unnecessary 0's when it performs the calculations or accesses the numerical value in question)&lt;br /&gt;
&lt;br /&gt;
-------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
Hey there!&lt;br /&gt;
&lt;br /&gt;
Now I'm guessing that, if you're reading this, you already know what The Battle for Wesnoth is. If you don't, I suggest finding before you read this tutorial.&lt;br /&gt;
&lt;br /&gt;
Some people may wonder what the purpose of this tutorial is. &amp;quot;We already have almost every aspect of WML covered in the [[ReferenceWML]] section,&amp;quot; these people might say. But the information contained in the WML reference section is just that: a reference. Not a tutorial. This page aims to introduce complete beginners to WML without their having to sift for days through &amp;quot;references&amp;quot; until WML finally begins to vuagely make some sort of sense.&lt;br /&gt;
&lt;br /&gt;
===Who This Tutorial is For===&lt;br /&gt;
This tutorial is aimed at users with no previous programming knowledge. This tutorial does assume that you have a certain level of competence in basic computer skills and concepts, such as opening and editing text files, and being able to follow folder directories. In this tutorial you will learn WML by building a short single-player campaign from the ground up.&lt;br /&gt;
&lt;br /&gt;
===What Tools You Will Need===&lt;br /&gt;
&lt;br /&gt;
Programming WML requires only one tool: a basic text editor. You don't need a fancy word processor to program WML; a simple program like Windows Notepad or Mac OS X TextEdit will work just fine. For Linux, there is a very nice text editing application called Kate that actually comes with syntax highlighting for WML.&lt;br /&gt;
&lt;br /&gt;
Obviously, you will also need The Battle for Wesnoth installed on your computer.&lt;br /&gt;
&lt;br /&gt;
===So What Exactly is WML?===&lt;br /&gt;
&lt;br /&gt;
WML is an acronym for the &amp;quot;Wesnoth Markup Language&amp;quot;, a custom scripting language that The Battle For Wesnoth uses to allow players to create and modify content without having to learn a much more complex language like Lua or C++. Now I'm going to say this here and now: don't think you can learn WML overnight. Although WML is relatively easy to learn, it will take a certain amount of effort, time and dedication on your part to fully understand the ins and outs of the language.&lt;br /&gt;
&lt;br /&gt;
==Chapter 1: Syntax==&lt;br /&gt;
&lt;br /&gt;
First things first; let's go over the ''syntax'' of WML.&lt;br /&gt;
&lt;br /&gt;
For those of you who might not know what the &amp;quot;syntax&amp;quot; of a language is, think of it as a set of rules for how WML needs to be written in order for the game to understand it. This concept may sound a bit confusing, but whether you realize it or not you have been using the concept of syntax your entire life! Think of the structure of a sentence in English: &amp;quot;I like jelly and cheese sandwiches.&amp;quot; That sentence uses a certain set of rules, or ''syntax'' in order to make sense to people who hear or read it. If you said instead, &amp;quot;Like cheese I and sandwiches jelly&amp;quot;, that would make no sense, and no one would understand what you were saying. Likewise, if you said &amp;quot;I like cheese sandwiches and jelly&amp;quot;, that would change the entire meaning of the sentence! &lt;br /&gt;
&lt;br /&gt;
Just like the syntax of the English language, WML syntax also requires proper capitalization, spelling, grammar and punctuation in order for others to understand what you're saying or writing. For example, if you decided to ignore the syntax of the English language and wrote something like this: &amp;quot;won day mary and i had went to seen the elefant at the zoo it's trunc was reely long&amp;quot;, chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: &amp;quot;One day Mary and I went to see the elephant at the zoo. Its trunk was really long!&amp;quot;, people can easily understand what you wrote because it is written in the syntax they recognize and understand. Just as English-reading people would be unable to understand something were it not written in the correct English syntax, the Battle for Wesnoth game is unable to read any WML that is not written in the correct WML syntax.&lt;br /&gt;
&lt;br /&gt;
So now let's go over the basics of WML syntax. Later on you will be gradually introduced to more complex WML syntax, but for now we'll just go over the basic stuff, enough to get you started.&lt;br /&gt;
&lt;br /&gt;
===Basic Components: Tags and Attributes===&lt;br /&gt;
&lt;br /&gt;
WML, as one can infer from the meaning of the acronym, is a [http://en.wikipedia.org/wiki/Markup_language markup language]. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.&lt;br /&gt;
&lt;br /&gt;
====Tags====&lt;br /&gt;
:A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [campaign]&lt;br /&gt;
&lt;br /&gt;
:Tags can only contain alphanumeric characters (letters and numbers) and underscores &amp;quot;_&amp;quot;. Notice I said earlier that &amp;quot;a tag is a string of ''lowercase'' text&amp;quot;. This is a fundamental aspect of the WML syntax: all tags are always written in lowercase letters. If you try and use capital letters (even just one), the WML engine won't be able to understand what tag you're trying to use and will give you an error when it tries to read the incorrect tag. &lt;br /&gt;
&lt;br /&gt;
:As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening tag and the closing tag like the covers of a book: when you open the front cover, you know you're at the beginning. When you reach the back cover, you know you're done reading the book. Likewise, when the WML engine finds an opening tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.&lt;br /&gt;
&lt;br /&gt;
:Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash &amp;quot;/&amp;quot; immediately after the first square bracket. This forward slash tells the WML engine that this tag is a closing tag and not another opening tag. Here is an example of the closing &amp;quot;campaign&amp;quot; tag:&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
:The opening and closing tag together are referred to as a &amp;quot;tagset&amp;quot;. A tagset always contains exactly two tags: the opening tag and the closing tag. So the &amp;quot;campaign&amp;quot; tagset would look like this:&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:So now we know how the WML engine knows where the beginning and end of a task are, and what syntax to use when writing them. These are the basics of tags. Later on we'll go over the more complicated aspects of tags; for now though, make sure you understand the concepts introduced here. Before we move on to the next section, let's review the points we've learned in this section about tags:&lt;br /&gt;
&lt;br /&gt;
::*A tag is a string of lowercase text encapsulated by two square brackets, one at either end.&lt;br /&gt;
::*A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.&lt;br /&gt;
::*The opening tag and the closing tag together are called the tagset.&lt;br /&gt;
::*A tagset consists of exactly two tags: the opening tag and the closing tag.&lt;br /&gt;
&lt;br /&gt;
:So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually making it do the task? This is where attributes come in.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Attributes====&lt;br /&gt;
&lt;br /&gt;
:Attributes consist of two principal elements: ''keys'' and ''values'', and are written like so:&lt;br /&gt;
 key=value&lt;br /&gt;
&lt;br /&gt;
:The basic function of attributes is to store information that is needed by the WML engine. The ''key'' of the attribute specifies what kind of information is stored, and the ''value'' of the attribute is the actual data that is stored. All text to the left of the equals sign &amp;quot;=&amp;quot; is considered to be the key, and all text to the right of the equals sign is considered to be the value of the key.&lt;br /&gt;
&lt;br /&gt;
:This may sound rather confusing, so let's illustrate by a practical example:&lt;br /&gt;
&lt;br /&gt;
:Let's say you wanted your friend to go to the grocery store and pick you up a loaf of bread. Would you say to him, &amp;quot;Go&amp;quot;? Of course not! He wouldn't understand what you wanted him to do, which means you'd have no bread for dinner. Likewise, if you only write a tagset, that's equivalent to telling the WML engine to &amp;quot;do&amp;quot;, but that's not enough. You will need to be more specific about exactly what the WML engine should do. If your friend were a human WML engine and you wanted him to go to the grocery store to get some bread, you might give him this code to read (''note'': this code isn't actually real WML, it is &amp;quot;pseudocode&amp;quot;, i.e. made up code for the purpose of illustration. If I ever use pseudocode during this tutorial I will tell you that it is pseudocode before you read the example, like I am doing now.):&lt;br /&gt;
 [go]&lt;br /&gt;
     where=grocery_store&lt;br /&gt;
     get=bread&lt;br /&gt;
 [/go]&lt;br /&gt;
&lt;br /&gt;
:Tags tell the WML engine what kind of task to do, but without attributes to specify ''exactly'' what to do, the WML engine won't be able to do anything because you haven't given it enough specific information. This is just like if you told your friend to &amp;quot;Go&amp;quot;: he'd understand that you want him to go somewhere, but he'd be unable to perform the task because he doesn't know where to go or what to do when he gets there.&lt;br /&gt;
&lt;br /&gt;
:*'''Keys'''&lt;br /&gt;
::Keys are sequences of lowercase alphabetic characters that tell the game what kind of information it is dealing with when it reads the attribute. Keys are case-sensetive (i.e., you can't use capital letters) and must be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
:*'''Values'''&lt;br /&gt;
&lt;br /&gt;
::WML keys deal with one and only one type of data, called ''strings''. A string is simply a sequence of ASCII characters that can include pretty much any character on your keyboard. Strings may be divided into two categories: Standard and Numerical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''1. Standard Strings'''&lt;br /&gt;
&lt;br /&gt;
::A standard string is simply a sequence of ASCII characters that is neither a numerical nor a translatable string. For example, this is a standard string:&lt;br /&gt;
 x&lt;br /&gt;
::as is this:&lt;br /&gt;
 blue&lt;br /&gt;
&lt;br /&gt;
::If a standard string includes whitespaces, it must be enclosed within double quotes:&lt;br /&gt;
 &amp;quot;Everything in these double quotes is a single string. This is the number one: 1. Hooray! :) We are now coming to the end of this string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::Everything within the double quotes (including the colon and parenthesis emoticon) is considered to one long string by the game.&lt;br /&gt;
&lt;br /&gt;
::Sometimes you will want to mark a standard string as translatable so that it can be translated into other languages. The only difference between a translatable sting and a non-transatable is that translatable strings are marked so that translators know that they need to translate that string, and non-translatable strings are not marked, so the translators know that they don't translate those strings.&lt;br /&gt;
&lt;br /&gt;
::To mark a string as translatable, you simply put an underscore in front of the string, before the first double quote that marks the beginning of the string. Example of a translatable string:&lt;br /&gt;
&lt;br /&gt;
  _ &amp;quot;This is a translatable string.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
::If the WML engine does not find an underscore in front of the string, it will assume the string is non-translatable.&lt;br /&gt;
&lt;br /&gt;
::Although not strictly necessary, it is considered good syntax to include a space before and after the underscore that marks a string as translatable. For instance, if we were to assign the translatable string &amp;quot;Hello World!&amp;quot; to this key, it would be considered good syntax to write&lt;br /&gt;
 key= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::rather than&lt;br /&gt;
 key=_&amp;quot;Hello World!&amp;quot;&lt;br /&gt;
::although the game considers both to be equivalent, and will therefore recognize both as translatable strings.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''2. Numerical Strings'''&lt;br /&gt;
&lt;br /&gt;
::Numerical strings, obviously, are strings that contain only numbers, decimal points, or minus signs &amp;quot;-&amp;quot;. If a string contains anything other than numbers, decimal points and/or a minus sign, the string becomes a standard string instead of a numerical one. Numerical strings can be either a single numeric character like this:&lt;br /&gt;
 2&lt;br /&gt;
::a sequence of numeric characters, like this:&lt;br /&gt;
 230001&lt;br /&gt;
&lt;br /&gt;
::or floating-point values (that's just a fancy way of saying that they can contain decimal points), like these two examples:&lt;br /&gt;
 2.6&lt;br /&gt;
 395667.49382345&lt;br /&gt;
&lt;br /&gt;
::or negative numbers, like these examples:&lt;br /&gt;
 -49&lt;br /&gt;
 -594.932&lt;br /&gt;
&lt;br /&gt;
::For all intents and purposes, you can treat numerical strings just as you would numbers in real life. You can add, divide, and otherwise mathematically employ them in mathematical computations (we'll go over this in-depth in chapter X). Just remember that if you include any characters other than numbers, decimal points, or minus signs, the string will cease to be a numeric string and will become a standard string, which means you won't be able to use it in mathematical calculations.&lt;br /&gt;
&lt;br /&gt;
::Directory paths are simply special strings that tell the game where to find a specific file or folder. Here is an example of a directory path:&lt;br /&gt;
 {data/add-ons/my_first_campaign}&lt;br /&gt;
This directory path tells the game where the folder &amp;quot;my_first_campaign&amp;quot; is located.&lt;br /&gt;
&lt;br /&gt;
===More About Tags===&lt;br /&gt;
&lt;br /&gt;
So now you should understand the basics about tags and attributes. As I promised earlier, we will now discuss some of the more involved aspects of tags.&lt;br /&gt;
&lt;br /&gt;
====Nested Tags: Parents and Children====&lt;br /&gt;
&lt;br /&gt;
:A fundamental aspect of markup languages is that you can use tagsets inside other tagsets. Tagsets located inside other tagsets are called nested tagsets. In the example below, the &amp;quot;side&amp;quot; tagset is nested inside the &amp;quot;scenario&amp;quot; tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [side]&lt;br /&gt;
     [/side]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
:When referring to nested tagsets, the tagset located inside the other is called the ''child'' tagset, and the tagset that encloses the child tagset is known ast he ''parent'' tagset. To illustrate with pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [parent]&lt;br /&gt;
     [child]&lt;br /&gt;
     [/child]&lt;br /&gt;
 [/parent]&lt;br /&gt;
&lt;br /&gt;
:Tagsets that are not child tagsets of any other tagsets are called ''toplevel'' tagsets. In this next example, the [scenario] tagset is a toplevel tagset, because it is not the child tagset of any other tagset. The  [event] tagset is the child tagset of [scenario], because it is located inside the [scenario] tagset. The tagset [event] is also the parent tagset of the [message] tagset, because the [message] tagset is located inside the [event] tagset. That means that since [event] is the parent of [message], [message] is the child tagset of [event].&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
     [event]&lt;br /&gt;
         [message]&lt;br /&gt;
         [/message]&lt;br /&gt;
     [/event]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Indentation and Levels====&lt;br /&gt;
&lt;br /&gt;
:You may have noticed that in the examples above, the child tagsets are indented four spaces further to the right than are their parent tagsets. Why is this? It's because proper indentation (although not technically required by the WML engine) makes you code a lot easier to read and maintain. It's like writing an outline for a school paper, where you would write something like this:&lt;br /&gt;
&lt;br /&gt;
 I.&lt;br /&gt;
     A.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
 II.&lt;br /&gt;
     A.&lt;br /&gt;
         1.&lt;br /&gt;
         2.&lt;br /&gt;
     B.&lt;br /&gt;
     C.&lt;br /&gt;
&lt;br /&gt;
:Indentation makes it much easier to see whether tagset is the child or parent of other tagsets. The amount of indentation before a tagset determines in what level that tagset is located. If the tagset is a toplevel tagset (i.e. has no spaces in front of it because it is not the child of any other tagset), that tagset is located at level one. Tagsets with an indentation of four spaces in front of them are located in level 2, because they are the children of the toplevel (level 1) tagset. Tagsets that are children of level 2 tagsets are called level 3 tagsets (and are indented 12 spaces), tagsets inside level 3 tagsets are called level 4 tagsets (and are indented 16 spaces), etc. As a general rule, all the attributes of a tagset, along with any child tagsets of that tagset, are indented one level deeper than that tagset. To illustrate in pseudocode:&lt;br /&gt;
&lt;br /&gt;
 [toplevel_tagset]&lt;br /&gt;
     level_2_attribute=value&lt;br /&gt;
     [level_2_tagset]&lt;br /&gt;
         level_3_attribute=value&lt;br /&gt;
         [level 3 tagset]&lt;br /&gt;
             level_4_attribute=value&lt;br /&gt;
         [/level 3 tagset]&lt;br /&gt;
     [/level_2_tagset]&lt;br /&gt;
 [/toplevel_tagset]&lt;br /&gt;
&lt;br /&gt;
:Indenting tagsets and attributes into levels like this makes it much easier for you (and others) to read, fix and maintain your code. It is strongly recommended that you indent exactly four spaces for each new level, although you can also use tabs instead of hitting the space key 4 times, if you'd prefer.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 2: The Userdata Directory and the Campaign Folder==&lt;br /&gt;
&lt;br /&gt;
So now that you understand the basic syntax of WML, it's time to learn where The Battle for Wesnoth stores files so that we can begin creating our campaign.&lt;br /&gt;
&lt;br /&gt;
===The Userdata Directory===&lt;br /&gt;
&lt;br /&gt;
There are two main directories that Wesnoth creates on your computer. The '''installation directory''' contains all the files for the core game. The '''userdata directory''' stores all your personal Wesnoth data, which includes your installed add-ons, your settings and preferences, and your saved games. The userdata directory is where we will store your work throughout this tutorial.&lt;br /&gt;
&lt;br /&gt;
The location of your userdata directory differs depending on your operating system, and in the case of Microsoft Windows, the version of your operating system. Refer to the following table to determine where your userdata directory is located:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Windows XP&lt;br /&gt;
|~/My Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Windows Vista and above&lt;br /&gt;
|~/Documents/My Games/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Mac OS X&lt;br /&gt;
|~/Library/Application Support/Wesnoth 1.10/&lt;br /&gt;
|-&lt;br /&gt;
!Linux&lt;br /&gt;
|~/.local/share/wesnoth/1.10/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now navigate to your userdata folder. Provided that you have already run the Wesnoth application at least once before, you should see a total of five folders (&amp;quot;cache&amp;quot;, &amp;quot;data&amp;quot;, &amp;quot;editor&amp;quot;, &amp;quot;persist&amp;quot;, and &amp;quot;saves&amp;quot;) in this directory, along with two files (&amp;quot;preferences&amp;quot; and &amp;quot;save_index.gz&amp;quot;). If you see all seven of these, everything is good. If you do not see all seven, try running the Wesnoth application. If that does not work, try restarting your computer. If neither of these steps work, reinstall Wesnoth.&lt;br /&gt;
&lt;br /&gt;
Of the seven objects contained in the userdata folder, you will only ever need to directly interact with two: the &amp;quot;data&amp;quot; folder and the &amp;quot;editor&amp;quot; folder.&lt;br /&gt;
&lt;br /&gt;
====The data folder====&lt;br /&gt;
&lt;br /&gt;
:The data folder is where all installed add-ons are kept. This is where we will be building our campaign, when we get to that. If you have previously installed any Wesnoth add-ons, they should show up in this folder.&lt;br /&gt;
&lt;br /&gt;
====The editor folder====&lt;br /&gt;
&lt;br /&gt;
:The editor folder is where all maps created with the in-game map editor are stored. If you have ever created and saved a map in-game, you should see the map file in this directory.&lt;br /&gt;
&lt;br /&gt;
===The Campaign Folder===&lt;br /&gt;
&lt;br /&gt;
Like I told you earlier, all add-ons are installed in the data folder inside the userdata directory. That means that your campaign will also be located inside the data folder. If you're not already there, enter the data folder now.&lt;br /&gt;
&lt;br /&gt;
Next, create a new folder inside the data folder. Name this new folder &amp;quot;my_first_campaign&amp;quot; exactly as I wrote it here (but don't include the quotation marks). Make sure you spelled it right, that you didn't accidentally capitalize any letters and that you included the underscores between the words in the folder name, because if you don't your campaign won't work when you try to play it. &lt;br /&gt;
&lt;br /&gt;
Now enter the &amp;quot;my_campaign&amp;quot; folder and create seven new folders. Name these folders &amp;quot;images&amp;quot;, &amp;quot;macros&amp;quot;, &amp;quot;maps&amp;quot;, &amp;quot;scenarios&amp;quot;, &amp;quot;translations&amp;quot;, &amp;quot;units&amp;quot; and &amp;quot;utils&amp;quot; (again, make sure you spelled everything right, that you didn't accidentally capitalize anything, and that you didn't include the quotation marks).&lt;br /&gt;
&lt;br /&gt;
All campaigns share this common folder structure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 3: The _main.cfg==&lt;br /&gt;
&lt;br /&gt;
Note: this page borrows heavily from the [[BuildingCampaignsTheCampaignFile]] page.&lt;br /&gt;
&lt;br /&gt;
So we've created a campaign folder, but as of yet the game doesn't even know this new folder exists. In order for the game to find the folder, we have to create a special file called &amp;quot;_main.cfg&amp;quot; that tells the game where to find all of your campaign's data. Without this file, the game won't be able to find your campaign when it starts up, and consequently you won't be able to play your campaign. &lt;br /&gt;
&lt;br /&gt;
So let's get started creating a &amp;quot;_main.cfg&amp;quot; file so that the game can find your campaign.&lt;br /&gt;
&lt;br /&gt;
Navigate to your campaign folder, if you aren't already there. Now create a new text file and name it &amp;quot;_main.cfg&amp;quot; (just like that, including the underscore but without the quotes). Now you have created a file called &amp;quot;_main.cfg&amp;quot;, but we're not done yet. Right now the file is empty, so the game still won't be able to locate your campaign yet. But fear not, all you have to do is write some specific WML inside the &amp;quot;_main.cfg&amp;quot; file and the game will be able to find your campaign just fine.&lt;br /&gt;
&lt;br /&gt;
===The Text Domain===&lt;br /&gt;
&lt;br /&gt;
Open the &amp;quot;_main.cfg&amp;quot; file in your text editor if you haven't already. and add the following tagset:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
This tagset which specifies where the game should look for translations to the strings in the campaign (at this stage you probably won't have any translations, but it's a common practice to add a text domain just in case you get translations later on). The textdomain tag specifies a name for the textdomain, which is what is used in the [campaign] tag, and is used in campaign scenarios to connect the strings with translations. &lt;br /&gt;
&lt;br /&gt;
Inside the [textdomain] tag, include the attributes '''name''' and '''path''' (don't assign attributes to them just yet, we'll do that in a moment):&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''name''' specifies the name of the text domain you are creating. The textdomain name should be unique, and start with 'wesnoth-', to ensure that it does not conflict with other textdomains that might be specified on a given system. Let's name our text domain &amp;quot;my_first_campaign&amp;quot;. Don't forget to start it with &amp;quot;wesnoth-&amp;quot;. Now the contents of your _main.cfg file should look exactly like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;path&amp;quot; Attribute'''&lt;br /&gt;
The attribute '''path''' specifies a path to the directory where the compiled translation files will be stored. This should be a file inside the campaign directory. Right now our translations folder is empty, but if you ever get translations for your campaign, this is the folder in which they would go. Let's assign the &amp;quot;translations&amp;quot; folder directory path, which should be &amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;,  to this attribute. Your _main.cfg should now look like this:&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
&lt;br /&gt;
===Defining the Campaign===&lt;br /&gt;
&lt;br /&gt;
And now we're going to add the [campaign] tagset. Yes, it's our old friend, the [campaign] tagset, from Chapter 1.&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Next, inside the [campaign] tagset, include the following line:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
This tells the game that the text strings in this file belong to the text domain you just defined above&lt;br /&gt;
&lt;br /&gt;
Next we need to give the attributes '''id''','''name''','''abbrev''','''icon''','''image''','''first_scenario''','''description''','''difficulties''', and '''difficulty_descriptions'''. Don't assign any values to these attributes yet, we'll do that in a moment. For now, just make sure that you have all of these attributes in between the campaign tags, like so (the exact order of the attributes doesn't matter, but it is recommended that you follow the order given below to make things easier for yourself when following this tutorial):&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=&lt;br /&gt;
     name=&lt;br /&gt;
     abbrev=&lt;br /&gt;
     define=&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=&lt;br /&gt;
     description=&lt;br /&gt;
     difficulties=&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
Now let's go over the attributes one by one and give them their values. I'll give you a specific value to assign to each attribute, and then I'll explain why we use that particular value.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Attribute'''&lt;br /&gt;
:The unique identifier of your campaign. The value of an &amp;quot;id&amp;quot; attribute can only contain lowercase alphanumeric characters and underscores. We are going to give this attribute the value &amp;quot;my_first_campaign&amp;quot;, like so:&lt;br /&gt;
 id=my_first_campaign&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Attribute'''&lt;br /&gt;
:The name of your campaign. This translatable string is the name that will show up in the in-game campaign menu, where you can select which campaign you want to play. Let's give it the value &amp;quot;My First Campaign&amp;quot;. Since we want this string to be translatable, don't forget to include the translation mark (the underscore) in front of the first double quote.&lt;br /&gt;
 name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;abbrev&amp;quot; Attribute'''&lt;br /&gt;
:This attribute defines a campaign abbreviation that will be used as a prefix for the names of save files from that campaign. It should generally consist of the acronym of the campaign's name (i.e., the first letter of each of the words in the campaign's name, capitalized).&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;define&amp;quot; Attribute'''&lt;br /&gt;
This attribute creates a key that lets the game know when a user has selected to play a scenario from your campaign.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;icon&amp;quot; Attribute'''&lt;br /&gt;
The image that will be displayed next to the name of your campaign in the in-game campaign selection menu. Since we need the game to locate a specific file, we [...]&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;image&amp;quot; Attribute'''&lt;br /&gt;
This defines the image that will appear under your campaign's description when your campaign is selected in the in-game campaign selection menu.&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;first_scenario&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;description&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulties&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;difficulty_descriptions&amp;quot; Attribute'''&lt;br /&gt;
&lt;br /&gt;
 [campaign]&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions=&lt;br /&gt;
 [/campaign]&lt;br /&gt;
&lt;br /&gt;
===The Preprocessor===&lt;br /&gt;
(discuss preprocessor directives, binary path, directory inclusion, etc.)&lt;br /&gt;
&lt;br /&gt;
====Preprocessor Directives====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Binary Path====&lt;br /&gt;
The binary path is used to tell the game to include a certain directory in the userdata folder whenever it searches for a file. For instance, if you had a custom image in your campaign called &amp;quot;my_face.png&amp;quot;, whenever the game finds a reference to that file in a scenario (e.g., you want to display that image at one of the story screens in a scenario), it will first search the core gamedata directories, then it will search any folders included in the binary path. If it cannot find the file in either the gamedata directory or in any of the directories specified in the binary path, then it will give you an error.&lt;br /&gt;
&lt;br /&gt;
You will only need to include a binary path if your campaign contains custom images, sounds or music that is not included in mainline Wesnoth. If you do not have any custom images, sounds or music, then you should not include a binary path. Since we will be including some custom images in our campaign, we are going to need to include a binary path.&lt;br /&gt;
&lt;br /&gt;
To create a binary path, use the following syntax:&lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
This tells the game to search the specified userdata directory whenever it cannot locate a certain file in the gamedata directory. Note that the value of the &amp;quot;path&amp;quot; key must always begin with &amp;quot;data/add-ons/&amp;quot; followed by the name of your campaign folder.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Directory Inclusion====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(The final _main.cfg should end up looking something like this:)&lt;br /&gt;
&lt;br /&gt;
 [textdomain]&lt;br /&gt;
     name=&amp;quot;wesnoth-my_first_campaign&amp;quot;&lt;br /&gt;
     path=&amp;quot;data/add-ons/my_first_campaign/translations&amp;quot;&lt;br /&gt;
 [/textdomain]&lt;br /&gt;
 &lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 &lt;br /&gt;
 [campaign]&lt;br /&gt;
     #wesnoth-My_First_Campaign&lt;br /&gt;
     id=my_first_campaign&lt;br /&gt;
     name= _ &amp;quot;My First Campaign&amp;quot;&lt;br /&gt;
     abbrev= _ &amp;quot;MFC&amp;quot;&lt;br /&gt;
     define=CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 #need icon and image (take from core files, don't include external files for sake of simplicity)&lt;br /&gt;
     icon=&lt;br /&gt;
     image=&lt;br /&gt;
     first_scenario=my_first_scenario&lt;br /&gt;
     description= _ &amp;quot;This is my first campaign.&amp;quot;&lt;br /&gt;
     difficulties=EASY&lt;br /&gt;
     difficulty_descriptions={MENU_IMG_TXT2 units/undead/shadow-s-attack-4.png  _&amp;quot;Easy&amp;quot;  _&amp;quot;&amp;quot;}&lt;br /&gt;
 [/campaign]&lt;br /&gt;
 &lt;br /&gt;
 #ifdef CAMPAIGN_MY_FIRST_CAMPAIGN&lt;br /&gt;
 &lt;br /&gt;
 [binary_path]&lt;br /&gt;
     path=data/add-ons/my_first_campaign&lt;br /&gt;
 [/binary_path]&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/macros}&lt;br /&gt;
 {~add-ons/my_first_campaign/utils}&lt;br /&gt;
 &lt;br /&gt;
 {~add-ons/my_first_campaign/scenarios}&lt;br /&gt;
 #endif&lt;br /&gt;
&lt;br /&gt;
(note: no units yet, save that for the adding custom units section)&lt;br /&gt;
&lt;br /&gt;
==Chapter 4: Creating Your First Scenario==&lt;br /&gt;
&lt;br /&gt;
Now that you have your _main.cfg file, it's time to create your first scenario.&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario Map===&lt;br /&gt;
&lt;br /&gt;
All scenarios require a map in order to work. Open the Battle for Wesnoth application. On the mainmenu, you should see an option labeled &amp;quot;Map Editor&amp;quot;. Click this option and wait for the editor to load.&lt;br /&gt;
&lt;br /&gt;
By default, Wesnoth creates a blank map with the dimensions 44 x 33 (43 wide and 33 tall). These dimensions will work fine for our purposes, so we won't change them. Hover your cursor over the map and look at the center of the upper edge of the Battle for Wesnoth application window. You should see two numbers separated by a comma.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
These numbers are the X and Y coordinates of the hex over which your cursor is currently hovering. If you move your cursor to another hex, the coordinates will change to show the new location of your cursor. This is a fast and convenient way to locate coordinates on the map.&lt;br /&gt;
&lt;br /&gt;
So we have a map, but let's face it: it's rather dull and uninteresting. Time to add some new terrain. Locate the terrain palette (the area at the far right of your Battle for Wesnoth window that displays the terrains you can use in the editor).&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
Towards the top of this window, you should see the terrain category selection buttons. From here you can change what category of terrain is displayed in the terrain palette.&lt;br /&gt;
&lt;br /&gt;
(screenshot)&lt;br /&gt;
&lt;br /&gt;
First, let's add a castle for the leader of the player's side to recruit from in the first scenario. Click on the &amp;quot;castle&amp;quot; terrain category button.&lt;br /&gt;
&lt;br /&gt;
(screenshot of the castle terrain category button)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Creating the Scenario .cfg File===&lt;br /&gt;
&lt;br /&gt;
Create a new text file in the &amp;quot;scenarios&amp;quot; folder inside your campaign folder. Name this new text file &amp;quot;my_first_scenario.cfg&amp;quot;. Open the &amp;quot;my_first_scenario.cfg&amp;quot; file in your text editor, if you haven't already. Since it is a new file, it should be completely empty right now. It won't be when we're done with it, however!&lt;br /&gt;
&lt;br /&gt;
====The Toplevel Tagset and Attributes====&lt;br /&gt;
&lt;br /&gt;
First, on the very first line of the file, tell the game what text domain this file belongs to. In case you forgot, the text domain for this campaign is &amp;quot;     wesnoth-my_first_campaign&amp;quot;. So you would write:&lt;br /&gt;
&lt;br /&gt;
     #textdomain wesnoth-my_first_campaign&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now let's add the [scenario] tagset:&lt;br /&gt;
&lt;br /&gt;
 [scenario]&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
The [scenario] tagset is a toplevel tagset (i.e., it is not the child of any other tagset) and tells the game where the scenario begins and where it ends. All the information for your scenario goes within this tagset.&lt;br /&gt;
&lt;br /&gt;
Next, inside the [scenario] tagset, include the following keys (don't forget to indent 4 spaces before each key):&lt;br /&gt;
 id=&lt;br /&gt;
 next_scenario=&lt;br /&gt;
 name=&lt;br /&gt;
 map_data=&lt;br /&gt;
 turns=&lt;br /&gt;
&lt;br /&gt;
Now the contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=&lt;br /&gt;
     next_scenario=&lt;br /&gt;
     name=&lt;br /&gt;
     map_data=&lt;br /&gt;
     turns=&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
We have provided keys for these attributes, so now it's time to assign them their values. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;id&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:Assign the value &amp;quot;my_first_scenario&amp;quot; to the &amp;quot;id&amp;quot; key, like so:&lt;br /&gt;
 id=my_first_scenario&lt;br /&gt;
:Do you remember the value we assigned to the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot; file? If you followed the instructions given in this tutorial, the value of that key should be &amp;quot;my_first_scenario&amp;quot;. It is absolutely imperative that the value of the &amp;quot;first_scenario&amp;quot; key and the &amp;quot;id&amp;quot; key of the first scenario are exactly the same. If you misspelled either of them, introduced an incorrect capitalization into either of them, or made a typo of any kind in either of them, the game will return an error message when it tries to load the scenario. This is because the value of the &amp;quot;first_scenario&amp;quot; key refers to the id of your first scenario. If there is no scenario with an &amp;quot;id&amp;quot; key whose value exactly matches the value of the &amp;quot;first_scenario&amp;quot; key in the &amp;quot;_main.cfg&amp;quot;, the game won't be able to find the first scenario and will tell you so by giving you an error message when you try to play your campaign.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;next_scenario&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key. Example:&lt;br /&gt;
 next_scenario=null&lt;br /&gt;
:The &amp;quot;next_scenario&amp;quot; key is a close cousin of the &amp;quot;first_scenario&amp;quot; key found in the &amp;quot;_main.cfg&amp;quot; file. Just as the &amp;quot;first_scenario&amp;quot; tells the game to look for a scenario with an id key whose value matches the value of the the &amp;quot;first_scenario&amp;quot; key, the &amp;quot;next_scenario&amp;quot; key tells the game which scenario to load after the player completes the current scenario. Just like with the &amp;quot;first_scenario&amp;quot; key, make sure the value of the &amp;quot;next_scenario&amp;quot; key exactly matches the id of the next scenario, otherwise you'll get an error message. If there is no next scenario, you would assign the value &amp;quot;null&amp;quot; to the &amp;quot;next_scenario&amp;quot; key, as we did here. This means that when the player completes the current scenario, the game knows that there is no next scenario to go to, and the campaign will end.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;name&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:For this attribute, we are going to give it this translatable string: &lt;br /&gt;
  _ &amp;quot;My First Scenario.&amp;quot; &lt;br /&gt;
As you should recall from our previous discussion about translatable strings, the value we give should be enclosed in double quotes and should have a whitespace, an underscore, and then another whitespace immediately before the first double quote. So now your &amp;quot;name&amp;quot; attribute should look like this:&lt;br /&gt;
 name= _ &amp;quot;My First Scenario&amp;quot;&lt;br /&gt;
:Technically, the name of the scenario doesn't have to resemble the scenario's id at all. But it's a good idea to have the scenario id and the scenario name be as similar as possible to avoid any confusion later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;map_data&amp;quot; Key&lt;br /&gt;
&lt;br /&gt;
:For this key, we are going to assign the value &amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;. Map filepaths must always be within surrounded by double quotes, otherwise error messages will occur. Now it should look like this:&lt;br /&gt;
 map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''The &amp;quot;turns&amp;quot; Key'''&lt;br /&gt;
&lt;br /&gt;
:We are going to assign the number &amp;quot;30&amp;quot; to this key:&lt;br /&gt;
&lt;br /&gt;
 turns=30&lt;br /&gt;
&lt;br /&gt;
:This attribute specifies how many turns the player will have to complete the scenario. If the player does not complete the scenario objective before the turns run out, then the player will lose the scenario. Since we have assigned the value &amp;quot;30&amp;quot; to this key, that means that if the player hasn't won the scenario by the end of thirty turns, he or she will lose.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now that we have assigned values to all our keys, the entire contents of the &amp;quot;my_first_scenario.cfg&amp;quot; file should now look like this:&lt;br /&gt;
 #textdomain wesnoth-my_first_campaign&lt;br /&gt;
 [scenario]&lt;br /&gt;
     id=my_first_scenario&lt;br /&gt;
     next_scenario=null&lt;br /&gt;
     name=_&amp;quot;My First Scenario.&amp;quot;&lt;br /&gt;
     map_data=&amp;quot;{~add-ons/my_first_campaign/maps/my_first_map.map}&amp;quot;&lt;br /&gt;
     turns=30&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
====Defining Sides====&lt;br /&gt;
&lt;br /&gt;
In any scenario, you will always need at least one side (the player's), and usually at least one other side as well. For this scenario, we need to define two sides: the player's side and the enemy's side.&lt;br /&gt;
&lt;br /&gt;
Let's start with the player's side. In order to define a side, we need to include the [side] tagset as a child of the [scenario] tagset.&lt;br /&gt;
&lt;br /&gt;
(...)&lt;br /&gt;
&lt;br /&gt;
==Chapter 5: Events==&lt;br /&gt;
&lt;br /&gt;
Let's walk through an average morning. When your alarm clock goes off, you wake up. You go downstairs and put some bread in the toaster for breakfast. When the toaster pops, you butter the toast and eat it. When you have eaten breakfast, you go outside and wait for the schoolbus to arrive. When the bus arrives, you get on it. When it stops at your destination, you get off of the bus.&lt;br /&gt;
&lt;br /&gt;
Notice that you do everything “when” something else happens. These are all “events”. The alarm going off caused you to wake up. The toaster popping causes you to butter the toast and eat it.  Finishing breakfast go outside. The bus stopping causes you to get on or off. These are all like events in WML. &lt;br /&gt;
&lt;br /&gt;
The syntax for writing an event goes like this:&lt;br /&gt;
 [event]&lt;br /&gt;
     name=name_of_the_event&lt;br /&gt;
     #do something&lt;br /&gt;
 [event]&lt;br /&gt;
&lt;br /&gt;
There are quite a few events available to you in WML. Of these, the most commonly used are the ''prestart'' event, the ''start'' event, and the ''moveto'' event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Objectives====&lt;br /&gt;
&lt;br /&gt;
==Chapter 6: Building and Including a Custom Unit==&lt;br /&gt;
&lt;br /&gt;
==Chapter 7: Introduction to Variables==&lt;br /&gt;
&lt;br /&gt;
Now it's time to learn about “variables”. Variables contain things. They're a lot like boxes that you'd use when moving to a new home. You put things in the boxes, and then you label them so that you can find the right things when unpacking later.&lt;br /&gt;
&lt;br /&gt;
Like attributes, every variable has a name and a value. The name of the variable is like the label on the box, and the variable's value is the thing that the variable (or box) contains.&lt;br /&gt;
&lt;br /&gt;
For instance, you might put all of your dishes in a box and label it “dishes”. Similarly you might create a variable named “my_name” and put your name inside of it. Then if you wanted to find your name later, you could look in the variable called “my_name”.&lt;br /&gt;
&lt;br /&gt;
===Creating Variables===&lt;br /&gt;
To create a variable, the following syntax is used:&lt;br /&gt;
 [set_variable]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     value=variable_value&lt;br /&gt;
 [/set_variable]&lt;br /&gt;
&lt;br /&gt;
This creates a variable and assigns a name and value to it.&lt;br /&gt;
&lt;br /&gt;
===Referencing Variables===&lt;br /&gt;
&lt;br /&gt;
If you have ever taken basic algebra, you should know what substitution is. If you haven't, don't worry, I'll explain it.&lt;br /&gt;
&lt;br /&gt;
Substitution basically allows you to substitute one thing for another thing, as long as both of those things are declared equal. For instance, let's say that x=7. Since they have been declared equal, if you were told to solve this problem:&lt;br /&gt;
 x-3=&lt;br /&gt;
what would you do? Well, since x is equal to seven, you can just replace x with 7, which gives you:&lt;br /&gt;
 7-3=&lt;br /&gt;
From there, it's easy to solve this problem.&lt;br /&gt;
&lt;br /&gt;
What you just did was called substitution. You substituted 7 for x in the problem.&lt;br /&gt;
&lt;br /&gt;
Returning the idea of the dishes stored in the box labeled &amp;quot;dishes&amp;quot;. If your mother pointed at the box containing the dishes and said &amp;quot;get out the contents of the box labeled dishes&amp;quot;, you understand that she wants you to get out the dishes from the box labeled &amp;quot;dishes&amp;quot;, so you'd get out the dishes and give them to her. Now suppose you had a WML variable named &amp;quot;dishes_box&amp;quot; and the value of that variable was &amp;quot;dishes&amp;quot;. If you tell the game that you want it to get the value of the variable named &amp;quot;dishes_box&amp;quot;, it would give you the value &amp;quot;dishes&amp;quot;. So what exactly do we need to do in order to tell the game to get the value of the &amp;quot;dishes_box&amp;quot; variable? This is where substitution comes in.&lt;br /&gt;
&lt;br /&gt;
Suppose you wanted to have the narrator give a message telling the player the value of the variable &amp;quot;dishes_box&amp;quot;. Here's how you would tell the game to do that in WML:&lt;br /&gt;
&lt;br /&gt;
 [message]&lt;br /&gt;
     speaker=narrator&lt;br /&gt;
     message= _ &amp;quot;The value of the dishes_box variable is: $dishes_box&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
&lt;br /&gt;
By preceding the name of a variable with a dollar sign &amp;quot;$&amp;quot; you are telling the game that you want to substitute the value of that variable. So in-game the narrator would say, &amp;quot;The value of the dishes_box variable is: dishes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Suppose you decided change the value of the &amp;quot;dishes_box&amp;quot; variable to &amp;quot;empty&amp;quot;. Now the narrator will say in-game, &amp;quot;The value of the dishes_box variable is: empty&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Manipulating Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Clearing Variables===&lt;br /&gt;
Whenever you know for sure that you won't need a variable any more, it's considered good programming practice to delete that variable, or ''clear'' it. This effectively tells the game that the variable in question isn't needed any more, so the game deletes that variable. If you don't clear variables once you no longer need them, they can accumulate over time and slow down the performance of both the game and the player's computer.&lt;br /&gt;
&lt;br /&gt;
In order to clear a variable, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
 #whatever the syntax is goes here, NOT THE MACRO, we want the user to be able to clear variables without relying on the macro (maybe mention the macro as a side note anyway?)&lt;br /&gt;
&lt;br /&gt;
==Chapter 8: Array, and Container Variables==&lt;br /&gt;
&lt;br /&gt;
So far we have only discussed ''scalar variables'', i.e. variables that have only one value at any given time. Believe it or not, there are types of variables than can store more than one value simultaneously, or even other variables.&lt;br /&gt;
&lt;br /&gt;
===Array Variables===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Container Variables===&lt;br /&gt;
&lt;br /&gt;
Container variables are variables that contain other variables within themselves. Returning to the metaphor of boxes, let's say you had three small boxes, labeled &amp;quot;Apples&amp;quot;, &amp;quot;Oranges&amp;quot;, and &amp;quot;Pears&amp;quot;, respectively. Instead of having to carry around three smaller boxes, wouldn't it be much easier if we could just put them all in one large box labeled &amp;quot;fruit&amp;quot;? Well, with container variables, you can!&lt;br /&gt;
&lt;br /&gt;
Container variables are not restricted to containing scalar variables, however. They can also store array variables.&lt;br /&gt;
&lt;br /&gt;
==Chapter 9: Macros==&lt;br /&gt;
&lt;br /&gt;
Have you ever needed to perform a task where you did the exact same thing several times? For instance, maybe you work at a cafe and you have three customers who want the exact same item: a (...)&lt;br /&gt;
&lt;br /&gt;
There are also instances in programming where you need the computer to perform the exact same task multiple times. But each time you need the computer to perform that same task again, you would have to write the same code again. There would be a lot of repetitious code, and it would take forever to write. Wouldn't it be great if we could do that task multiple times without having to result to writing the code out multiple times? Well, with macros, you can.&lt;br /&gt;
&lt;br /&gt;
You can think of macros as a special kind of variable. Just like you can store a long sentence in a variable and substitute it in several messages later on so that you don't have to write out the sentence several times, you can store WML code in a macro and simply call the macro wherever you would have to write all the code contained in the macro. When the scenario is loaded, the preprocessor will automatically substitute the code contained in the macro wherever the macro is called, for the duration of that scenario.&lt;br /&gt;
&lt;br /&gt;
This can be a confusing topic, so let's illustrate with some actual WML examples. Here we have the noble leader and the hard-of-hearing stooge trying to formulate their battle plan at the start of the scenario:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
    name=start&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;What do you think our plan should be, Stooge?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;I said, what do you think our battle plan should be?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;WHAT DO YOU THINK OUR BATTLE PLAN SHOULD BE?!&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Leader&lt;br /&gt;
         message= _ &amp;quot;Grrr...&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
Notice how each time the leader says something, Stooge says the exact same thing: &amp;quot;WHAT?&amp;quot; Rather than having to write&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
three times, let's stick the code in a macro named &amp;quot;STOOGE_REPLY&amp;quot;. Create a new text document in the &amp;quot;macros&amp;quot; folder inside your campaign folder. Name it &amp;quot;my_macros.cfg&amp;quot;. Now open the file in a text editor (if you haven't already) and enter the following code:&lt;br /&gt;
&lt;br /&gt;
 #define STOOGE_REPLY&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
 #enddef&lt;br /&gt;
&lt;br /&gt;
Now save the file. Hooray, you have just created your first macro! Now go to the scenarios folder and open the &amp;quot;my_first_campaign&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===The Parts of a Macro===&lt;br /&gt;
&lt;br /&gt;
Macros consist of three elements: the macro preprocessor directives, the macro symbol, and the macro body.&lt;br /&gt;
&lt;br /&gt;
====The Macro Preprocessor Directives====&lt;br /&gt;
The macro preprocessor directives consist of the strings &amp;quot;#define&amp;quot; and &amp;quot;enddef&amp;quot;. They tell the game where the macro begins and ends. Just like the preprocessor directives in the &amp;quot;_main.cfg&amp;quot; file, the macro preprocessor directives must be entirely lowercase and be spelled correctly.&lt;br /&gt;
&lt;br /&gt;
====The Macro Symbol====&lt;br /&gt;
The macro's symbol is the string of uppercase characters following the opening preprocessor directive that identifies the macro. Think of it as the macro's id. Symbols can only include alphanumeric characters and underscores, and should be capitalized throughout. In the case of the example above, the macro symbol would be:&lt;br /&gt;
 STOOGE_REPLY&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====The Macro Body====&lt;br /&gt;
The macro body is the code that is contained in the macro. Everything between the preprocessor directives (with the exception of the macro symbol) is considered by the game to be the macro body. In this case, the macro body is:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
====Calling A Macro====&lt;br /&gt;
Now that we have created our macro and understand what it does and what its respective parts are, let's return to our scenario and scroll to the start event that contains the dialogue between the leader and the stooge. Replace each instance of this code:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
with the following line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
&lt;br /&gt;
Basically, this tells the game that whenever it comes across an instance of this line:&lt;br /&gt;
 {STOOGE_REPLY}&lt;br /&gt;
it should substitute the following code in place of that line:&lt;br /&gt;
     [message]&lt;br /&gt;
         speaker=Stooge&lt;br /&gt;
         message= _ &amp;quot;WHAT?&amp;quot;&lt;br /&gt;
     [/message]&lt;br /&gt;
&lt;br /&gt;
===Macro Arguments===&lt;br /&gt;
&lt;br /&gt;
==Chapter 10: Introduction to Logic==&lt;br /&gt;
&lt;br /&gt;
===If This, Then That===&lt;br /&gt;
&lt;br /&gt;
Suppose you went to the grocery store to get some food. You park you car in the parking lot and begin to walk towards the store, when suddenly you realize that you can't remember if you shut the car door or not after you got out. You turn around to see if the car door is open...&lt;br /&gt;
&lt;br /&gt;
...and then what?&lt;br /&gt;
&lt;br /&gt;
Well, if the car door is open, you know that you ''did'' forget to close it, so you go over and close it before you go into the grocery store. If the car door isn't open, there's no need for you to do anything, so you keep walking towards the store.&lt;br /&gt;
&lt;br /&gt;
This kind of logic (called ''conditional'' logic) evaluates a condition and determines a reaction based on the state of that condition. In the example above, the condition is whether or not the car door is open. If it is open, then you go over and close it. If it isn't open, then you continue walking towards the store.&lt;br /&gt;
&lt;br /&gt;
In WML you have a number of logical operations available to assess and react to conditions. The first one we will go over is the if/then operation. The syntax of this operations is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition)&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
===Else===&lt;br /&gt;
&lt;br /&gt;
With the if clause, if the condition is true then we do something. But what if the condition isn't true? Well, in the examples above the WML engine doesn't have anything to do if the condition isn't true, so it just keeps running and doesn't do anything. However, it is possible to make the game perform a task if the condition isn't true, which is done by using the tagset [else]. The syntax is:&lt;br /&gt;
&lt;br /&gt;
 [if]&lt;br /&gt;
     (condition]&lt;br /&gt;
     [then]&lt;br /&gt;
         (do something)&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         (do something else)&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
Returning to the example of the car door, suppose that, before you turn around to check to see whether the door is open or not, you decide to go over and close the door if it is open, and if it isn't then you'll do a backflip to celebrate your genius before continuing your journey across the parking lot to the grocery store. In pseudocode:&lt;br /&gt;
 [if]&lt;br /&gt;
     the car door is open&lt;br /&gt;
     [then]&lt;br /&gt;
         go over and shut it&lt;br /&gt;
     [/then]&lt;br /&gt;
     [else]&lt;br /&gt;
         do a backflip&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/if]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Chapter 11: More Logic: Cases and Loops==&lt;br /&gt;
&lt;br /&gt;
===Cases===&lt;br /&gt;
&lt;br /&gt;
Suppose you had a scenario in which the player must pick a flower by moving a unit to the coordinates 14,30 in order to win. But that's not all: the flower can only be picked after turn 10 and before turn 20 (so the flower can only be picked between turns 11 and 20). If the player tries to pick the flower before turn 11, the game tells him that the flower hasn't bloomed yet and that he or she needs to wait a while longer. If the player tries to pick the flower after turn 20, the game will display a message telling him or her that he or she waited too long, and now the flower is dead. How would you go about implementing this in WML?&lt;br /&gt;
&lt;br /&gt;
Well, you could write something like this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
     name=moveto&lt;br /&gt;
     first_time_only=no&lt;br /&gt;
     [filter]&lt;br /&gt;
         side=1&lt;br /&gt;
     [/filter]&lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             less_than_equal_to=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;The flower hasn't bloomed yet. Try coming back later.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if] &lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You waited too long: the flower is dead now.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
     [if]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_number&lt;br /&gt;
             greater_than=10&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [and]&lt;br /&gt;
         [variable]&lt;br /&gt;
             name=turn_count&lt;br /&gt;
             less_than_equal_to=20&lt;br /&gt;
         [/variable]&lt;br /&gt;
     [/and]&lt;br /&gt;
         [then]&lt;br /&gt;
             [message]&lt;br /&gt;
                 speaker=narrator&lt;br /&gt;
                 message= _ &amp;quot;You pick the flower.&amp;quot;&lt;br /&gt;
             [/message]&lt;br /&gt;
         [/then]&lt;br /&gt;
     [/if]&lt;br /&gt;
 &lt;br /&gt;
 [/event]&lt;br /&gt;
&lt;br /&gt;
but this is extremely lengthy and tedious to write and maintain. Wouldn't it be awesome if we had some simpler way to test multiple conditions without having to create an entire [if] codeblock for each condition?&lt;br /&gt;
&lt;br /&gt;
Well, actually, there is an easier way to test for multiple conditions without. Instead of using multiple [if] codeblocks, you could simply use the switch/case codeblock to evaluate the value of a variable and determine the action performed as a result of the evaluation. The syntax of the switch/case codeblock goes thusly:&lt;br /&gt;
&lt;br /&gt;
 [switch]&lt;br /&gt;
     name=variable_name&lt;br /&gt;
     [case]&lt;br /&gt;
         value=first_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=second_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [case]&lt;br /&gt;
         value=third_value&lt;br /&gt;
         #do something&lt;br /&gt;
     [/case]&lt;br /&gt;
     [else]&lt;br /&gt;
         #do something&lt;br /&gt;
     [/else]&lt;br /&gt;
 [/switch]&lt;br /&gt;
&lt;br /&gt;
===Loops===&lt;br /&gt;
&lt;br /&gt;
==Conclusion: Where to Go From Here==&lt;br /&gt;
&lt;br /&gt;
As long and involved as this tutorial was, it barely scratches the surface of WML. You can't call yourself a WML expert just yet, but the hardest part for you — finding a starting point — is now over. You now know how to create a simple campaign, and you know many of the features WML has to offer.&lt;br /&gt;
&lt;br /&gt;
One of the best ways to learn more WML (and one of the only ways before this tutorial ;) ) is to study the WML code of other add-ons. You can also research any tags you're not familiar with on the [http://wiki.wesnoth.org/ReferenceWML WML Reference], which is a complete reference to pretty much every element of WML.&lt;br /&gt;
&lt;br /&gt;
If you run into any problems that you can't solve by looking at other people's code or by studying the wiki, post a message in the [http://forums.wesnoth.org/viewforum.php?f=21 WML Workshop forum]. The resident WML gurus will be happy to help you out if you ask politely.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You've been given the tools and the materials. Now go out and build something amazing!&lt;/div&gt;</summary>
		<author><name>Artisticdude</name></author>
		
	</entry>
</feed>