<?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=Winter+Knight</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=Winter+Knight"/>
	<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/Special:Contributions/Winter_Knight"/>
	<updated>2026-04-26T13:28:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.16</generator>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingScenariosAdvanced&amp;diff=18918</id>
		<title>BuildingScenariosAdvanced</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingScenariosAdvanced&amp;diff=18918"/>
		<updated>2007-10-20T18:14:19Z</updated>

		<summary type="html">&lt;p&gt;Winter Knight: Somebody failed math class.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{BuildingScenariosNav}}&lt;br /&gt;
&lt;br /&gt;
= Building scenarios: Advanced =&lt;br /&gt;
&lt;br /&gt;
== '''TODO:''' ==&lt;br /&gt;
This contained a repetition of what was already inside [[BuildingScenariosIntermediate]]&lt;br /&gt;
This should contain: &lt;br /&gt;
* (more) information about making &amp;amp; using preprocessors ([[PreprocessorRef]])&lt;br /&gt;
* information on guidelines concerning the general layout of a scenario file&lt;br /&gt;
* advanced filtering&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
Ayone who feels like writing something, go ahead&lt;br /&gt;
&lt;br /&gt;
== Advanced Events ==&lt;br /&gt;
&lt;br /&gt;
===Internal Actions===&lt;br /&gt;
See [[InternalActionsWML]] for a complete list of all tags and values. In what folows, the basics of variable creation and manipulation is explained.&lt;br /&gt;
&lt;br /&gt;
====Variables====&lt;br /&gt;
(This can be skipped if you're familiar with the concept of variables)&lt;br /&gt;
&lt;br /&gt;
(See [[VariablesWML]] for more)&lt;br /&gt;
&lt;br /&gt;
What are variables? Variables are basicly names. And with those names, we associate a certain value. You can compare this with the words, because words are associated with (several) objects, people, feelings, ... So a variable is just a way of communication: you and the computer (the Wesnoth engine really) are communicating wit each other!&lt;br /&gt;
&lt;br /&gt;
The most important aspect of variables is that they can change with time. (If they don't we call them constants.) Because they change, we can use them to trigger events, or to detect something has happened. You did this already in [[BuildingScenariosIntermediate]], using the [event] tag. We only wanted to trigger the actions inside the [event] when Konrad moved onto tile 4,8. To o so we had to make use of the variables x,y and description.&lt;br /&gt;
&lt;br /&gt;
Most variables provided by the engine are associated with a certain tag and can thus only be used inside them.&lt;br /&gt;
&lt;br /&gt;
====Manipulating====&lt;br /&gt;
These three actions can be executed in one single tag: ''''[set_variable]''''&lt;br /&gt;
Say we wanted to store 'Hello World' in a variable named ''message_to_the_world''. This is how we would do this:&lt;br /&gt;
 [event]&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
   [set_variable]&lt;br /&gt;
     #The name of our variable:&lt;br /&gt;
     name=message_to_the_world&lt;br /&gt;
     #The value of message_to_the_world, notice the underscore!&lt;br /&gt;
     value= _ &amp;quot;Hello World!&amp;quot;&lt;br /&gt;
   [/set_variable]&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
 [/event]&lt;br /&gt;
Now, if we want to change the value to something else later on, e.g. 'Goodbye World', we can use the exact same code as above. &lt;br /&gt;
If we want to add something to our message we need to use this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
   [set_variable]&lt;br /&gt;
     name=message_to_the_world&lt;br /&gt;
     value= _ &amp;quot;$message_to_the_world Have a nice day!&amp;quot;&lt;br /&gt;
   [/set_variable]&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
 [/event]&lt;br /&gt;
We've been using text variables (called strings) for now. But we can also store numbers and do some basic math with them. The following example clarifies this:&lt;br /&gt;
&lt;br /&gt;
 [event]&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
   [set_variable]&lt;br /&gt;
     name=number_x&lt;br /&gt;
     value=10&lt;br /&gt;
   [/set_variable]&lt;br /&gt;
   [set_variable]&lt;br /&gt;
     name=number_x&lt;br /&gt;
     add=-9&lt;br /&gt;
   [/set_variable]&lt;br /&gt;
   [set_variable]&lt;br /&gt;
     name=number_x&lt;br /&gt;
     multiply=200&lt;br /&gt;
   [/set_variable]&lt;br /&gt;
   [set_variable]&lt;br /&gt;
     name=number_x&lt;br /&gt;
     multiply=0.5&lt;br /&gt;
   [/set_variable]&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
  .&lt;br /&gt;
 [/event]&lt;br /&gt;
In the above, we set a variable named ''number_x'' to the value of 10. We substract 9 (=1), multiply with 200 (=200) and divide by two (or multiply with 0.5) resulting in 100.&lt;br /&gt;
&lt;br /&gt;
====Using Variables====&lt;br /&gt;
Now that we know how to create and manipulate variables, we'll learn how to use them.&lt;br /&gt;
First of all, you need to know what variables you always have at your disposal! In an event tag, these variables are &lt;br /&gt;
* side_number- the number of the current player's side (may be empty during start or prestart events)&lt;br /&gt;
* turn_number- the number of the current turn (may be empty during start or prestart events)&lt;br /&gt;
* x1- this is the x-coordinate of the location where the most recent event was triggered&lt;br /&gt;
* y1- this is the y-coordinate of the location where the most recent event was triggered&lt;br /&gt;
* x2- this is the x-coordinate of the location that assisted in triggering the most recent event&lt;br /&gt;
* y2- this is the y-coordinate of the location that assisted in triggering the most recent event&lt;br /&gt;
*  unit- inside an event, this is the unit at $x1,$y1 {{DevFeature}}&lt;br /&gt;
* second_unit- inside an event, this is the unit at $x2,$y2 {{DevFeature}}&lt;br /&gt;
* this_unit- inside a standard unit filter, this is the unit currently being considered for a possible match {{DevFeature}}&lt;br /&gt;
&lt;br /&gt;
Some of these are only containers for other variables. The ''unit'' variable is an example. You can acces those 'sub'-variables by using dots:&lt;br /&gt;
 unit.hitpoints&lt;br /&gt;
 unit.side&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
We will use $unit in an example to show you how you can use all this:&lt;br /&gt;
 [scenario]&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
   [event]&lt;br /&gt;
     #A unit moves onto a tile:&lt;br /&gt;
     name=moveto&lt;br /&gt;
     [filter]&lt;br /&gt;
       x,y=25,26&lt;br /&gt;
     [/filter]&lt;br /&gt;
     &lt;br /&gt;
     &lt;br /&gt;
     [set_variable]&lt;br /&gt;
       name=unit.hitpoints&lt;br /&gt;
       add=-5&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
     [set_variable]&lt;br /&gt;
       name=unit.status.poisoned&lt;br /&gt;
       value=yes&lt;br /&gt;
     [/set_variable]&lt;br /&gt;
 &lt;br /&gt;
     #After we have changed the values, we need to apply them.&lt;br /&gt;
     #We do this by using the unstore_unit tag like this:&lt;br /&gt;
     [unstore_unit]&lt;br /&gt;
       variable=$unit&lt;br /&gt;
       find_vacant=no&lt;br /&gt;
     [/unstore_unit]&lt;br /&gt;
   [/event]&lt;br /&gt;
   #We're finished!&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 [/scenario]&lt;br /&gt;
&lt;br /&gt;
There's one tag you don't know yet, and thats the '''[unstore_unit]''' tag. To explain this tag I'll explain it's counterparts; '''[store_unit]'''. [store_unit] stores a unit, or several units, in a variables you choose. You can then manipulate those variables as described above. However, you will need to apply these changes, and this is done by using the [unstore_unit] tag. For more see [http://www.wesnoth.org/wiki/InternalActionsWML#.5Bevent.5D InternalActions].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ====Conditionals: [if] and [while]====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Direct Actions===&lt;br /&gt;
===Interface Actions===&lt;br /&gt;
//--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== [[GetText]] &amp;amp; Translations ==&lt;br /&gt;
[http://www.wesnoth.org/forum/viewtopic.php?t=11445 As Viliam pointed out] (reordered his words):&lt;br /&gt;
&lt;br /&gt;
 Translating programs has two steps. The first step is making [...] scenarios that are&lt;br /&gt;
 &amp;lt;b&amp;gt;possible&amp;lt;/b&amp;gt; to translate; &amp;lt;b&amp;gt;preferably easy&amp;lt;/b&amp;gt; to translate. [...] The second &lt;br /&gt;
 step is the translating of the texts... leave this to  translators.&lt;br /&gt;
&lt;br /&gt;
So, as a campaign/scenario developer you have to make sure your campaign will be easy to translate. You can achieve this very easily by preceding all text the user might see on the screen with an underscore. This indicates it is a translatable string. [[GetText]] will then be able to look up a translation, based on your localisation settings.&lt;br /&gt;
To make it ever more clear, here's an example:&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 [message]&lt;br /&gt;
   description=Konrad&lt;br /&gt;
   message= &amp;lt;b&amp;gt;_&amp;lt;/b&amp;gt; &amp;quot;I am mighty Konrad! I fought many dummies and now I will fight you!&amp;quot;&lt;br /&gt;
 [/message]&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
 .&lt;br /&gt;
&lt;br /&gt;
The message key contains the words that will be displayed when Konrad speaks. So this is a translatable string. So it is preceded with an underscore.&lt;br /&gt;
&lt;br /&gt;
Viliam also said:&lt;br /&gt;
&lt;br /&gt;
 The most important rule of all is: &amp;lt;b&amp;gt;Do not split sentences.&amp;lt;/b&amp;gt;&lt;br /&gt;
 In some languages placing a word in a sentence requires more than mere string concatenation.&lt;br /&gt;
 Some languages use [http://en.wikipedia.org/wiki/Declension declension].&lt;br /&gt;
&lt;br /&gt;
== Quick Tag Index ==&lt;br /&gt;
'''[[ScenarioWML]]''' the top level tags [scenario], [multiplayer], [test], and [tutorial]&lt;br /&gt;
:* [[EventWML]] how to describe an event&lt;br /&gt;
:** [[FilterWML]]&lt;br /&gt;
:** [[DirectActionsWML]], [[InterfaceActionsWML]], [[InternalActionsWML]]&lt;br /&gt;
:* [[SideWML]] how to describe a side&lt;br /&gt;
:** [[SingleUnitWML]]&lt;br /&gt;
:** [[BuildingScenariosShroudData]]&lt;br /&gt;
:* [[MapGeneratorWML]] the random map generator&lt;br /&gt;
:* [[TimeWML]] how to describe a day&lt;br /&gt;
:* [[IntroWML]] how to describe the intro screen &lt;br /&gt;
:* [[UtilWML]] a set of preprocessors you can use&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[ScenarioWML]], [[SyntaxWML]] &amp;amp; [[ReferenceWML]]&lt;br /&gt;
* [[BuildingScenarios]]&lt;/div&gt;</summary>
		<author><name>Winter Knight</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.wesnoth.org/index.php?title=BuildingScenarios&amp;diff=18917</id>
		<title>BuildingScenarios</title>
		<link rel="alternate" type="text/html" href="https://wiki.wesnoth.org/index.php?title=BuildingScenarios&amp;diff=18917"/>
		<updated>2007-10-20T17:16:49Z</updated>

		<summary type="html">&lt;p&gt;Winter Knight: Removed details inappropriate for an introduction. Also removed &amp;quot;This is easy&amp;quot; which makes it harder for some people to ask questions. Scenarios are for multiplayer too.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Wesnoth scenarios are the individual levels within the game. Or they can be advanced multiplayer maps, with extra characters and items and such. Each scenario contains two files. First is the map itself, this is described in [[BuildingMaps]]. The second is the config file. This configuration file is used to describe everything about the scenario. Both of the files are ascii and can be edited in any standard text editor (vi, notepad, etc.) If you decide to use a wordprocessor, please make sure you remember to ''Save As'' text.&lt;br /&gt;
&lt;br /&gt;
Scenarios are written in the [[ReferenceWML | Wesnoth Markup Language]].&lt;br /&gt;
&lt;br /&gt;
This document is split into several sections, starting with a basic tutorial and moving into more complex techniques.  From the information contained within this document you should have all the knowledge to create Wesnoth scenarios. If you see any mistakes or missing information, please feel free to fix the pages yourself, add a comment to the comment page, or email me jzaun at campus dot hpu dot edu.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;navtemplate&amp;quot;&amp;gt;&lt;br /&gt;
==== Index ====&lt;br /&gt;
[[BuildingScenarios]]&lt;br /&gt;
:* '''[[BuildingScenariosSimple]] - [[BuildingScenariosIntermediate]] - [[BuildingScenariosAdvanced]]'''&lt;br /&gt;
:* [[BuildingScenariosSimple - French Version]]&lt;br /&gt;
:* [[BuildingScenariosComments]] - Comments left for advice&lt;br /&gt;
:* [[BuildingScenariosSamples]] - Basic sample code&lt;br /&gt;
:* [[BuildingScenariosShroudData]] - A tutorial on shroud_data&lt;br /&gt;
:* [[BuildingScenariosBalancing]] - How to balance your scenario&lt;br /&gt;
:* [[BuildingScenariosFAQ]] - Frequently Asked Questions&lt;br /&gt;
&amp;lt;/div class=&amp;quot;navtemplate&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Quick Tag Index ==&lt;br /&gt;
'''[[ScenarioWML]]''' the top level tags [scenario], [multiplayer], [test], and [tutorial]&lt;br /&gt;
:* [[EventWML]] how to describe an event&lt;br /&gt;
:** [[FilterWML]]&lt;br /&gt;
:** [[DirectActionsWML]], [[InterfaceActionsWML]], [[InternalActionsWML]]&lt;br /&gt;
:* [[SideWML]] how to describe a side&lt;br /&gt;
:** [[SingleUnitWML]]&lt;br /&gt;
:** [[BuildingScenariosShroudData]]&lt;br /&gt;
:* [[MapGeneratorWML]] the random map generator&lt;br /&gt;
:* [[TimeWML]] how to describe a day&lt;br /&gt;
:* [[IntroWML]] how to describe the intro screen &lt;br /&gt;
:* [[UtilWML]] a set of preprocessors you can use&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[Create]]&lt;br /&gt;
* [[ReferenceWML]] - WML master reference&lt;br /&gt;
** [[AlphabeticalWML]] - a tag index&lt;br /&gt;
** [[BuildingScenariosIndex]] - in-depth key and tag index&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Create}}&lt;/div&gt;</summary>
		<author><name>Winter Knight</name></author>
		
	</entry>
</feed>