Working useful macros!

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
Flyro
Posts: 27
Joined: March 12th, 2011, 9:58 pm

Working useful macros!

Post by Flyro »

EDIT------------
From now on i will use this thread for all my coding questions. :eng:
I will post the working codes below for others to enjoy! :)

HOW TO:
Teleport from terrain X1 to X2 (both ways)
Spoiler:
Make peasant dig through caves (at the cost of moves)
http://forums.wesnoth.org/viewtopic.php?f=21&t=33287
Spoiler:
Make one enemy for each chosen terrain (good in scenarios)
Spoiler:
My Transport Galleon macro (fully functional)!
Spoiler:
Last edited by Flyro on April 15th, 2011, 6:06 am, edited 14 times in total.
monochromatic
Posts: 1549
Joined: June 18th, 2009, 1:45 am

Re: Why dont this work?

Post by monochromatic »

because terrain= is a key available only under the Standard Location Filter. x,y= works in both.
Here's links to both indexes of filters: StandardUnitFilter StandardLocationFilter
User avatar
Kapoue_II
Posts: 203
Joined: October 11th, 2010, 9:41 am

Re: Why dont this work?

Post by Kapoue_II »

Try this instead

Code: Select all

#define TELE_TERRAIN_ON
	[event]
		name=moveto
		first_time_only=no
		[if]
		[have_location]
                 terrain=Rrc
                 [filter]
                  side=$side_number
                 [/filter]
               [/have_location]
                 
		[then]

		[store_locations]
			variable=telea
			[filter]
				[filter_location]
					terrain=Rrc
				[/filter_location]
				[not]
					x,y=$x1,$y1
				[/not]
			[/filter]
		[/store_locations]

		[teleport]
			[filter]
				x,y=$x1,$y1
			[/filter]
			x=$telea.x
			y=$telea.y
		[/teleport]
		[redraw]
		[/redraw]
		[/then]
	[/if]
	[/event]
#enddef
User avatar
Flyro
Posts: 27
Joined: March 12th, 2011, 9:58 pm

Re: Why dont this work?

Post by Flyro »

Kapoue_II wrote:Try this instead

Code: Select all

#define TELE_TERRAIN_ON
	[event]
		name=moveto
		first_time_only=no
		[if]
		[have_location]
                 terrain=Rrc
                 [filter]
                  side=$side_number
                 [/filter]
               [/have_location]
                 
		[then]

		[store_locations]
			variable=telea
			[filter]
				[filter_location]
					terrain=Rrc
				[/filter_location]
				[not]
					x,y=$x1,$y1
				[/not]
			[/filter]
		[/store_locations]

		[teleport]
			[filter]
				x,y=$x1,$y1
			[/filter]
			x=$telea.x
			y=$telea.y
		[/teleport]
		[redraw]
		[/redraw]
		[/then]
	[/if]
	[/event]
#enddef
Nope that doesn't work neither :(

Edit--------
Ive done some further investigating.
I'ts now confirmed that its the "store location" thats my only problem,
I tried to set the teleport coordinates to 3,3 instead of $telea.x/y
and that unit in fact got teleported to 3,3
That proves that the filtering in the beginning of the macro is correct.

Code: Select all

#define TELE_TERRAIN_ON
   [event]
      name=moveto
      first_time_only=no
      [if]
      [have_unit]
         side=$side_number
         [filter_location]
            terrain=Rrc
         [/filter_location]
      [/have_unit]
      [then]


# This part is what doesnt work -.-
      [store_locations]
         variable=telea
            [filter_location]
               terrain=Rrc
               [not]
                  x,y=$x1,$y1
               [/not]
            [/filter_location]
      [/store_locations]
# To here

      [teleport]
         [filter]
            x,y=$x1,$y1
         [/filter]
         x=$telea.x
         y=$telea.y
      [/teleport]
      [redraw]
      [/redraw]
      [/then]
   [/if]
   [/event]
#enddef

Edit-------
I found one more problem
"[filter]: a StandardUnitFilter. The locations reachable by any of the matching units will be stored."
The location i want to store is out of reach for the unit, that may be why filter doesn't work ??
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Why dont this work?

Post by zookeeper »

Your problem is that [filter_location] is not part of StandardLocationFilter and thus has no meaning inside [store_locations].
User avatar
Flyro
Posts: 27
Joined: March 12th, 2011, 9:58 pm

Re: Why dont this work?

Post by Flyro »

zookeeper wrote:Your problem is that [filter_location] is not part of StandardLocationFilter and thus has no meaning inside [store_locations].
¨
You're probably right, but unless you wright it as a code I wont understand what you mean
Besides its already solved.
TY for trying to help though, its not your fault i didn't understand :P
Spoiler:
User avatar
Flyro
Posts: 27
Joined: March 12th, 2011, 9:58 pm

Re: Working useful macros!

Post by Flyro »

You want the Transport galleon to carry units?
Just add these macros to the prestart event.
Spoiler:
Post Reply