variable in turn#
Moderator: Forum Moderators
variable in turn#
On this page http://wesnoth.slack.it/?VariablesWML it says:
For example the attribute turns=$turns is a way to set the number of turns in a scenario to a particular variable.
I'm working on a multiplayer scenario with a friend of mine and neither one of us can figure out why the following does not set the number of turns to the variable:
[event]
name=prestart
[set_variable]
name=turns
value=13
[/set_variable]
[/event]
turns=$turns
[event]
name=start
[print]
text=$turns
duration=100
red=255
[/print]
[/event]
I've added [print] in the start event to check if the variable indeed had a value, which it does. So why turns=0 instead of turns=13 in the game?!
A different name for the variable doesn't help.
Thanks for any solutions
For example the attribute turns=$turns is a way to set the number of turns in a scenario to a particular variable.
I'm working on a multiplayer scenario with a friend of mine and neither one of us can figure out why the following does not set the number of turns to the variable:
[event]
name=prestart
[set_variable]
name=turns
value=13
[/set_variable]
[/event]
turns=$turns
[event]
name=start
[print]
text=$turns
duration=100
red=255
[/print]
[/event]
I've added [print] in the start event to check if the variable indeed had a value, which it does. So why turns=0 instead of turns=13 in the game?!
A different name for the variable doesn't help.
Thanks for any solutions
Re: variable in turn#
Turn value is determined based on the value of 'turns' (or whatever you put) when the scenario starts. Changes to 'turns' will only affect the number of turns if it is in a previous scenario's event; i.e. a carry-over variable. The number of turns cannot be changed during a scenario.Darwin wrote:So why turns=0 instead of turns=13 in the game?!
I added this information to the wiki page... possibly a better example should be used too
Thanks, Dacyn, it's not the answer I was hoping for, but it'll have to do..Dacyn wrote:The number of turns cannot be changed during a scenario.
[event]
name=turn $turns
This won't work for the same reason, then, right?
So are all variables carried over from one scenario to another, if they are not cleared? Are they carried over multiple scenarios until cleared?Dacyn wrote:Changes to 'turns' will only affect the number of turns if it is in a previous scenario's event; i.e. a carry-over variable.
That would be good news. Good enough to compensate for the above-mentioned disappointment, perhaps
Yes, variables set with [set_variable] do carry over.
If you want a variable number of turns, you could set the scenario to unlimited turns then have different victory defeat or victory events based on the variable's value. I think the code you posted should work as long as you have a value in the variable you're using.
If you want a variable number of turns, you could set the scenario to unlimited turns then have different victory defeat or victory events based on the variable's value. I think the code you posted should work as long as you have a value in the variable you're using.
Hope springs eternal.
Wesnoth acronym guide.
Wesnoth acronym guide.
There is also a way to have a certain turn limit AFTER you do something. So, you have the objective be "move here", then, after you do that, the objective changes to "survive for 5 turns" or something like that.
Code: Select all
[event]
name=moveto
[filter]
x,y=16,25
description=Thursagan
[/filter]
[set_variable]
name=turnsleft
value=5
[/set_variable]
[objectives]
side=1
[objective]
description= _ "Survive for 5 turns"
condition=win
[/objective]
[objective]
description= _ "Death of Rugnur"
condition=lose
[/objective]
[objective]
description= _ "Death of Baglur"
condition=lose
[/objective]
[objective]
description= _ "Death of Krawg"
condition=lose
[/objective]
[objective]
description= _ "An enemy moves onto the forge"
condition=lose
[/objective]
[objective]
description= _ "Time runs out"
condition=lose
[/objective]
[/objectives]
[event]
name=new turn
first_time_only=no
[set_variable]
name=turnsleft
add=-1
[/set_variable]
[if]
[variable]
name=turnsleft
numerical_equals=0
[/variable]
[then]
[endlevel]
result=victory
bonus=no
[/endlevel]
[/then]
[/if]
[/event]
[/event]
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm
-
- Posts: 873
- Joined: July 4th, 2004, 9:14 pm
- Location: My imagination
- Contact:
I believe that reason would make it not work, although I am not sure. In any case most tags, such as that "name", do not interpolate variables but rather check only for a $ as the first character. However events can generate events, and other things can be used for formatting, so it is still doable:Darwin wrote:[event]
name=turn $turns
This won't work for the same reason, then, right?
Code: Select all
[event]
name=prestart
#...
{VARIABLE_OP turn_event_value format (turn $turns)}
[event]
name=$turn_event_value
#...
[/event]
[/event]
Play a Silver Mage in the Wesvoid campaign.