Difference between revisions of "BuildingScenariosAdvanced"

From The Battle for Wesnoth Wiki
('''TODO:''')
(Building scenarios: Advanced - added an example for events and filters)
Line 13: Line 13:
 
Ayone who feels like writing something, go ahead
 
Ayone who feels like writing something, go ahead
  
== GetText ==
+
== Filters & Events ==
As Viliam pointed out (reordered his words):
+
When you are making campaigns, you will have to be able to control the game flow. This means you will need to interfere with the game if certain events arise. Examples:
 +
* There's a radioactive stone inside a cave. Units entering this cave (it has circular shape) lose 5HP and are poisoned. The cave is at tile (25,26) and has a radius of 8 tiles. This is the code that would achieve this:
 +
 
 +
[scenario]
 +
.
 +
.
 +
.
 +
  [event]
 +
    #A unit has moved, maybe it move inside the cave? Let's find out!
 +
    name=moveto
 +
    #Here's our filter! {{DevFeature}} see below for earlier version
 +
    [filter]
 +
      x,y=25,26
 +
      radius=8
 +
    [/filter]
 +
   
 +
    #We can use the variable $unit inside an event tag to change the
 +
    #unit that triggered the action. See [http://www.wesnoth.org/wiki/InternalActionsWML#.5Bevent.5D event internal actions]. Inside a set_variable tag we can
 +
    #adjust the values of some of the unit characteristisc, like it's hitpoints and it's status
 +
    [set_variable]
 +
      name=unit.hitpoints
 +
      add=-5
 +
    [/set_variable]
 +
    [set_variable]
 +
      name=unit.status.poisoned
 +
      value=yes
 +
    [/set_variable]
 +
 
 +
    #After we have changed the values, we need to apply them.
 +
    #We do this by using the unstore_unit tag like this:
 +
    [unstore_unit]
 +
      variable=$unit
 +
      find_vacant=no
 +
    [/unstore_unit]
 +
  [/event]
 +
  #We're finished!
 +
.
 +
.
 +
.
 +
[/scenario]
 +
 
 +
== [[GetText]] & Translations ==
 +
[http://www.wesnoth.org/forum/viewtopic.php?t=11445 As Viliam pointed out] (reordered his words):
  
 
  Translating programs has two steps. The first step is making [...] scenarios that are <b>possible</b> to translate;  
 
  Translating programs has two steps. The first step is making [...] scenarios that are <b>possible</b> to translate;  
Line 33: Line 75:
  
 
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.
 
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.
 +
 +
Viliam also said:
 +
 +
The most important rule of all is: <b>Do not split sentences.</b>
 +
In some languages placing a word in a sentence requires more than mere string concatenation.
 +
Some languages use [http://en.wikipedia.org/wiki/Declension declension].
  
 
== Quick Tag Index ==
 
== Quick Tag Index ==

Revision as of 15:51, 28 June 2007

Building scenarios: Advanced

TODO:

This contained a repetition of what was already inside BuildingScenariosIntermediate This should contain:

  • (more) information about making & using preprocessors (PreprocessorRef)
  • information on guidelines concerning the general layout of a scenario file
  • advanced filtering
  • ...

Ayone who feels like writing something, go ahead

Filters & Events

When you are making campaigns, you will have to be able to control the game flow. This means you will need to interfere with the game if certain events arise. Examples:

  • There's a radioactive stone inside a cave. Units entering this cave (it has circular shape) lose 5HP and are poisoned. The cave is at tile (25,26) and has a radius of 8 tiles. This is the code that would achieve this:
[scenario]
.
.
.
  [event]
    #A unit has moved, maybe it move inside the cave? Let's find out!
    name=moveto
    #Here's our filter! Template:DevFeature see below for earlier version
    [filter]
      x,y=25,26
      radius=8
    [/filter]
    
    #We can use the variable $unit inside an event tag to change the
    #unit that triggered the action. See event internal actions. Inside a set_variable tag we can
    #adjust the values of some of the unit characteristisc, like it's hitpoints and it's status
    [set_variable]
      name=unit.hitpoints
      add=-5
    [/set_variable]
    [set_variable]
      name=unit.status.poisoned
      value=yes
    [/set_variable]
    #After we have changed the values, we need to apply them.
    #We do this by using the unstore_unit tag like this:
    [unstore_unit]
      variable=$unit
      find_vacant=no
    [/unstore_unit]
  [/event]
  #We're finished!
.
.
.
[/scenario]

GetText & Translations

As Viliam pointed out (reordered his words):

Translating programs has two steps. The first step is making [...] scenarios that are possible to translate; 
preferably easy to translate. [...] The second step is the translating of the texts... leave this to  translators.

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. To make it ever more clear, here's an example:

.
.
.
[message]
  description=Konrad
  message= _ "I am mighty Konrad! I fought many dummies and now I will fight you!"
[/message]
.
.
.

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.

Viliam also said:

The most important rule of all is: Do not split sentences.
In some languages placing a word in a sentence requires more than mere string concatenation.
Some languages use declension.

Quick Tag Index

ScenarioWML the top level tags [scenario], [multiplayer], [test], and [tutorial]

See Also