tekelili advanced WML questions
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
tekelili advanced WML questions
Hi, to not spam never more wml forum I decided put togegher all my silly questions here.
To no spam this thread I will avoid "thanks posts", but of course thanks a lot to anyone who answer
To inaugurate my noob questions here is the first:
I want to trigger an event on a turn related to a variable. I tried this:
[set_variable]
name=eruption
value=10
[/set_variable]
[event]
name=turn ($eruption+2)
[/event]
This is not working probably because is "invented stuff". How can I trigger an event on a variable turn?
To no spam this thread I will avoid "thanks posts", but of course thanks a lot to anyone who answer
To inaugurate my noob questions here is the first:
I want to trigger an event on a turn related to a variable. I tried this:
[set_variable]
name=eruption
value=10
[/set_variable]
[event]
name=turn ($eruption+2)
[/event]
This is not working probably because is "invented stuff". How can I trigger an event on a variable turn?
Last edited by tekelili on December 18th, 2013, 7:49 am, edited 1 time in total.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: tekelili WML noob questions
Code: Select all
[event]
name=new turn
first_time_only=no
[if]
[variable]
name=turn_number
numerical_equals="$($eruption + 2)"
[/variable]
[then]
Re: tekelili WML noob questions
I hope this is last one for some time:
I want display a message of 2 lines having different typo size each line. in other words, I want to display theese 2 [print] tags in just one [print] tag to avoid second one instant delete first one:
[print]
text=Volcano Active
size=40
duration=700
red,green,blue=255,0,0
[/print]
[print]
text="(Eruption on Turn "+$eruption+")"
size=20
duration=700
red,green,blue=255,0,0
[/print]
It is possible?
I want display a message of 2 lines having different typo size each line. in other words, I want to display theese 2 [print] tags in just one [print] tag to avoid second one instant delete first one:
[print]
text=Volcano Active
size=40
duration=700
red,green,blue=255,0,0
[/print]
[print]
text="(Eruption on Turn "+$eruption+")"
size=20
duration=700
red,green,blue=255,0,0
[/print]
It is possible?
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: tekelili WML noob questions
I don't know if span or multiple lines works with [print], but you could try:
Code: Select all
text="<span size='large'>Volcano etc</span>
Eruption etc"
-
- Posts: 1549
- Joined: June 18th, 2009, 1:45 am
Re: tekelili WML noob questions
Use pango markup.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: tekelili WML noob questions
tekelili wrote:I want to trigger an event on a turn related to a variable. I tried this:
[set_variable]
name=eruption
value=10
[/set_variable]
[event]
name=turn ($eruption+2)
[/event]
Code: Select all
[event]
name=turn 1
[set_variable]
name=eruption
value=10
[/set_variable]
[event]
delayed_variable_substitution=no
name="turn $($eruption+2)"
[/event]
[/event]
2. delayed...=no required
3. "" required around the event name
In case of 1.9 the best approach is probably to use [filter_condition] in zookeeper's approach, instead of [if][variable][then].
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: tekelili WML noob questions
I have a new issue. I want a side starts game with village_gold=5, and be able to change during game to village_gold=2 by an event.
But after try it, I couldnt. After consult WML guide I becomed to think tha sides can only be defined oce at begining of cfg and can not be changed anymore, because so is how wesnoth works. ¿I am right?
this is what I tried:
But after try it, I couldnt. After consult WML guide I becomed to think tha sides can only be defined oce at begining of cfg and can not be changed anymore, because so is how wesnoth works. ¿I am right?
this is what I tried:
Spoiler:
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: tekelili WML noob questions
I am trying to learn to use arrays, but looks like I am doing something wrong or I didnt understand wml guide at all
I want create an array named fruits, and storage "banana", "orange" and "melon" on 0,1 and 2 positions of fruits array.
Then I want use:
[label]
x=10
y=10
value=$fruits[2]
[/label]
Can anyone give me exact code to create that array and a label "melon" is showed on 10.10?
Thanks a lot for help.
I want create an array named fruits, and storage "banana", "orange" and "melon" on 0,1 and 2 positions of fruits array.
Then I want use:
[label]
x=10
y=10
value=$fruits[2]
[/label]
Can anyone give me exact code to create that array and a label "melon" is showed on 10.10?
Thanks a lot for help.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: tekelili WML noob questions
untested:
Code: Select all
[set_variables]
name=fruits
[value]
name=banana
[/value]
[value]
name=orange
[/value]
[value]
name=melon
[/value]
[/set_variables]
#...
[label]
x=10
y=10
text=$fruits[2].name
[/label]
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: tekelili WML noob questions
I am having what looks a silly problem, to go across an array I want use a while tag in wich I add +1 to a index, but it looks like I dont know how do that. BtW:
[set_variable]
name=ArrayIndex
value=2
[/set_variable]
[set_variable]
name=ArrayIndex
value=$ArrayIndex+1
[/set_variable]
It looks like I am not having 3 as value storaged inside ArrayIndex variable after execute these 2 tags. I have also tried different modifications of like value=$($ArrayIndex+1) but none looks work.
What code should I use to add +1 to a given variable value inside that variable?
[set_variable]
name=ArrayIndex
value=2
[/set_variable]
[set_variable]
name=ArrayIndex
value=$ArrayIndex+1
[/set_variable]
It looks like I am not having 3 as value storaged inside ArrayIndex variable after execute these 2 tags. I have also tried different modifications of like value=$($ArrayIndex+1) but none looks work.
What code should I use to add +1 to a given variable value inside that variable?
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II
Re: tekelili WML noob questions
Unfortunately, WML can't handle mathematical expressions. Everything which can't be parsed as a number will be cosnidered to be a string. Strings' numerical value is 0. I said stupid things again . I'm going to retire, become a monk, and never comment in WML threads again.[set_variable]
name=ArrayIndex
value=2
[/set_variable]
[set_variable]
name=ArrayIndex
value=$ArrayIndex+1
[/set_variable]
If you want to numerically increase a value, then you should do this:
Code: Select all
[set_variable]
name=MyNumericalValue
add=1
[/set_variable]
Last edited by lipk on August 12th, 2011, 10:06 am, edited 1 time in total.
-
- Inactive Developer
- Posts: 2461
- Joined: August 15th, 2008, 8:46 pm
- Location: Germany
Re: tekelili WML noob questions
Any reason for not using the core FOREACH macro then ?tekelili wrote:to go across an array
use:
value="$($ArrayIndex+1)"
(with the quotes!)
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
A Simple Campaign: campaign draft for wml starters • Plan Your Advancements: mp mod
The Earth's Gut: sp campaign • Settlers of Wesnoth: mp scenario • Wesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign
Re: tekelili WML noob questions
Restating and clarifying...
First point
The standard way of iterating through an array in WML would be like so (where 'i' is the chosen name of the index variable)...
Second point
As already mentioned by lipk, the standard way of incrementing a variable in WML is using [set_variable] add=
Third point
As mentioned by Anonymissimus, if you want to use FormulaAI notation to perform math inside a WML string value, please always remember to surround the string with quote marks! Otherwise the '+' sign will unfortunately be interpreted as a low level string concatenation.
Better to focus on the basics, though, before using FormulaAI notation inside WML strings, e.g. "$(...)"
By the way, the SyntaxWML page on the wiki answers most of these questions, but there's nothing wrong with asking here if it isn't clear enough.
First point
The standard way of iterating through an array in WML would be like so (where 'i' is the chosen name of the index variable)...
Code: Select all
{FOREACH fruits i}
[message]
speaker=narrator
message="Element $i in the fruits array is: $fruits[$i].name"
[/message]
{NEXT i}
As already mentioned by lipk, the standard way of incrementing a variable in WML is using [set_variable] add=
Third point
As mentioned by Anonymissimus, if you want to use FormulaAI notation to perform math inside a WML string value, please always remember to surround the string with quote marks! Otherwise the '+' sign will unfortunately be interpreted as a low level string concatenation.
Better to focus on the basics, though, before using FormulaAI notation inside WML strings, e.g. "$(...)"
By the way, the SyntaxWML page on the wiki answers most of these questions, but there's nothing wrong with asking here if it isn't clear enough.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: tekelili WML noob questions
I have problems to syncronize image and sound during events:
I want remove a wall to free some units and then move them, I am using this kind of code
My problem is during game first of all units moves before walls are removed, wich looks ugly. Any idea why?
Other similar problem, I want place several units on map and use a sound each time one of them are placed
But all units are placed in map during game and I only hear sound effect just 1 time
As always, thanks a lot for help
I want remove a wall to free some units and then move them, I am using this kind of code
Spoiler:
Other similar problem, I want place several units on map and use a sound each time one of them are placed
Spoiler:
As always, thanks a lot for help
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
World Conquest II