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.
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Tricky WML (Clever people needed)

Post by Longbow »

Hi,

Can anyone tell me what's wrong with this code?

When I remove

Code: Select all

  {OBJ_BOOK_STRATEGY 33 22 book_strategy}
it works, but I need this part.

#note, the bit about the holy staff at the end is fine, I describe it earlier, just not posted.

If you want to help and need more info pls ask.

Thanks

:)

Code: Select all

#define OBJ_BOOK_STRATEGY X Y book_strategy
    {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]
            [then]
                [message]
                    speaker=narrator
                    image="items/book1.png"
                    message= _ "Do you want this unit to pick up the staff?"
                            [object]
                                id={ID}
                                name= _ "Undead Strategy Guide"
                                image=items/staff-magic.png
                                duration=forever
                                description= _ "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!"
                [/message]
                                [then]
                                    [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

					[option]
						
						message=*{MENU_IMG_TXT "items/book1.png" _"Close Strategy Guide"}
						[command]
							[set_variable]
								name=quit_menu
								value=1
							[/set_variable]
						[/command]
					[/option]
				[/message]
			[/do]
		[/while]
	[clear_variable]
		name=quit_menu
	[/clear_variable]
                                 [/set_menu_item]

                                [/effect]
                            [/object]
                        [/command]
                    [/option]
                [/message]
            [/then]
        [/if]
    [/event]
#enddef

        {OBJ_STAFF_HOLY 9 12 holy_staff}

        {OBJ_BOOK_STRATEGY 33 22 book_strategy}
:shock:
My campaign, Elvish Legacy
My inventively named Era
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Tricky WML (Clever people needed)

Post by zookeeper »

#define OBJ_BOOK_STRATEGY X Y book_strategy

:roll:
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

?

Code mistake?

Concept of strategy book?

Something really obvious that someone with IQ>0 could see?

Sorry, I don't get what your sarcastic but perfectly executed eye-rolling is directed at.
My campaign, Elvish Legacy
My inventively named Era
User avatar
A Guy
Posts: 793
Joined: May 24th, 2008, 1:55 am

Re: Tricky WML (Clever people needed)

Post by A Guy »

The book_strategy part of the macro isn't necessary.

Also, I don't see why a [/set_menu_item] tag is there when no [set_menu_item] tag was opened up.
I'm just... a guy...
I'm back for now, I might get started on some work again.
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

book_strategy makes no difference it seems and set menu thingy is here:

Code: Select all

#define OBJ_BOOK_STRATEGY X Y book_strategy
    {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]
            [then]
                [message]
                    speaker=narrator
                    image="items/book1.png"
                    message= _ "Do you want this unit to pick up the staff?"
                            [object]
                                id={ID}
                                name= _ "Undead Strategy Guide"
                                image=items/staff-magic.png
                                duration=forever
                                description= _ "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!"
                [/message]
                                [then]
                                    [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]

Code: Select all

                                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

               [option]
                  
                  message=*{MENU_IMG_TXT "items/book1.png" _"Close Strategy Guide"}
                  [command]
                     [set_variable]
                        name=quit_menu
                        value=1
                     [/set_variable]
                  [/command]
               [/option]
            [/message]
         [/do]
      [/while]
   [clear_variable]
      name=quit_menu
   [/clear_variable]
                                 [/set_menu_item]

                                [/effect]
                            [/object]
                        [/command]
                    [/option]
                [/message]
            [/then]
        [/if]
    [/event]
#enddef

        {OBJ_STAFF_HOLY 9 12 holy_staff}

        {OBJ_BOOK_STRATEGY 33 22 book_strategy}
My campaign, Elvish Legacy
My inventively named Era
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Re: Tricky WML (Clever people needed)

Post by Ken_Oh »

You want #define OBJ_BOOK_STRATEGY X Y ID
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

Thanks but I've done this:

Code: Select all

#define OBJ_BOOK_STRATEGY X Y ID
and get
snapshot7.png
:(

Also, this didn't seem to affect anything on my holy_staff define earlier...
My campaign, Elvish Legacy
My inventively named Era
User avatar
A Guy
Posts: 793
Joined: May 24th, 2008, 1:55 am

Re: Tricky WML (Clever people needed)

Post by A Guy »

Just look at all the unnecessary closing tags you have at the end.
I'm just... a guy...
I'm back for now, I might get started on some work again.
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

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...
My campaign, Elvish Legacy
My inventively named Era
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Tricky WML (Clever people needed)

Post by zookeeper »

Then find out what is wrong. It's that simple.
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

What a brilliant idea, thanks :D

I have spent all evening trying different things to find out what is wrong... :x
I may just delete this and start again, most of the WML for this comes from some other add-on, but I modified it and...
My campaign, Elvish Legacy
My inventively named Era
User avatar
A Guy
Posts: 793
Joined: May 24th, 2008, 1:55 am

Re: Tricky WML (Clever people needed)

Post by A Guy »

Try using wmlindent to make things easier for us.
I'm just... a guy...
I'm back for now, I might get started on some work again.
User avatar
Longbow
Posts: 303
Joined: May 18th, 2008, 3:59 pm

Re: Tricky WML (Clever people needed)

Post by Longbow »

OK, I'll do so and post tomorrow, ty for help/advice :)
My campaign, Elvish Legacy
My inventively named Era
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Tricky WML (Clever people needed)

Post by zookeeper »

Longbow wrote:I have spent all evening trying different things to find out what is wrong... :x
Then figure out a more effective way of finding out what's wrong than reading the thing over and over again and changing random things. I'm not kidding. Read the sticky thread again if you've forgotten.
User avatar
DEATH_is_undead
Posts: 960
Joined: March 4th, 2007, 3:00 pm
Location: Northern United States

Re: Tricky WML (Clever people needed)

Post by DEATH_is_undead »

zookeeper wrote:
Longbow wrote:I have spent all evening trying different things to find out what is wrong... :x
Then figure out a more effective way of finding out what's wrong than reading the thing over and over again and changing random things. I'm not kidding.
Kind of cruel there, Zookeeper...

This might help with tags, if it is one.
3P MP Scenario - Great Dwarves Escape
The best way to learn is to follow. In order to learn WML, you have to follow other's work, and check their codes.
Post Reply