WML Error Messages and what they mean

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
Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

WML Error Messages and what they mean

Post by Ceres » July 24th, 2011, 7:07 pm

Since it happens rather often that some WML code outputs some error message, but it is not clear to everybody what these messages mean, here's a list of WML errors on loading and their reasons:

NOTE: This list is based on Battle for Wesnoth 1.9.9. While error messages may differ for newer/older versions, most of this list still applies.

Unknown Scenario: <id of a scenario>


-the next_scenario key of the previous scenario and the id key of the actual scenario don't match (if it's the first scenario, it's the first_scenario key in your[campaign] tag which has to match with the scenario id)
(NOTE: id's are case-sensitive! Id's have nothing to do with filenames!)

-the argument given in the define key in your [campaign]tag doesn't match the one following the #ifdef when including your files
(NOTE: definitions are case-sensitive!)

-the actual path to your scenarios folder and the path you used within your _main.cfg don't match
(NOTE: again, case-sensitivity; and watch out for accidental whitespaces in your folder names, they're almost invisible in non-monospace font)

-whitespaces in the path to your scenarios folder. Even if the path is right, Wesnoth doesn't like whitespaces. Always use underscores.

-your scenario file has no .cfg ending
(NOTE: some programs tend to add a .txt extension without your knowledge)

-any other error message that hasn't "The program will now terminate" or something similar written in it generates this error after clicking 'Ok' at the first message. Removing the other problem removes the "Unknown Scenario". Remember: if the engine complains about your scenario, it can't be unknown anymore.

Macro/File <macro or path> is missing

-you called a macro that isn't defined
(NOTE: macros are case-sensitive)

-you called a path that isn't existing, likely there is a spelling error in this path
(NOTE: again, paths are case-sensitive)

-if <macro or path> contains font or charset, you saved one or more files as rich text. WML files need to be UTF-8 plain text.

-in your _main.cfg, you called e.g. the scenarios folder before the utils folder, so the macros you used in the first are not yet known by the engine.

Preprocessor symbol <macro> expects <number> arguments but has <number> arguments

-you called a macro with the wrong number of arguments. If a macro has X possible arguments, you always have to call it with X arguments!
If you want to leave one out, search for the macro definition and check how the argument is used. If it doesn't hurt that the argument is empty, use (). That counts as argument, but does nothing. If the argument being empty would break the code, test it if necessary, look for the shortest way to make it syntactically correct without any gameplay effect.

-note that since whitespaces divide the arguments, you have to put brackets around a single argument that contains whitespaces. Otherwise every whitespace-seperated part of the argument will count as an argument on its own.

A map without a header is not supported

-your map path is invalid. The header is automatically added by the map editor.

Quoted string not terminated

-you have an unclosed quote somewhere. The number of quotes should always be even.
(NOTE: the error message doesn't necessarily point to the line that caused the error. If you forgot to terminate a quote, the next opening quote is counting as terminating, the terminating quote as opening and so on, till the last quote when the engine notices that there's one missing)

Found invalid closing tag <tag name> for tag <tag name>

-a tag is closed incorrectly, either because you mistyped the opening or terminating tag; or because of something like

Code: Select all

[a]
  [b]
[/a]
  [/b]
Missing closing tag for tag <tag name>

-you didn't close a tag

Unexpected character after variable name (expected , or =) value '<something>'

-if the error message is "Unexpected character after variable name (expected , or =) value '
' ", then you have no equal sign (=) after a key. It has to look like

Code: Select all

key=value
or

Code: Select all

key,key2=value,value2
-if the error message is "Unexpected character after variable name (expected , or =) value ']' ", then you forgot an opening square bracket in a tag

-if the error message is "Unexpected character after variable name (expected , or =) value '}' ", then you forgot an opening brace in a macro

Unterminated [element] tag, value '<something>'

-you forgot a terminating square bracket in a tag, but have <something> instead

Macro substitution not terminated

-you forgot to terminate a macro with a brace

The game map could not be loaded: Illegal tile in map: (something) 'something'

-you used a terrain type wesnoth doen't recognize. If you want to use costom terrain types from UMC or special terrain of a mainline campaign, you have to copy the terrain definition as well, and make Wesnoth read it by including the file in your _main.cfg.
Last edited by Ceres on March 18th, 2012, 8:30 pm, edited 12 times in total.

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

Re: WML Error Messages and what they mean

Post by zookeeper » July 24th, 2011, 7:40 pm

Good thread.
Ceres wrote:-you called a mcaro with the wrong number of arguments. If a macro has X possible arguments, you always have to call it with X arguments! If you want to leave one out, use (). That counts as argument, but does nothing.
That could probably be clarified a bit. What effects an empty argument has depends entirely on what the macro does with that argument: it might work as you'd expect or it might not, so you should only use an empty argument if you know (through example code, or by reading the macro definition and checking for yourself) that it's actually supported.

Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: WML Error Messages and what they mean

Post by Ceres » July 24th, 2011, 7:56 pm

Thanks :D
Clarified it (hopefully).

User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm

Re: WML Error Messages and what they mean

Post by 8680 » July 24th, 2011, 9:06 pm

Ceres wrote:Preprocessor symbol <macro> expects <number> arguments but has <number> arguments [...] If it doesn't hurt that the argument is empty, use (). [...]
I read that “()” as “0” at first. I suggest you make it monospace.
Ceres wrote:Unexpected character after variable name (expected , or =) value '<something>' [...] I has to look like [...]
“I” > “It”.

I also recommend increasing the size of the error names to make them easier to find. In just bold they blend in somewhat.

Anonymissimus
Developer
Posts: 2458
Joined: August 15th, 2008, 8:46 pm
Location: Germany

Re: WML Error Messages and what they mean

Post by Anonymissimus » July 25th, 2011, 12:16 am

Ceres wrote:-the path to your folder and the path you used within [binary_path] (...) don't match
Um, no. If the binary path is wrong
-custom units are completely invisible except for the ellipse, the hitpoints bar and such
-custom sounds and music issue "not found" messages
But the campaign loads anyway.
Actually, I would recommend to get something working first without the art.

note: I didn't check the whole post.
projects (BfW 1.12):
A Simple Campaign: campaign draft for wml startersPlan Your Advancements: mp mod
The Earth's Gut: sp campaignSettlers of Wesnoth: mp scenarioWesnoth Lua Pack: lua tags and utils
updated to 1.8 and handed over: A Gryphon's Tale: sp campaign

monochromatic
Posts: 1545
Joined: June 18th, 2009, 1:45 am

Re: WML Error Messages and what they mean

Post by monochromatic » July 25th, 2011, 4:27 pm

Good work so far!

For 'Macro/File <macro or path> is missing', you might also want to write something about calling the macros before the scenarios. I've had something like this:

Code: Select all

#ifdef CAMPAIGN_AWESOME
[binary_path]
    path=data/add-ons/Awesome
[/binary_path]

{~add-ons/Awesome/scenarios}
{~add-ons/Awesome/utils}
#endif
... fail on me before. Swapping utils and scenarios fixed it though. (1.9, though haven't tested it on the more recent releases.)
EDIT: Grammar fail.
Last edited by monochromatic on July 25th, 2011, 8:36 pm, edited 1 time in total.

User avatar
8680
Moderator Emeritus
Posts: 742
Joined: March 20th, 2011, 11:45 pm

Re: WML Error Messages and what they mean

Post by 8680 » July 25th, 2011, 6:15 pm

Another reason for “Macro/file <macro or path> is missing”:

-if <macro or path> contains font or charset, you saved one or more files as rich text. WML files need to be UTF-8 plain text.

User avatar
SkyOne
Posts: 1310
Joined: January 3rd, 2009, 7:23 pm

Re: WML Error Messages and what they mean

Post by SkyOne » July 26th, 2011, 4:32 am

monochromatic wrote:Good work so far!
The same.:)
Ceres wrote:NOTE: This list is based on Battle for Wesnoth 1.9.7. It may be that various error messages from older versions aren't appearing anymore in 1.9.7 and aren't listed.
Ceres wrote:Missing closing tag for tag <tag name>

-you didn't close a tag
I think "missing closing tag error" occurs on 1.8 and before, but no longer on 1.9.
It seems more specified on 1.9 as you describe above.
Spoiler:
Fate of a Princess/feedback thread: "What is in own heart that is the most important, not who you are."
Drake Campaign: Brave Wings/feedback thread, Naga Campaign: Return of the Monster, Saurian Campaign: Across the Ocean
Northern Forces - now on 1.12 server

Ceres
Forum Regular
Posts: 620
Joined: September 18th, 2010, 7:56 pm
Location: Germany

Re: WML Error Messages and what they mean

Post by Ceres » August 24th, 2011, 6:26 pm

Thanks all :)
Anonymissimus wrote:
Ceres wrote:-the path to your folder and the path you used within [binary_path] (...) don't match
Um, no. If the binary path is wrong
-custom units are completely invisible except for the ellipse, the hitpoints bar and such
-custom sounds and music issue "not found" messages
But the campaign loads anyway.
Actually, I would recommend to get something working first without the art.
My wrong then. Changed.

monochromatic&8680: Thank you, included.
SkyOne wrote:I think "missing closing tag error" occurs on 1.8 and before, but no longer on 1.9.
It seems more specified on 1.9 as you describe above.
I removed a [/scenario] and got this error on 1.9.7. Maybe behaviour is different for different tags.

Repost-edit: If no one has any more complaints or ideas, if you don't mind, could someone please stickify it?

Post Reply