Difference between revisions of "WML for Complete Beginners"
Artisticdude (talk | contribs) (Created page with ''''Template for future "WML for Complete Beginners" tutorial''' '''Note: this is a work in progress.''' ------------- ==Introduction== Hey there! ...blahblahblah random in…') |
Artisticdude (talk | contribs) |
||
Line 57: | Line 57: | ||
==Chapter 2: == | ==Chapter 2: == | ||
+ | |||
+ | ==Chapter 3: == | ||
+ | |||
+ | ==Chapter 4: == | ||
+ | |||
+ | ==Chapter 5: Variables== | ||
+ | |||
+ | ==Chapter 6: == |
Revision as of 16:53, 8 February 2012
Template for future "WML for Complete Beginners" tutorial
Note: this is a work in progress.
Contents
Introduction
Hey there!
...blahblahblah random intro rhetoric, explain what WML stands for, what it's used for, etc. Then:
Chapter 1: Syntax
First things first; let's go over the syntax of WML.
For those of you who might not know what the "syntax" 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: "I like to eat jelly and cheese sandwiches." 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, "Like cheese I and sandwiches jelly", that would make no sense, and no one would understand what you were saying. Likewise, if you said "I like cheese sandwiches and jelly", that would change the entire meaning of the sentence!
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: "won day mary and i had went to seen the elefant at the zoo it's trunc was reely long", chances are people would not understand much of what you wrote. On the other hand, if you used the correct syntax and wrote: "One day Mary and I went to see the elephant at the zoo. Its trunk was really long!", 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.
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.
Basic Components: Tags and Attributes
WML, as one can infer from the meaning of the acronym, is a markup language. This means that the syntax of the entire language consists of two fundamental elements: tags and attributes.
Tags
A tag is a string of lowercase text encapsulated by two square brackets, one at either end. This is an example of a campaign tag:
[campaign]
Notice that I said "a tag is a string of lowercase text". 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 you've written and will give you an error when it tries to read the incorrect tag.
As with most markup languages, in WML tags are always used in pairs: one opening tag and one closing tag. Think of the opening and closing tags 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 a closing tag, it realizes it's at the beginning of a task. When it reaches the closing tag, it realizes it has finished the task.
Closing tags are exactly the same as opening tags except for one key component: closing tags always have a forward slash "/" immediately after the first square bracket. This forward slash tells the WML engine that this is a closing tag and not another opening tag. Here is an example of the closing campaign tag:
[/campaign]
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. So the campaign tagset would look like this:
[campaign] [/campaign]
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. Before we move on to the next section, let's review the points we've learned in this section about tags:
- A tag is a string of lowercase text encapsulated by two square brackets, one at either end.
- A closing tag is exactly the same as an opening tag except for the forward slash immediately following the first square bracket.
- The opening tag and the closing tag together are called the tagset. A tagset consists of only two tags: the opening tag and the closing tag.
So now we know how to tell the WML engine where the beginning and the end of a task are, but what about actually giving it the task? This is where attributes come in.
Attributes
More About Tags
-Discuss nested tags, whitespaces and underscores in tags