Seemingly erroneous "missing [x] closing tag" errors

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.
User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by zookeeper » August 21st, 2010, 5:06 pm

Well, I did that and just copied the resulting contents straight into the map_data=, and it worked just fine. Are you really really sure that you don't have some other change or broken file somewhere? Does the error really go away if you remove 2pCave_Questv2.cfg?

Zenogias
Posts: 28
Joined: July 5th, 2010, 1:10 pm

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Zenogias » August 21st, 2010, 6:20 pm

Yes if I remove the .cfg the error goes away -- but another one of the scenarios in the same folder has a similar problem, referencing either a missing [/ai] tag and a line which contains a key with a list or decimal place (village_value=0.1) within the cfg, OR the same problem, referencing a missing [/multiplayer] tag and a " value inside the map.

Only the add-on I've created does this my, apparently broken, copy of wesnoth will run all of the other add-ons I've downloaded fine.

This error has manifested itself in my work twice, and twice I've been totally unable to track it down, deleted the contents of my add-on folder, and started over. It seems to work fine until the files get to a certain level of complexity, or... I don't know; 45 days go by? Hellif-Iknow; I've been working on this for like weeks before I decided to bother everyone here about it.

Also, I've tried it on three different computers locally, all running wesnoth 1.8.2 -- all with identical error messages..

I've attached my _main.cfg - which I have also been over a bunch of times -- since that is next logical place to look; as far as I can tell?
Attachments
_main.cfg
(2.32 KiB) Downloaded 101 times

Zenogias
Posts: 28
Joined: July 5th, 2010, 1:10 pm

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Zenogias » August 21st, 2010, 6:37 pm

I'm trying to uninstall and reinstall Wesnoth right now (again)

--

This did not fix the problem.
Last edited by Zenogias on August 21st, 2010, 7:08 pm, edited 1 time in total.

User avatar
Dixie
Posts: 1756
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Dixie » August 21st, 2010, 6:47 pm

Zenogias wrote:Yes if I remove the .cfg the error goes away -- but another one of the scenarios in the same folder has a similar problem, referencing either a missing [/ai] tag and a line which contains a key with a list or decimal place (village_value=0.1) within the cfg, OR the same problem, referencing a missing [/multiplayer] tag and a " value inside the map.
The error didn't go away, then. The error message may change, but there is still an error somewhere.
Zenogias wrote: Only the add-on I've created does this my, apparently broken, copy of wesnoth will run all of the other add-ons I've downloaded fine.

This error has manifested itself in my work twice, and twice I've been totally unable to track it down, deleted the contents of my add-on folder, and started over. It seems to work fine until the files get to a certain level of complexity, or... I don't know; 45 days go by? Hellif-Iknow; I've been working on this for like weeks before I decided to bother everyone here about it.

Also, I've tried it on three different computers locally, all running wesnoth 1.8.2 -- all with identical error messages..
I really doubt either your copy of wesnoth or your computer is broken, and this quote only proves it. Likely, all the add-ons you download work fine, but not yours: because when you reach a certain level of complexity (as you say it) you make a certain mistake. And apparently, it's something you always eventually make when reaching that certain degree of complexity. Find what that mistake is, fix it, and try to not reproduce it ever again.

What to do, then? Continue removing the stuff it points to until it stops giving error messages entirely: then you know the last file you removed had an error. So add it back, and try removing content from it, until you can tackle which section contained the error. Repeat over and over again until you narrowed your search enough that you know most certainly what is wrong, and fix it, or THEN ask for help if you don't understand what's wrong with said code snippet. You are more likely to get prompt help if you narrow your code to jsut a few lines: people usually have other stuff to do than look through an entire scenario. Do note that there can be more than one such error, though. It's hard, it's long, but it's necessary, and no one but you will do it.

Don't give up, debugging can be long and arduous, but when you succeed, it is highly worth it. :)
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth

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

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by zookeeper » August 21st, 2010, 7:24 pm

What Dixie said.

You can't always trust the syntax/preprocessor error messages. When you make a mistake in one place, for example forget to add the closing quote to a quoted string, the game might happily continue to read in all the rest of the WML in that file and assume that you simply intended that to be part of the string you started, and when it eventually figures out that something is wrong, it only reports the location at which point it figured out that something is wrong.

So, if you get an error seemingly originating from file A, then remove file A and now get a different error from file B, you can't assume that that's really a different error just because of what the error message says.

Zenogias
Posts: 28
Joined: July 5th, 2010, 1:10 pm

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Zenogias » August 21st, 2010, 7:54 pm

I really do appreciate the inspiring advice, but now that I know other people have tried my files -- the same ones that I am trying to load -- and did NOT get my errors.... Well, my .cfg and map, as I've posted and tried, are free of errors... unless there is a problem I cannot find with the fairly straight-forward _main.cfg file I have written (which I have posted), there doesn't seem to be any causality associated with the actual files I've written but -- as far as I can tell -- only with computers I've physically touched, so.... :hmm:

Although you are MORE than welcome to go through all of my code (which I have posted) an ferret out my problem -- in fact, as I've been unable to, I would greatly appreciate it. I would LOVE if there was some novice syntax mistake I had made in my _main.cfg that was causing my stuff to load poorly :cry:

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

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by zookeeper » August 21st, 2010, 8:05 pm

Well, in case of otherwise unsolvable mysteries, you can just .zip up your entire add-on and post that as an attachment (if you're worried about filesize then you can remove all images; that never results in WML errors, only missing images) so that people can actually see it exactly like you do. Just by looking at individual files one at a time, we can never be sure that you don't actually have some file in the wrong place or something on your end.

Zenogias
Posts: 28
Joined: July 5th, 2010, 1:10 pm

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Zenogias » August 21st, 2010, 8:46 pm

Hahah! Thanks zookeeper -- I went to take the images out to zip, and decided to remove a few of the cfg's which are not causing errors, which stopped the errors from occurring -- so there is a problem in a scenario cfg which is causing my OTHER scenarios to fail :hmm:

When wesnoth loads the contents of a directory (i.e. loading the contents of my "scenarios" directory from my _main.cfg file) does it load them in alphabetical order??

The reason I ask, being that the LAST scenario -- in alphabetical order -- in causing EVER other one of my scenarios to fail, in alphabetical order, starting with the first.

User avatar
Dixie
Posts: 1756
Joined: February 10th, 2010, 1:06 am
Location: $x1,$y1

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Dixie » August 21st, 2010, 9:09 pm

Zenogias wrote:I went to take the images out to zip, and decided to remove a few of the cfg's which are not causing errors, which stopped the errors from occurring -- so there is a problem in a scenario cfg which is causing my OTHER scenarios to fail :hmm:

Yes, that is exactly what we said: maybe the error message points to a scenario, and maybe removing it changes the message, but it doesn't necessarily mean that the error was in the pointed scenario, or that there are multiple errors. I think when a campaign is loaded, the engine goes over everything. As Zookeeper said, it could come over an error somewhere in so doing, but think it is intended, but finally realise there is truly something wrong later on, and point to the place it realised that, even though the error message may make no sense and the place being the wrong one. Other people have tried the file alone, and it worked: the error is not in that file. But it can still be elsewhere and point to that file, who knows why.
Jazz is not dead, it just smells funny - Frank Zappa
Current projects: Internet meme Era, The Settlers of Wesnoth

Zenogias
Posts: 28
Joined: July 5th, 2010, 1:10 pm

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Zenogias » August 21st, 2010, 9:22 pm

Right after I posted below, I realized I defined a macro WITHIN a larger macro -- is this even possible??
----

Ok, my scenario (3pDungeon_Quest.cfg -- I know, I'm totally original and creative :P ) loads fine if I comment out the following files; and does not work if I do include the following files. Including these files -- like I said -- causes problems loading EARLIER scenarios...

Attached are two separate files, one which I use to define a large macro for placement of items in an RPG-type scenario, in chests randomly (random item from list in pre-defined chests), and the other file actually defines the items (also within macros which are referenced by the placement macro, which is in turn utilized by the scenario cfg)

I am using 30 items and 21 chests, but I have cut this down to 1 item and 1 chest, trying to debug my code. I still get the same fail errors using just 1 item and 1 chest, meaning (to me) that there is a fundamental problem with my code, and not a singular typo.

I've gone over the code and there isn't any typo's I can find; (for me) this is a fairly complex process I'm trying to achieve here (is my newest work -- should have looked here first for problems in general but, as observed, I was miss-led by my own assumption that the error message was "smart" in some way :P ) and so there is probably some fundamental problem with my code I don't have the experience to see; or maybe I can't at all do what I'm trying to do.

Please help (more), thanks.

Here is the item_defintion code

Code: Select all

### DUNGEON QUEST ITEM MACROS ###

#define VOID_ARMOR X Y
    {PLACE_IMAGE items/armor-golden.png ({X}) ({Y})}
    {VARIABLE void_armor_taken 0}
	#define VOIDARM Z
		[event]
			name=moveto
			first_time_only=no
			[filter]
				side={Z}
				x,y={X},{Y}
			[/filter]
			[if]
				[variable]
					name=void_armor_taken
					numerical_equals=0
				[/variable]
				[then]
					[message]
						speaker=narrator
						image="wesnoth-icon.png"
						message= _ "Should this unit pick up the VOID ARMOR?"
						side_for={Z}
						[option]
							message= _ "Yes"
							[command]
								[object]
									id=void armor
									name= _ "Void Armor"
									image="items/armor-golden.png"
									description= _ "A beautiful chest plate crafted from shimmering black steel, the Void Armor is virtually impenetrable to physical weapons!"
									duration=forever
									[filter]
										side={Z}
										x,y={X},{Y}
									[/filter]
									[then]
										[removeitem]
											x,y={X},{Y}
										[/removeitem]
										[message]
											speaker=narrator
											image="wesnoth-icon.png"
											side_for={Z}
											message= _ "You struggle to lift and don the heavy plate. Once worn, however, it is amazingly comfortable. You have increased resistance to all physical damage!"
										[/message]
										{VARIABLE void_armor_taken 1}
										[set_variables]
											name=unit.modifications.trait
											mode=append
											[value]
												id=void_armor
												name= _ "void armor"
												description= _ "The Void Armor grants the following resistances:
blade:  60%
pierce: 50%
impact: 50%
fire:  +10%"
											[/value]
										[/set_variables]
										[unstore_unit]
											variable=unit
											find_vacant=no
										[/unstore_unit]
									[/then]
									[effect]
										apply_to=resistance
										replace=true
										[resistance]
											blade=40
											pierce=50
											impact=50
										[/resistance]
									[/effect]
									[effect]
										apply_to=resistance
										[resistance]
											fire=-10
										[/resistance]
									[/effect]
								[/object]
							[/command]
						[/option]
						[option]
							message= _ "No"
						[/option]
					[/message]
				[/then]
			[/if]
		[/event]
	#enddef
	{VOIDARM 1}
	{VOIDARM 2}
	{VOIDARM 3}
#enddef
And here is the item placement code

Code: Select all

### DUNGEON QUEST ITEM PLACEMENT WML ###


#define DUNGEON_QUEST_ITEM_PLACEMENT


{VARIABLE VOID_ARMOR_placed 0}
{VARIABLE chest_01_filled 0}


#define NEWSEARCH X
{VARIABLE_OP treasure_{X} random (VOID_ARMOR)}
#enddef

### Place Item at Chest 01 ###
	[event]
		name=prestart
		{NEWSEARCH 01}
		[while]
			variable=chest_01_filled
			numerical_equals=0
			[if]
				variable=$treasure_01|_placed
				numerical_equals=0
				[then]
					{treasure_01 60 197}
					{VARIABLE $treasure_01|_placed 1}
					{VARIABLE chest_01_filled 1}
				[/then]
				[else]
					{NEWSEARCH 01}
				[/else]
			[/if]
		[/while]
	[/event]

						
#enddef

	
Last edited by Zenogias on August 21st, 2010, 10:12 pm, edited 2 times in total.

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

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by zookeeper » August 21st, 2010, 9:51 pm

That's so unnecessarily complicated that...urgh. To tell you the truth it's pretty horrible.

I have no idea if defining a macro inside a macro works, but the whole VOIDARM macro is completely unnecessary. You don't need three calls to it to be able to make it work for three different sides...just use side=1,2,3 in the moveto event filter, and then $side_number instead of {Z} everywhere else.

As for dungeon_quest_item_placement.cfg, I have no idea what it's supposed to do, nor do I want to try to figure it out either...

Lastly, [while] and [if] don't take variable= and numerical_equals= keys, [variable] does.

What you want seems like something someone could whip up pretty quickly for you if you just describe it in plain english.

Zenogias
Posts: 28
Joined: July 5th, 2010, 1:10 pm

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Zenogias » August 21st, 2010, 10:00 pm

OK:

dungeon_quest_item_placement is supposed to pick a random item from a list (I cut the complete list of 30 items I've created definitions for down to just VOID_ARMOR for debugging) and FIRST check to see if that item has been placed already (thereby unique items in only one of the 21 chests), if it has then it picks a new item, if it has not then it moves forward with placing the item on the particular hex (there are 21 hexes to get items and 30 items) and sets a variable to indicate that the item has been placed, and then moves on to the next chest. I used a variable (chest_x_filled) and [while] loops to make it keep trying to fill one chest with a unique item until it succeeds (I thought) and then move on to the next.

dungeon_quest_items describes the items for which to be placed;
zookeeper:
Lastly, [while] and [if] don't take variable= and numerical_equals= keys, [variable] does.
so instead I should do:

Code: Select all

[if]
    [variable]
         name=my_variable
         numerical_equals=desired_value
    [/variable]
    [then]
          {WHAT_I_WANT_TO_HAPPEN}
    [/then]
[/if]
Right??

so aside from deleting the interior macro, and just using $side_number... -- uhg -- I spent a lot of time on it :oops:
I mean, I'm more interested in learning from my mistakes and getting better than just getting working code that someone else banged together for me..
Thanks, anyways, I appreciate you pro's helping out my inexperienced rear end :P

Zenogias
Posts: 28
Joined: July 5th, 2010, 1:10 pm

Re: Seemingly erroneous "missing [x] closing tag" errors

Post by Zenogias » August 21st, 2010, 10:22 pm

Ahah! It's because you CANNOT define a macro INSIDE the definition of another macro. I fixed that and -- BOOM -- no more errors.
So I guess we ALL learned something today; don't use macros inside of macros or you get WEIRD errors..

My crappy code even seems to work OK so far (edit: no it does not :P)

(thanks again for your saint-like patience zookeeper, and now dixie, as well as everyone else who chimed in)

Post Reply