Options

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
tribes55
Posts: 119
Joined: June 10th, 2012, 4:29 am

Options

Post by tribes55 » July 16th, 2018, 4:25 am

Hello,

I'm currently trying to make an event where when a particular unit reaches a location, the player is prompted with the ability to change the type the unit is. However, it isn't working; I was using a mainline campaign as a reference, specifically HttT's Bay of Pearls, but I don't know what I'm doing wrong. I looked here https://wiki.wesnoth.org/OptionWML , but I'm not sure if this is applicable.

Here's what I got going for me:

Code: Select all

[event]
	name=moveto
	[filter]
		id=Squid
		[filter_location]
			[filter]
				id=Smith
			[/filter]
			radius=1
		[/filter_location]
	[/filter]
	[message]
		speaker=Squid
		message= _ "Er.. I was told to come to you for some weapons?"
	[/message]
	[message]
		speaker=Smith
		message= _ "Aye, youngen. We got some armor designed for ye folk outtdere. Ancient. Can get ya some o' dat. Longbow and sword."
	[/message]
	[option]
		label= _ "Yeah, I've always wanted to be an archer!"
		[command]
			[modify_unit]
				id=Squid
				type=Longbowman
			[/modify_unit]
			[message]
				speaker=Squid
				message= _ "Cool!"
			[/message]
		[/command]
	[/option]
	[option]
		label= _ "No, I think I prefer my current fighting style."
		[command]
			[message]
				speaker=Smith
				message= _ "Suit yerself."
			[/message]
		[/command]
	[/option]
[/event]
Thanks!

User avatar
Ravana
Moderator
Posts: 1886
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Options

Post by Ravana » July 16th, 2018, 9:15 am

You linked to [options] that goes under [campaign], [era], [multiplayer] or [modification] tag. Not [event].

You want [option] instead https://wiki.wesnoth.org/InterfaceActio ... message.5D.

User avatar
beetlenaut
Developer
Posts: 2256
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Options

Post by beetlenaut » July 16th, 2018, 1:42 pm

Read "Notes about Radius Usage" in the Standard Location Filter. I think you are having the problem they talk about there: Your [filter] tag seems to check to make sure that the id of the moving unit is Squid, then it checks to make sure that the id of the unit on the moving unit's location is Smith. If that hex exists (which of course it can't) it finds all hexes one hex away from it. Actually though, it sounds like you could use [filter_adjacent], which is easier anyway.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide

enclave
Posts: 909
Joined: December 15th, 2007, 8:52 am

Re: Options

Post by enclave » July 16th, 2018, 5:51 pm

tribes55 wrote:
July 16th, 2018, 4:25 am

Code: Select all

[filter]
		id=Squid
		[filter_location]
			[filter]
				id=Smith
			[/filter]
			radius=1
		[/filter_location]
	[/filter]
I'm not 100% sure, but try to change this into:

Code: Select all

[filter]
		id=Squid
		[filter_location]
[and]
			[filter]
				id=Smith
			[/filter]
[/and]
			radius=1
		[/filter_location]
	[/filter]
To be honest I think your filter should work as it is..

I think your real problem is that you have:
[event]
name=moveto
but you don't have first_time_only=no

So your event will never work.. It filters the first moveto accurance, and then it doesnt do anythign anymore.

tribes55
Posts: 119
Joined: June 10th, 2012, 4:29 am

Re: Options

Post by tribes55 » July 16th, 2018, 11:47 pm

I have found the solution to my problem; [Option] is a subtag of the [message] tag and I was not using it appropriately.

Regarding first_time_only=yes, I'm glad you pointed that out! I don't want this event firing multiple times, either. That'd be strange. :lol:

Also, I will read about the radius thing, but it does seem to be working accordingly. I have had a tough time understanding some errors with filters, so I think it's about time I sit down and give it a read.

Here are the corrections I have made.

Code: Select all

event]
	name=moveto
	[filter]
		id=Squid
		[filter_location]
			[filter]
				id=Smith
			[/filter]
			radius=1
		[/filter_location]
	[/filter]
	[message]
		speaker=Squid
		message= _ "Er.. I was told to come to you for some weapons?"
	[/message]
	[message]
		speaker=Smith
		message= _ "Aye, youngen. We got some armor designed for ye folk outtdere. Ancient. Can get ya some o' dat. Longbow and sword."
		[option]
			label= _ "Yeah, I've always wanted to be an archer!"
				[command]
					[modify_unit]
					[filter]
						id=Squid
					[/filter]
					type=Longbowman
					[modifications]
						{TRAIT_DEXTROUS}
						{TRAIT_QUICK}
					[/modify_unit]
					[message]
						speaker=Squid
						message= _ "Cool!"
					[/message]
				[/command]
		[/option]
		[option]
			label= _ "No, I think I prefer my current fighting style."
			[command]
				[message]
					speaker=Smith
					message= _ "Suit yerself."
				[/message]
			[/command]
		[/option]			
	[/message]
[/event]
Thanks to all who helped.

enclave
Posts: 909
Joined: December 15th, 2007, 8:52 am

Re: Options

Post by enclave » July 17th, 2018, 12:33 pm

tribes55 wrote:
July 16th, 2018, 11:47 pm
Regarding first_time_only=yes, I'm glad you pointed that out! I don't want this event firing multiple times, either. That'd be strange. :lol:
Ah actually you are right probably.. you need it at yes state.. For some reason I thought it would fire for any moveto.. but it will only fire when filter catched it.. I'm quite sure in this case you have eveything right, default is "yes" so you don't need to write first_time_only=yes, its already assumed.. but I guess having it there doesnt hurt :)
I misunderstood your initial question completely.. didn't read it through :) I thought u having problems that nothing was working at all, but now I realized it was only [option] wasnt going inside [message] tags :) sorry for all confusion answers :D glad you helped your self :DDDDDDD

Post Reply