Tricky WML (Clever people needed)

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.
Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

Re: Tricky WML (Clever people needed)

Post by Mabuse »

i have noticed some odd things, maybe that helps you:
Longbow wrote:

Code: Select all

#define OBJ_BOOK_STRATEGY X Y ID

[...]

        [if]
            [variable]
                name=book_taken
                numerical_equals=0
            [/variable]
[/if]
            [then]
                [message]

[...]

                                    [/message]
                                    {VARIABLE book_taken 1}
                                [/then]


                                [effect]

[...]

                                [/effect]
            [/then]
    [/event]
#enddef
I've checked all the tags as best I can, but it still doesn't work and I still don't know what's wrong...
1)
so first of all you open an IF tag, close it and then open a then tag
is this how if/then is used ;) ?

it should be like this:
[if]
...
[then]
...
[/then]
[/if]


also you have at the bottom of your code a [/then] tag which i cant find a [then] for
perhaps look at these things and go on


btw, you wrote that you took this from another source and just edited it or something - my tip for these things: stay as close as yp can to the original unless you know what you are doing ;)

so i would simply take the original and stick as close as possible to it. if you cant fix it.

if it works in the other SCN it will work for you.
The best bet is your own, good Taste.
User avatar
Turuk
Sithslayer
Posts: 5283
Joined: February 28th, 2007, 8:58 pm
Contact:

Re: Tricky WML (Clever people needed)

Post by Turuk »

Mabuse wrote:also you have at the bottom of your code a [/then] tag which i cant find a [then] for
perhaps look at these things and go on
They are both there, you may have missed it when you edited out the big portions of his code.
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
Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

Re: Tricky WML (Clever people needed)

Post by Mabuse »

nope. "they" are not.

and why "both" its just ONE [then] what is missing

and its terribly easy to check that either, just "search for "[then]" with a texteditor on the example and you will only find ONE [then], while there are TWO [/then]

EDIT:
(although i guess it the [/then] in the middle which is wrong though, but tbh, i didnt look at the code and see what it does, i just checked for tags - but as a matter of fact theres one [/then] too much, and this will cause problems ... and also the wrongly placed If/then thingy since then should be included inside IF)
Last edited by Mabuse on March 5th, 2009, 7:41 pm, edited 1 time in total.
The best bet is your own, good Taste.
Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

Re: Tricky WML (Clever people needed)

Post by Mabuse »

heres the full version i am referring to:
(if this is unclear)

as said, grab a textpad, copy it in, and look for yourself - i would be surprised if you find TWO "[then]" ;)
Longbow wrote:

Code: Select all

#define OBJ_BOOK_STRATEGY X Y ID
    {PLACE_IMAGE items/book1.png ({X}) ({Y})}
    {VARIABLE book_taken 0}
    [event]
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x={X}
            y={Y}
        [/filter]
        [if]
            [variable]
                name=book_taken
                numerical_equals=0
            [/variable]
[/if]
            [then]
                [message]
                    speaker=narrator
                    image="items/book1.png"
                            [object]
                                id={ID}
                                name= _ "Undead Strategy Guide"
                                image=items/staff-magic.png
                                duration=forever
                                message= _ "This legendary staff belonged to Minister Edmond, advisor to Prince Haldric and founder of the White order of Magi. When he passed away from old age, the staff was thought to have been lost."
                                cannot_use_message= _ "Only a powerful warrior or mage can use this staff!"
[/object]
                 [/message]
                                    [removeitem]
                                        x,y={X},{Y}
                                    [/removeitem]
                                    [message]
                                        speaker=narrator
                                        image="items/book1.png"
                                        message= _ "As you pick up the ornate staff, it starts to pulse with arcane energy. This mighty weapon will decimate magical creatures."
                                    [/message]
                                    {VARIABLE book_taken 1}
                                [/then]
                                [effect]
                                    [set_menu_item]
	                             id=book_strategy
	                             description= _ "Undead Strategy Guide"
	                             image=items/book1.png
                                      [while]
			               [variable]
				        name=quit_menu
				        numerical_equals=0
			               [/variable]

			
			                 [do]
				 [message]
					speaker=narrator
					side_for=$side_number
					caption= _ "   Undead Strategy Guide   "
					message= _ " Choose what you want to know:     "
					image=items/book1.png
	                         [/message]
					  [option]
						
						message=*{MENU_IMG_TXT "items/book1.png" _"Close Strategy Guide"}
						[command]
							[set_variable]
								name=quit_menu
								value=1
							[/set_variable]
						[/command]
					   [/option]
			
			                   [/do]
	                                 [clear_variable]
		                           name=quit_menu
	                                 [/clear_variable]
                                       [/while]
                                 [/set_menu_item]

                                [/effect]
            [/then]
    [/event]
#enddef
I've checked all the tags as best I can, but it still doesn't work and I still don't know what's wrong...
The best bet is your own, good Taste.
User avatar
Turuk
Sithslayer
Posts: 5283
Joined: February 28th, 2007, 8:58 pm
Contact:

Re: Tricky WML (Clever people needed)

Post by Turuk »

Ah, the third iteration of it, yes. The first two have all the then tags there, for some reason he took it out in that one. I was looking only at the first two.

Longbow! Fix yourself! :P
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
Mabuse
Posts: 2130
Joined: November 6th, 2007, 1:38 pm

Re: Tricky WML (Clever people needed)

Post by Mabuse »

Turuk wrote:Ah, the third iteration of it, yes. The first two have all the then tags there, for some reason he took it out in that one. I was looking only at the first two.

Longbow! Fix yourself! :P
hehe, i thought that :)
(tbh, i even didnt look at the first two :p .... um not carefully i mean - but that wasnt needed either i guess)
The best bet is your own, good Taste.
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

Thanks guys, I'll fix the then tomorrow. I did the if/then thingy and it didn't seem to work, but that may be because of the duplicate /thens.
Turuk wrote:Longbow! Fix yourself! :P
:P
My campaign, Elvish Legacy
My inventively named Era
fabi
Inactive Developer
Posts: 1260
Joined: March 21st, 2004, 2:42 pm
Location: Germany

Re: Tricky WML (Clever people needed)

Post by fabi »

One mistake I can spot on a first glance is a error with the conditional:

Code: Select all

[if]
     [then]
     [/then]
[/if]

not
[if]
[/if]
[then]
[/then]
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

OK, so now it doesn't crash, but I don't get the right-click menu option, just the picking-up-item text etc.

edit: Disregard that, menu working now, no features/content yet, but at least it works! :D
My campaign, Elvish Legacy
My inventively named Era
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Tricky WML (Clever people needed)

Post by Sapient »

By the way, that's not a "crash": it's called a "config error" due to parsing a .cfg file with malformed WML
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

Ok, but it is quicker to write crash :wink:
I know, people will think it is a different problem, will bear in mind in future
My campaign, Elvish Legacy
My inventively named Era
Post Reply