Macros don´t work! Aaargh!

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.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Using this, in fully written?

Code: Select all

#define CHG_GOLD SIDE AMOUNT
 [store_gold]
 variable=gold_inc
  [filter]
  side={SIDE}
  [/filter]
 [/store_gold]

 {VARIABLE_OP gold_inc add{AMOUNT}}

 [modify_side]
 gold=$gold_inc
  [filter]
  side=1
  [/filter]
 [/modify_side]

 {CLEAR_VARIABLE gold_inc}
#enddef
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Otherwise correct, except that: [store_gold] and [modify_side] do not accept [filter]s, they take just the side key. And your [modify_side] should have side={AMOUNT}, not side=1. Also, add a space after "add" in the {VARIABLE_OP}. :wink:
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

zookeeper wrote:Otherwise correct, except that: [store_gold] and [modify_side] do not accept [filter]s, they take just the side key. And your [modify_side] should have side={AMOUNT}, not side=1. Also, add a space after "add" in the {VARIABLE_OP}. :wink:
[store_gold]: I just thought it´s the same as [store_unit].
side={AMOUNT}: Huh? :shock: I think you meant side={SIDE}
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

toms wrote:[store_gold]: I just thought it´s the same as [store_unit].
side={AMOUNT}: Huh? :shock: I think you meant side={SIDE}
Oops, my bad. Yes, it should be side={SIDE}.

And how could [store_gold] possibly work like [store_unit]? Units don't have gold, only sides do.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

zookeeper wrote:And how could [store_gold] possibly work like [store_unit]? Units don't have gold, only sides do.
No, youn didn´t understand. I meant for [store_unit], you need filters, and for [store_locations] too. But-alright then.
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

toms wrote:No, youn didn´t understand. I meant for [store_unit], you need filters, and for [store_locations] too. But-alright then.
For those, you need to filter something - locations or units. To store gold, you don't need to "filter" anything but side. But yeah, I suppose there could be a side filter in addition to unit and location filters (but then again, it would probably be mentioned in the FilterWML page).
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

Another macro is not working. It´s in the attached file and it´s the big thing in the beginning.

And thanks for your effort to help me. :)
First read, then think. Read again, think again. And then post!
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Code: Select all

[event]
name=side turn
first_time_only=no
[filter]
side=3
[/filter]
In side turn events, there isn't any unit involved, so you can't use a [filter]. That [filter] could be what's causing it not to trigger. As the event description in the wiki says, "when a player ends their turn, before any events of this type trigger, the value of the WML variable side_number is set to the number of the side of the player about to take their turn". So, you need to use an [if] instead:

Code: Select all

[event]
    name=side turn
    first_time_only=no

    [if]
        [variable]
            name=side_number
            equals=3
        [/variable]

        [then]
           # this gets executed when side 3 is starting it's turn
        [/then]
    [/if]
[/event]
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

No, i don´t have any turn=3 in the filter. :? (only a side number)

NO, FORGET IT. It´s already fixed.
First read, then think. Read again, think again. And then post!
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I want to shut this thread, but I have one last question: If I use a macro in a macro, do I have to use parantheses?
Example

Code: Select all

{MACRO ({MACRO})}
:?: I´m not sure, and I haven´t found it in the wiki.
First read, then think. Read again, think again. And then post!
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Corporate.
Memory.

Can't beat it.
http://www.wesnoth.org/forum/viewtopic.php?t=5838
Hope springs eternal.
Wesnoth acronym guide.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

scott wrote:Corporate.
Memory.

Can't beat it.
http://www.wesnoth.org/forum/viewtopic.php?t=5838
I feel sorry because of posting a question again, but I wanna mention that I wasn´t at the forum at this time.
First read, then think. Read again, think again. And then post!
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

It's ok. I wasn't rebuking you for it, just pointing out that sometimes being there trumps the search function, which is saying a lot.
Hope springs eternal.
Wesnoth acronym guide.
Post Reply