Variable Tags--Seem to Work When They Feel Like It

The place to post your WML questions and answers.

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.
Post Reply
User avatar
TofuOgre
Posts: 24
Joined: April 25th, 2009, 12:25 am

Variable Tags--Seem to Work When They Feel Like It

Post by TofuOgre »

It's driving me nuts. I've looked at other campaigns, and their variable tags have the same format as mine.

Let's say that in the first scenario we set all variables to "0", so if an event does not happen, it will be carrying a variable. Then we have this simple if-then-else.

Code: Select all

        [if]
            [variable]
                name=batwand
                value="1"
            [/variable]
            [then]
                [message]
                    speaker="Squeeky"
                    message= _ "Is that the bat signal again? Good thing I have this Bat Wand. Otherwise, I would have to chew on such villians as Red Pepperman and the Urchin Woman and their villainous child: Spiky Hot Sea Pepper Boy."
                    image="squeeky.png"
                [/message]
            [/then]
            [else]
                [message]
                    speaker="Squeeky"
                    message= _ "You are lucky. Too bad we could not find a Bat Wand. Now, I have to chew on such villians as Red Pepperman and the Urchin Woman, and their villainous child: Spiky Hot Sea Pepper Boy."
                    image="squeeky.png"
                [/message]
            [/else]
        [/if]
If we look at the save file, it says, batwand="0" in two places, which should result in the [else] message being played. It does not.

Okay, so let's make them two separate if-then's, what happens? Both messages are played. I've erased all saves but one, made sure there is no batwand="1", sometimes remove the quotes, swap 'value' with 'equals', restart the program, and the same results. And this happens elsewhere, where I can see the stored variables in the save file, but it does not trigger the right sequence.
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Re: Variable Tags--Seem to Work When They Feel Like It

Post by Ken_Oh »

"value" isn't listed as a valid key to put inside [variable].

http://www.wesnoth.org/wiki/Conditional ... ition_Tags

Why, then, are you using it?
User avatar
Simons Mith
Posts: 821
Joined: January 27th, 2005, 10:46 pm
Location: Twickenham
Contact:

Re: Variable Tags--Seem to Work When They Feel Like It

Post by Simons Mith »

Ken_Oh wrote:"value" isn't listed as a valid key to put inside [variable].

http://www.wesnoth.org/wiki/Conditional ... ition_Tags

Why, then, are you using it?
Why don't we make value= a synonym of equals=, and possibly save our novice WML coders a lot of torn-out hair?
 
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Variable Tags--Seem to Work When They Feel Like It

Post by zookeeper »

Simons Mith wrote:
Ken_Oh wrote:"value" isn't listed as a valid key to put inside [variable].

http://www.wesnoth.org/wiki/Conditional ... ition_Tags

Why, then, are you using it?
Why don't we make value= a synonym of equals=, and possibly save our novice WML coders a lot of torn-out hair?
I'd rather see proper tutorials or such that'd teach the newbies how they should be writing and debugging WML.
User avatar
TofuOgre
Posts: 24
Joined: April 25th, 2009, 12:25 am

Re: Variable Tags--Seem to Work When They Feel Like It

Post by TofuOgre »

Simons Mith wrote:
Ken_Oh wrote:"value" isn't listed as a valid key to put inside [variable].

http://www.wesnoth.org/wiki/Conditional ... ition_Tags

Why, then, are you using it?
Why don't we make value= a synonym of equals=, and possibly save our novice WML coders a lot of torn-out hair?
I probably used 'value' because 'equals' was not working, and one does set_variable with 'value', so it makes more sense to use 'value' instead of 'equals' when looking up the variable.

However, when using 'equals', I run into problems where it does not execute (e.g. turn 2, if-then), but restarting the scenario without changing the script, it does execute.
Exasperation
Posts: 462
Joined: June 8th, 2006, 3:25 am

Re: Variable Tags--Seem to Work When They Feel Like It

Post by Exasperation »

When you save a game, it also saves the events. This is because triggering events can change which events are active, so it needs to keep track of which events will be active when the game is loaded. This means that if you save a game, modify the WML for the event, then load the saved game you get the old version of the event - could this be what has been giving you trouble?
Post Reply