Error concerning variable comparison

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
Anagkai
Posts: 55
Joined: February 12th, 2012, 10:05 am

Error concerning variable comparison

Post by Anagkai » September 3rd, 2018, 8:29 pm

The following code is supposed to replace villages when moved upon by opponents and - when a certain number have been replaced - make you lose.
For some reason, though, the scenario is lost the very first time the event is triggered.

Code: Select all

	[event]
		name=prestart
		{VARIABLE villages_destroyed 0}
#ifdef EASY
        {VARIABLE maximum_villages_destroyed 14}
#endif
#ifdef NORMAL
        {VARIABLE maximum_villages_destroyed 12}
#endif
#ifdef HARD
        {VARIABLE maximum_villages_destroyed 10}
#endif
	[/event]
	
		[event]
		name=moveto
		first_time_only=no
		[filter]
			type=Red Mage
			terrain=*^V
		[/filter]
		[terrain]
			x,y=$x1,$y1
			terrain=Rb
		[/terrain]
		[if]
		    [variable]
                name=villages_destroyed
                numerical_equals=0
            [/variable]
			[then]
			[/then]
		[/if]
		{VARIABLE_OP (villages_destroyed) add (1)}
		[if]
		    [variable]
                name=villages_destroyed
                greater_than=maximum_villages_destroyed
            [/variable]
			[then]
				[endlevel]
					result=defeat
				[/endlevel]
			[/then]
		[/if]
	[/event]
I'm looking for an explanation to this problem. Any help is appreciated.
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)

User avatar
Pentarctagon
Forum Administrator
Posts: 3998
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Error concerning variable comparison

Post by Pentarctagon » September 3rd, 2018, 8:55 pm

greater_than=maximum_villages_destroyed should be greater_than=$maximum_villages_destroyed
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Error concerning variable comparison

Post by zookeeper » September 4th, 2018, 1:41 pm


Anagkai
Posts: 55
Joined: February 12th, 2012, 10:05 am

Re: Error concerning variable comparison

Post by Anagkai » September 4th, 2018, 3:40 pm

I changed both of these, the location filter doesn't seem to work, though. Probably did something wrong. Here's my code:

Code: Select all

	[event]
		name=moveto
		first_time_only=no
		[filter]
			type=Red Mage			
		[/filter]
		[filter_location]
			terrain=*^V
		[/filter_location]
		[terrain]
			x,y=$x1,$y1
			terrain=Rb
		[/terrain]
       [/event]
My campaigns: Princess Nilwyn (available) & Home of the Undead (available)

User avatar
beetlenaut
Developer
Posts: 2379
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Error concerning variable comparison

Post by beetlenaut » September 4th, 2018, 5:04 pm

[filter_location] is not part of [event]. It is part of the standard unit filter, so it goes inside the [filter] tag. It's a good idea to use the wiki to confirm that your tags are in the right place. That's what zookeeper was hinting at when he provided you with a link.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

Post Reply