Variable Tags--Seem to Work When They Feel Like It
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.
Variable Tags--Seem to Work When They Feel Like It
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.
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.
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]
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.
- 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
"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?
http://www.wesnoth.org/wiki/Conditional ... ition_Tags
Why, then, are you using it?
- 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
Why don't we make value= a synonym of equals=, and possibly save our novice WML coders a lot of torn-out hair?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?
Re: Variable Tags--Seem to Work When They Feel Like It
I'd rather see proper tutorials or such that'd teach the newbies how they should be writing and debugging WML.Simons Mith wrote:Why don't we make value= a synonym of equals=, and possibly save our novice WML coders a lot of torn-out hair?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?
Re: Variable Tags--Seem to Work When They Feel Like It
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.Simons Mith wrote:Why don't we make value= a synonym of equals=, and possibly save our novice WML coders a lot of torn-out hair?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?
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.
-
- Posts: 462
- Joined: June 8th, 2006, 3:25 am
Re: Variable Tags--Seem to Work When They Feel Like It
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?