None of my macros is working

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
Steelclad Brian
Posts: 110
Joined: November 15th, 2005, 5:26 am

None of my macros is working

Post by Steelclad Brian »

I'm working on my first map and I have to admit I am totally confused and frustrated. I've done two things with macros that will not work for reasons I cannot fathom. Both are almost literally copy and pasted from other campaigns, and after going through the relatively sparse documentation on defining your own macros, I really have no idea what is going wrong.

The first macro is in the campaigns uppermost .cfg file. It's a fairly common idea I've seen in several campaigns. It's this:

Code: Select all

#ifdef CAMPAIGN_DWARF_SUNDERING
[+units]
{@campaigns/The_Sundering/units}
[/units]

{@campaigns/The_Sundering/scenarios}

#define MAP NAME
	map_data="{@campaigns/The_Sundering/maps/{NAME}}"
#enddef
#endif
This was my first clue that none of my macros were working, but I just ignored it and entered the map data in manually. When I try to use this macro to call map_data, I simply get an error message equivalent to "Map not found."

The second, which is driving me up the wall, is a set of unit spawning macros. They are designed to populate the world on prestart with an army of units for two sides. They look like this:

Code: Select all

#define ORC_ARCHER X Y
	[unit]
		type=Orcish Archer
		side=2
		x={X}
		y={Y}
	[/unit]
#enddef
Then they are called in a prestart event like this:

Code: Select all

[event]
	name=prestart
	{DWARVISH_SCOUT 8 21}
	{DWARVISH_SCOUT 9 23}
	{DWARVISH_SCOUT 8 22}
	{DWARVISH_SCOUT 10 22}

	{ORCISH_GRUNT 16 20}
	{ORCISH_GRUNT 16 18}
	{ORCISH_ARCHER 15 19}
	{ORCISH_ARCHER 17 19}
	{ORCISH_ARCHER 15 20}
	{ORCISH_ARCHER 17 20}
	{ORCISH_WARRIOR 15 21}
	{ORCISH_WARRIOR 16 21}
	{ORCISH_WARRIOR 17 21}

	[/event]
Yet none of these units show up when the map loads. It is as if the macros simply aren't there. Any help would be appreciated - this is driving me up the wall.
Steelclad Brian
Posts: 110
Joined: November 15th, 2005, 5:26 am

Re: None of my macros are working

Post by Steelclad Brian »

Oh man... I already see the inconsistency between ORC_ARCHER and ORCISH_ARCHER... well, I suppose there's something to be said at looking at things from another angle... :)

Well, now I've got the units working, but I still can't load the map file using that macro.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: None of my macros are working

Post by zookeeper »

Steelclad Brian wrote:

Code: Select all

#ifdef CAMPAIGN_DWARF_SUNDERING
[+units]
{@campaigns/The_Sundering/units}
[/units]

{@campaigns/The_Sundering/scenarios}

#define MAP NAME
	map_data="{@campaigns/The_Sundering/maps/{NAME}}"
#enddef
#endif
The MAP macro should work.

Code: Select all

[scenario]
    id=whatever
    name= _ "whatever"
    {MAP filename-of-map}
    ...
[/scenario]
Are you sure you're using it like this (I assume that the maps are in the directory where the macro points to, etc.)?
scott
Posts: 5243
Joined: May 12th, 2004, 12:35 am
Location: San Pedro, CA

Post by scott »

Try putting {NAME} inside parentheses like this

Code: Select all

#define MAP NAME 
   map_data="{@campaigns/The_Sundering/maps/({NAME})}" 
#enddef 
[code]

Also you can try not using a macro.  You don't gain much since you call one macro that does nothing except call another macro, passing through your sinlge argument unchanged.  I always thought map macros were slightly silly.


Edit: sorry, I meant NAME not MAP
Last edited by scott on November 15th, 2005, 1:22 pm, edited 1 time in total.
Hope springs eternal.
Wesnoth acronym guide.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

scott wrote:I always thought map macros were slightly silly.
I develop my campaign under a name different than the name I'll use when publishing, so at least I don't have to, when the time comes, go through all the scenario files to change the directories there. Of course it would take only 10 extra seconds to change those as well, but still.
Post Reply