Converting some old Macros for v1.6

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
Devrailis Colandore
Posts: 76
Joined: April 22nd, 2007, 3:16 am
Location: Canada

Converting some old Macros for v1.6

Post by Devrailis Colandore »

Hi everyone. I was working on a campaign back when Wesnoth was on version 1.3.x. I've been trying to complete it recently but I've been running into some problems with the new 1.6 version not being able to recognize some of the macros that I used in the campaign.

The two macros that I am having the most trouble with are the GUARDIAN suffix-tag and the {RECALL_ALL} macro.

I'm not certain how to use the GUARDIAN tag, as I used to write my own macros when I wanted to place a unit with the GUARDIAN trait, however, I am trying to reduce my use of custom macros as much as possible. From what I read in the WML library, I think I ought to be using the GUARDIAN tag like so:
{NAMED_LOYAL_UNIT_GUARDIAN 2 (Spearman) 16 25 (Leeroy Jenkins) ( _ "Leeroy Jenkins")}
Unfortunately, this doesn't work and the unit simply does not appear. I've also tried:
{NAMED_LOYAL_GUARDIAN_UNIT 2 (Spearman) 16 25 (Leeroy Jenkins) ( _ "Leeroy Jenkins")}
However, when I do that, the unit does not appear either, so I assume that this is not the correct way to use the GUARDIAN suffix. I haven't been able to find any previous threads that address this usage. Could someone tell me what I'm doing wrong here?

The second problem I'm running into is the {RECALL_ALL} macro. The macro code looks like this:
#define RECALL_ALL

{VARIABLE call 0}
{VARIABLE list 20}

[while]
[variable]
name=call
less_than=$list
[/variable]

[do]
[recall]
side=1
[/recall]

[variable]
name=call
add=1
[/variable]
[/do]
[/while]

{CLEAR_VARIABLE call}
{CLEAR_VARIABLE list}

#enddef
It worked fine for v1.3.x and v1.4.x, however the game simply does not recognize the macro anymore, at least, this is what I'm assuming, as my units do not get recalled at the beginning of the scenario. They can be recalled fine if I recall them seperately, which works fine for named units but terribly for generic ones.

Did something change between v1.3.x to v1.6 that I missed?

Any help would be greatly appreciated. Thanks in advance.
User avatar
Turuk
Sithslayer
Posts: 5283
Joined: February 28th, 2007, 8:58 pm
Contact:

Re: Converting some old Macros for v1.6

Post by Turuk »

Are you sure that the RECALL ALL macro still exists?

A quick look at the reference page will let you know the macros in the game.
Mainline Maintainer: AOI, DM, NR, TB and THoT.
UMC Maintainer: Forward They Cried, A Few Logs, A Few More Logs, Start of the War, and Battle Against Time
Devrailis Colandore
Posts: 76
Joined: April 22nd, 2007, 3:16 am
Location: Canada

Re: Converting some old Macros for v1.6

Post by Devrailis Colandore »

Turuk wrote:Are you sure that the RECALL ALL macro still exists?

A quick look at the reference page will let you know the macros in the game.
Hi Turuk, thanks for the reply. The RECALL ALL macro no longer exists as an official macro. I still have a copy of the old macro file in my campaign folder. Thanks for reminding me of that however, as I think the problem might also be that the campaign is no longer reading my list of custom macros.

This is the code that I used to access the macros that I had built from scratch.

Code: Select all

	# Let the campaign load from the utils folder
	{@campaigns/Autumn_Kingdoms_Prologue/utils}
	{@campaigns/Autumn_Kingdoms_Prologue/utils/macros.cfg}
I don't know if anything has changed from the version upgrade that might invalidate this method of recalling macros. Could this be where the problem is?
User avatar
Mist
Inactive Developer
Posts: 753
Joined: February 15th, 2007, 8:44 am
Location: Milton Keynes, UK

Re: Converting some old Macros for v1.6

Post by Mist »

Right after quick look into unit-utils.cfg :

1) GUARDIAN usage

<Unit macro>
<guardian>

So in your case :

{NAMED_LOYAL_UNIT 2 (Spearman) 16 25 (Leeroy Jenkins) ( _ "Leeroy Jenkins")}
{GUARDIAN}

The definition of {GUARDIAN} is

Code: Select all

#define GUARDIAN
    # Meant to be used as a suffix to a unit-generating macro call.
    [+unit]
        ai_special=guardian
        animate=no
    [/unit]
#enddef
Which makes the comment on macro reference page slightly unfortunate

2) I can see no WML problems with your recall macro, can you post simple stderr.txt output (without --log-debug=all)?
Somewhere, between the sacred silence and sleep.
Disorder.
User avatar
Turuk
Sithslayer
Posts: 5283
Joined: February 28th, 2007, 8:58 pm
Contact:

Re: Converting some old Macros for v1.6

Post by Turuk »

I figured since you seemed to know what you were talking about that you would have the macro in your own file, but I had to ask. ;) Your current setup seems to be fine though, so I'm not sure what the problem is there.
Mainline Maintainer: AOI, DM, NR, TB and THoT.
UMC Maintainer: Forward They Cried, A Few Logs, A Few More Logs, Start of the War, and Battle Against Time
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Converting some old Macros for v1.6

Post by Sapient »

first of all, that's pretty ugly... why not use [have_unit] condition and eliminate those two variables?

another problem, despite what the wiki states, it looks like x and y may be required (I'm not sure though); check your stderr.txt for "inavlid location" errors then try this:

Code: Select all

[store_location]
  [filter]
    canrecruit=1
    side=1
  [/filter]
  variable=destination
[/store_location]
[while]
  [have_unit]
    x,y=recall,recall
    side=1
  [/have_unit]
  [do]
    [recall]
      x,y=$destination.x,$destination.y
      side=1
    [/recall]
  [/do]
[/while]

http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Devrailis Colandore
Posts: 76
Joined: April 22nd, 2007, 3:16 am
Location: Canada

Re: Converting some old Macros for v1.6

Post by Devrailis Colandore »

Thanks for explaining the {GUARDIAN} tag to me. I tried it and it worked perfectly.

I just looked through my stderr.txt file and it's coming up empty. I think that the game is simply not reading any macros in my campaign folder.

I tried verfiying this by having some of my unique units die. I had written some simple macros that would trigger on the death of any important character, which would result in a game loss, however nothing happens now. I don't know if this is because the code has changed or if it is because I have programmed my _main.cfg file improperly.

I've checked my _main.cfg file and this is what is calling my macro files:

Code: Select all

	# Let the campaign load from the utils folder
	{@campaigns/Autumn_Kingdoms_Prologue/utils/}
	{@campaigns/Autumn_Kingdoms_Prologue/utils/macros.cfg}
I believe that this is consistent with what has been done in other campaigns. My utils.cfg and macros.cfg file are both in the utils folder and were working fine back in version v1.3.x.

Should I be doing something different to recall macros?

EDIT:

Just to clarify, the {RECALL_ALL} macro is supposed to trigger at the beginning of the third scenario, and basically recall every single unit around the main character. I tried planting a fort at the beginning of the scenario just to see if there was a problem with the units being stored in the recall list but it turns out that the units are fine and can be recalled normally.

EDIT:

I tried deleting my macro files, inserting a back-up copying and running the program again. This time I did get some results from my stderr.txt file. I'll post the bits that seem the most relevant here:

Code: Select all

20090416 00:01:27 error config: File not found 'FREE_UNIT'
20090416 00:01:27 error config: File not found 'PERRIN_ALDEHAR_DEATH'
20090416 00:01:27 error config: File not found 'ILYANIS_LAVINS_DEATH'
20090416 00:01:27 error config: File not found 'ARAMELLE_ELUVISS_DEATH'
20090416 00:01:27 error config: File not found 'RECALL_ALL'
20090416 00:01:27 error config: File not found 'RECALL_ALL'
It seems like the game just cannot read any of the macros that I had written. I'm going to try re-writing all of the macros from scratch and keep it consistent with v1.6 syntax and hope that that fixes the problem.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Converting some old Macros for v1.6

Post by zookeeper »

Devrailis Colandore wrote:I'm going to try re-writing all of the macros from scratch and keep it consistent with v1.6 syntax and hope that that fixes the problem.
No, it won't.

You're most likely just including your macros after your scenarios or something. Can't say because you haven't shown what you have.
Devrailis Colandore
Posts: 76
Joined: April 22nd, 2007, 3:16 am
Location: Canada

Re: Converting some old Macros for v1.6

Post by Devrailis Colandore »

zookeeper wrote:No, it won't.

You're most likely just including your macros after your scenarios or something. Can't say because you haven't shown what you have.
You were right. It seems the problem is that the game is not reading my macro .cfgs at all. I've checked the macros and they're embedded inside the [scenario] tags, so I don't believe that is the problem.

I should have posted my files sooner. I've attached a zip of my campaign files up to the third scenario. Could someone take a look and see if there are any glaring errors that might be causing the campaign to ignore my macro files? Any help would be appreciated.
Attachments
Autumn_Kingdoms_Prologue.zip
(324.76 KiB) Downloaded 117 times
User avatar
Mist
Inactive Developer
Posts: 753
Joined: February 15th, 2007, 8:44 am
Location: Milton Keynes, UK

Re: Converting some old Macros for v1.6

Post by Mist »

The including order.

You have
<scenarios>
<units>
<macros>

Scenarios use symbols from macros and unit types not defined at the time they are read, so they are ignored. Try

<macros>
<units>
<scenarios>

Should be much better. And there's no need to include images folder, these are read autamaticaly from [binary_path]

EDIT : There is no such thing as

Code: Select all

[variable]
    name=foo
    <operation>=<value>
[/variable]
you want [set_variable] tag or {VARIABLE_OP <name> <operation> <value>} macro for these cases. I should have noticed that in your first post actually :annoyed:
Somewhere, between the sacred silence and sleep.
Disorder.
Devrailis Colandore
Posts: 76
Joined: April 22nd, 2007, 3:16 am
Location: Canada

Re: Converting some old Macros for v1.6

Post by Devrailis Colandore »

Mist wrote:The including order.

You have
<scenarios>
<units>
<macros>

Scenarios use symbols from macros and unit types not defined at the time they are read, so they are ignored. Try

<macros>
<units>
<scenarios>

Should be much better. And there's no need to include images folder, these are read autamaticaly from [binary_path]

EDIT : There is no such thing as

Code: Select all

[variable]
    name=foo
    <operation>=<value>
[/variable]
you want [set_variable] tag or {VARIABLE_OP <name> <operation> <value>} macro for these cases. I should have noticed that in your first post actually :annoyed:
I tried what you suggested and everything ended up working. Thanks, I'm not sure why I didn't try that myself before, it seems terribly simple in retrospect. :? I also fixed the coding on the recall macro. Hopefully this will make it a lot cleaner.

I appreciate all the help you guys have given me!
Post Reply