Difference between revisions of "WML for Complete Beginners"

From The Battle for Wesnoth Wiki
(Add includeonly index link)
 
(90 intermediate revisions by 11 users not shown)
Line 1: Line 1:
'''Template for future "WML for Complete Beginners" tutorial'''
+
{{Translations}}
  
'''Note: this is a work in progress.'''
+
Welcome to the WML Guide for Complete Beginners!  From here, you can get started directly by heading to the [[WML for Complete Beginners: Introduction|Introduction]] or you can continue from the chapter you left off.
-------------
 
  
 +
==Main Index==
  
 +
<onlyinclude>
 +
{| class="wikitable"
 +
<includeonly>|-
 +
|[[WML for Complete Beginners|Index]]</includeonly>
 +
|-
 +
|[[WML_for_Complete_Beginners:_Introduction|Introduction]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_1|1 - Syntax]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_2|2 - The Userdata Directory and the Campaign Folder]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_3|3 - The _main.cfg]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_4|4 - Creating Your First Scenario]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_5|5 - Events]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_6|6 - Custom Units]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_7|7 - Variables Introduction]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_8|8 - Non-scalar Variables]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_9|9 - Macros]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_10|10 - Logic]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Chapter_11|11 - More Logic]]
 +
|-
 +
|[[WML_for_Complete_Beginners:_Conclusion|Conclusion]]
 +
|}
 +
</onlyinclude>
  
 +
==Note for Improvements:==
  
==Introduction==
+
1. 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).
  
Hey there!
+
2. Finish chapters 6-11 (Partially Complete)
  
...blahblahblah random intro rhetoric, explain what WML stands for, what it's used for, etc. Then:
+
[[Category:WML_for_Complete_Beginners]]
 
 
==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 [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.
 
 
 
====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
 
 
 
 
 
==Chapter 2: ==
 
 
 
==Chapter 3: ==
 
 
 
==Chapter 4: ==
 
 
 
==Chapter 5: Variables==
 
 
 
==Chapter 6: ==
 

Latest revision as of 18:56, 29 January 2023


Welcome to the WML Guide for Complete Beginners! From here, you can get started directly by heading to the Introduction or you can continue from the chapter you left off.

Main Index

Introduction
1 - Syntax
2 - The Userdata Directory and the Campaign Folder
3 - The _main.cfg
4 - Creating Your First Scenario
5 - Events
6 - Custom Units
7 - Variables Introduction
8 - Non-scalar Variables
9 - Macros
10 - Logic
11 - More Logic
Conclusion


Note for Improvements:

1. 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).

2. Finish chapters 6-11 (Partially Complete)

This page was last edited on 29 January 2023, at 18:56.