[option] tag not working on a conditional clause.

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
Nyxl
Posts: 25
Joined: February 12th, 2006, 6:21 pm
Contact:

[option] tag not working on a conditional clause.

Post by Nyxl » March 31st, 2006, 10:43 am

The context :

I'm building a scenario with a few interactive choices. In one instance of multiple choices dialog, I want to have options displayed according to previous events.

The text example :

The player has the opportunity to discover a clue regarding a plot against an Empress. Later, he is talking to said Empress and has a choice for a few replies. If he has discovered aforementioned clue, he must have the opportunity to tell the Empress, as one of those replies.

The WML code that does not work :

Code: Select all

		[if]
			[variable]
				name=PlotWarning
				numerical_equals=1
			[/variable]
			[then]
				[message]
					speaker=Stregoi
					message= _ "Well..."
					{FEELINGS_PLOT}
					{FEELINGS_GENERIC}
				[/message]
			[/then]
			[else]
				[message]
					speaker=Stregoi
					message= _ "Well..."
					{FEELINGS_GENERIC}
				[/message]
			[/else]
		[/if]
The variable $PlotWarning and both Macroes FEELINGS_GENERIC and FEELINGS_PLOT (who only contain the [option/] tags with the specific actions) have been tested and proven correct in the same context, but without the conditional clauses.

What happens is that I get the "Well..." message, but no option, and the dialog continues after all the processes that should have occured due to a choice..

Existing reference :

I recall the Elven Council scenario in the "Raise of Wesnoth" campaign where a similar situation occurs. There isn't really a workaround of this trouble : the four choices of quest all appear each time one of those quests is completed...

Da question :

Does anyone know a clean workaround to this? I mean, how can I have all the options appear according to the conditional clause?

Thanks in advance if someone are willing to share their knowledge. And my apologies if this has been mentioned before.

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

Post by zookeeper » March 31st, 2006, 1:15 pm

What you're doing should work in my opinion. Perhaps you could post the contents of the macros and the event inside which all of this is, just to be sure?

Nyxl
Posts: 25
Joined: February 12th, 2006, 6:21 pm
Contact:

Post by Nyxl » March 31st, 2006, 2:40 pm

I have located the problem, I think.

The macroes were defined at the end of the very scenario.cfg file, and my guess is that those weren't loaded at the start of said scenario. So I put all those macroes in a separate /mycampaign/utils/dialogs.cfg file, and a generous testing of all usecases showed that it works fine now.

I love macroes. My apologies for the silly help request :P !

I'll post a more detailed solution later (probably this week-end), for I hope it will be useful to others as well (I'm still thinking of the Ka'lian in TRoW). :)

User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Post by Sapient » March 31st, 2006, 5:40 pm

Macros should always be placed before the place where they are used. That's why I usually put mine at the top of the file. I'll make a note on the wiki.
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."

Nyxl
Posts: 25
Joined: February 12th, 2006, 6:21 pm
Contact:

Doobeedoobeedah, promise kept.

Post by Nyxl » April 1st, 2006, 7:26 pm

Here is, as promised, the full solution I used to match clearly and cleanly my scenario specifications.

First, the snippet that triggers the "plot warning"...

Code: Select all

			[option]
				message= _ "I'll summon a wrathful spirit, those are more common than you might think, you'll see what I have endured since childhood..."
				[command]
					#summon Whilelmina's great-grand uncle, former Emperor who was murdered by his brother...
					[unit]
						type=Nightgaunt
						description="Hans"
						user_description="Hans IV"
						x=18
						y=11
					[/unit]
					[redraw]
					[/redraw]
#some dialog here
					[message]
						speaker=Hans
						message= _ "HA HA HA! Thou wisheth me gone? Thy wish shalt be granted! I have said what I had to say! Farewell. Heed my words, Empress! Thou art honourable, but some that aren't will try to overthrow thee!"
					[/message]
					[kill]
						description=Hans
						animate=yes
					[/kill]
					[redraw]
					[/redraw]
					[message]
						speaker=Whilelmina
						message= _ "That was... Interesting."
					[/message]
#end of dialog here
					[message]
						speaker=Whilelmina
						message= _ "Peace, Zukunft! Not another word from you. I asked for a demonstration, and I got it."
					[/message]
					#this earns Stregoi 1 point of relationship with Whilelmina.
					{VARIABLE_OP WhilelminaRelationship add 1}
					#this also warns the Empress that there's something afoot against her...
					{VARIABLE_OP PlotWarning add 1}
				[/command]
			[/option]
As you can see, this is an [option], already, among three of them. Interaction with the storyline(s) is very important in the campaign I'm trying to design.

Now, later in the same scenario, the hero Stregoi talks anew with the Empress and the Chancellor.

Code: Select all

#Here Stregoi is asked about his "feelings" about the previous conversation.
		[if]
			[variable]
				name=PlotWarning
				numerical_equals=1
			[/variable]
			[then]
				[message]
					speaker=Stregoi
					message= _ "Well..."
					{FEELINGS_PLOT}
					{FEELINGS_GENERIC}
				[/message]
			[/then]
			[else]
				[message]
					speaker=Stregoi
					message= _ "Well..."
					{FEELINGS_GENERIC}
				[/message]
			[/else]
		[/if]
Both {FEELINGS_GENERIC} & {FEELINGS_PLOT} are defined in a campaigns/Shade_Of_Grey/utils/dialogs.cfg file that I've already re-used to store similar macroes for similar situations. The directory is included in the [campaign] definition file.

Code: Select all

#define FEELINGS_GENERIC
	[option]
		message= _ "(You take things in good humour.)"
		[command]
			#Humour, that's something Whilelmina does not see often...
			{VARIABLE_OP WhilelminaRelationship add 2}
			[message]
				speaker=Stregoi
				message= _ "(Waves his hands dismissively.) All this nonsense while I have so much work to do. (Makes a comic face, looking at the ceiling.) Boo! And they summoned me from the Archives just to yell at me? Tsss..."
			[/message]
			[message]
				speaker=Whilelmina
				message= _ "(Suddenly giggling.) I guess you were enjoying yourself there!"
			[/message]
			[message]
				speaker=Stregoi
				message= _ "Heh. I guess there are more important things. But I'd really love to get back to my work..."
			[/message]
		[/command]
	[/option]
	[option]
		message= _ "(You mention your wounded pride.)"
		[command]
			#Whilelmina likes a strong sense of honour, loyalty.
			{VARIABLE_OP WhilelminaRelationship add 1}
			[message]
				speaker=Stregoi
				message= _ "I called that officer a *friend*, but a few hours ago. And now, he betrays me thus... It is not a pleasant feeling, your Majesty."
			[/message]
			[message]
				speaker=Whilelmina
				message= _ "That's understandable. You were right, by the way. It is Gunthar who told us about your power. In a very picturesque way."
			[/message]
			[message]
				speaker=Stregoi
				message= _ "It does not matter anymore. In a few hours, the whole palace will be aware. And I'm afraid people will be curious about the stranger that I am, now..."
			[/message]
		[/command]
	[/option]
	[option]
		message= _ "(You are scared.)"
		[command]
			#Chicken, chicken!
			[message]
				speaker=Stregoi
				message= _ "Well, to be honest, now I'm scared. It is clear that some would like to have me *removed*..."
			[/message]
			[message]
				speaker=Whilelmina
				message= _ "That's understandable. But do not worry, Stregoi, your life won't be at stake for that kind of reason, as long as I am Empress."
			[/message]
			[message]
				speaker=Stregoi
				message= _ "Let me insist on the fact I've always kept that ability a secret for all but Rebecca, until now. Precisely because I was fearing other people's reactions..."
			[/message]
		[/command]
	[/option]
#enddef

#define FEELINGS_PLOT
	[option]
		message= _ "(You express your concern about the Empress' fate.)"
		[command]
			#Woohoo, Whilelmina likes that a lot.
			{VARIABLE_OP WhilelminaRelationship add 3}
			[message]
				speaker=Stregoi
				message= _ "I feel concerned by what Hans the Fourth told us about people wishing your death, your Majesty."
			[/message]
			[message]
				speaker=Whilelmina
				message= _ "Why, that's commendable of you. I'm threatened on a daily base, but how much trust can we put in the words of a bitter ghost?"
			[/message]
			[message]
				speaker=Stregoi
				message= _ "Let me insist on the fact I've never been told lies by the dead..."
			[/message]
		[/command]
	[/option]
#enddef	
I'm not linking the whole files for two reasons :
1°) they're huge and, though documented, tedious to browse,
2°) I don't wish to disclose any of this before I have a real campaign to release.

Though now I have another question, more of code styling. It is better to put all macroes in separate files, in order to make the maintenance easier. But is it better to put those macroes in one relevant file per scenario or to organise those according to semantics (similar usage or similar effects)?

I'm currently using the second view, but the .cfg files are getting bigger and bigger with each scenario...

toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms » April 2nd, 2006, 5:23 am

I only found this thing on a short read:

Code: Select all

[kill] 
description=Hans 
animate=yes 
[/kill]
Better put the killed unit in a [filter].

Code: Select all

[kill]
animate=no
 [filter]
 description=Hans
 [/filter]
[/kill]
And, even if it should not cause an error, I would make a shorter variable name for WilhelminaRelationship.
First read, then think. Read again, think again. And then post!

Nyxl
Posts: 25
Joined: February 12th, 2006, 6:21 pm
Contact:

Post by Nyxl » April 2nd, 2006, 8:35 am

toms wrote:I only found this thing on a short read:

Code: Select all

[kill] 
description=Hans 
animate=yes 
[/kill]
Better put the killed unit in a [filter].

Code: Select all

[kill]
animate=no
 [filter]
 description=Hans
 [/filter]
[/kill]
I tried this on a previous scenario, with a similar situation where a ghost appears briefly. At the time, it killed all units. Now that I've gained some experience in WML, I'm wondering if I had not written "Description" instead of "description" in the [filter]. I'll try this some time soon, thanks for the reminder.
toms wrote:And, even if it should not cause an error, I would make a shorter variable name for WilhelminaRelationship.
Aye, I'll do that when I'm sure it all works. While I'm designing the campaign, I'd rather keep my "programmer names" as understandable as possible. When I'm done, it'll be all ctrl+h. :P

toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms » April 2nd, 2006, 9:48 am

I think I did not understand. The reason for the bug in the previous scenario was because of Description or you think you should try it to get it work?

(all WML keys are written without capitals)
First read, then think. Read again, think again. And then post!

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

Post by zookeeper » April 2nd, 2006, 10:16 am

No, don't put a [filter] inside [kill]. [kill] takes a standard unit filter, not a [filter] containing a standard unit filter.

User avatar
Casual User
Posts: 475
Joined: March 11th, 2005, 5:05 pm

Post by Casual User » April 4th, 2006, 2:21 am

zookeeper wrote:No, don't put a [filter] inside [kill]. [kill] takes a standard unit filter, not a [filter] containing a standard unit filter.
According to what logic was it decided which tags take a filter and which don't?

I like to think I've gotten more experienced with WML now, but I still regularly wipe out my units with a filtered [kill].

P.S. A campaign with more plot and intrigue and less "hack 'n slash" is exactly what we need. Hope you finish it, Nyxl.

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

Post by zookeeper » April 4th, 2006, 8:28 am

Casual User wrote:
zookeeper wrote:No, don't put a [filter] inside [kill]. [kill] takes a standard unit filter, not a [filter] containing a standard unit filter.
According to what logic was it decided which tags take a filter and which don't?

I like to think I've gotten more experienced with WML now, but I still regularly wipe out my units with a filtered [kill].
To me it looks like they've been decided pretty arbitrarily on a per-tag basis. It would be nice to have a consistent way of filtering units, but changing such fundamental syntax might still not be worth the trouble in the end.

Nyxl
Posts: 25
Joined: February 12th, 2006, 6:21 pm
Contact:

Post by Nyxl » April 4th, 2006, 1:11 pm

zookeeper wrote:
Casual User wrote: According to what logic was it decided which tags take a filter and which don't?

I like to think I've gotten more experienced with WML now, but I still regularly wipe out my units with a filtered [kill].
To me it looks like they've been decided pretty arbitrarily on a per-tag basis. It would be nice to have a consistent way of filtering units, but changing such fundamental syntax might still not be worth the trouble in the end.
I've examined the Wiki WML documentation. Everytime a [filter] tag is required, it is clearly mentioned. Elsewhere, it just says "standard [unit/terrain] filter". I'll rely on this for now. I guess a more standardized filter WMLization would be nice but hey, they did not build Roma in one day.

@Casual User : Well, I hope I'll be able to finish the first part of that campaign within the year...

Post Reply