Conditional story parts & part components
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.
Conditional story parts & part components
I have not been able to get conditionals to work for story sections.
I am currently writing for 1.6 so cannot yet use [case] for this. So unless
I want to massively nest ifs I have to do without a catch-all else and just
exhaustively cover each and every possibility even while most of them
do not yet have their own custom screenshots and text.
I tried setting a variable to the path of the desired screenshot, but it
seems that the background value cannot be a $variable so I have to put
a whole part inside an if instead of just setting a variable inside the if.
I have tried the following with a test part first showing that nationality is
in fact one of the tested values (Argentine). If I wrap each page's huge
if inside its own story tag I can see a later story that has no if clauses.
So it looks like having an if at all not only fails to work but also prevents
even parts that have no if around them from being displayed.
Do I maybe have to use the ifs outside the story tag, putting entire stories
inside the ifs instead of just putting entire parts inside the ifs?
[story]
#
# First page: show your nations view if we have it else show main one for the planet
#
[if]
[variable]
name=nationality
equals="Afghani"
[/variable]
[then]
[part]
background=story/canadian.gif
story= _ "This is where your Mission Control area will be located if you become a rear echelon whatzit."
[/part]
[/then]
[/if]
[if]
[variable]
name=nationality
equals="Argentine"
[/variable]
[then]
[part]
background=story/argentine.gif
story= _ "This is where your Mission Control area will be located if you become a rear echelon whatzit."
[/part]
EDIT: evidently there must be a limit to the number of if tags you can enclose in a story tag. I finally stumbled upon the rather weird and unintuitive solution of wrapping each if inside its own story tag. Yeah I was that desperate... I'd tried everything that seemed it might make sense and was down to trying to debug seemingly silly theories as to why it didnt work.
-MarkM- ("knotwork"; Digitalis Data Services.)
I am currently writing for 1.6 so cannot yet use [case] for this. So unless
I want to massively nest ifs I have to do without a catch-all else and just
exhaustively cover each and every possibility even while most of them
do not yet have their own custom screenshots and text.
I tried setting a variable to the path of the desired screenshot, but it
seems that the background value cannot be a $variable so I have to put
a whole part inside an if instead of just setting a variable inside the if.
I have tried the following with a test part first showing that nationality is
in fact one of the tested values (Argentine). If I wrap each page's huge
if inside its own story tag I can see a later story that has no if clauses.
So it looks like having an if at all not only fails to work but also prevents
even parts that have no if around them from being displayed.
Do I maybe have to use the ifs outside the story tag, putting entire stories
inside the ifs instead of just putting entire parts inside the ifs?
[story]
#
# First page: show your nations view if we have it else show main one for the planet
#
[if]
[variable]
name=nationality
equals="Afghani"
[/variable]
[then]
[part]
background=story/canadian.gif
story= _ "This is where your Mission Control area will be located if you become a rear echelon whatzit."
[/part]
[/then]
[/if]
[if]
[variable]
name=nationality
equals="Argentine"
[/variable]
[then]
[part]
background=story/argentine.gif
story= _ "This is where your Mission Control area will be located if you become a rear echelon whatzit."
[/part]
EDIT: evidently there must be a limit to the number of if tags you can enclose in a story tag. I finally stumbled upon the rather weird and unintuitive solution of wrapping each if inside its own story tag. Yeah I was that desperate... I'd tried everything that seemed it might make sense and was down to trying to debug seemingly silly theories as to why it didnt work.
-MarkM- ("knotwork"; Digitalis Data Services.)
Re: Conditional story parts & part components
If you are doing something really advanced within the [story] based on WML variables, I suggest you first construct your story parts using WML array variable "parts" (in the previous scenario) and then insert the content with [insert_tag].
Code: Select all
[story]
[insert_tag]
name="part"
variable="parts"
[/insert_tag]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Re: Conditional story parts & part components
Hmm, interesting, thanks I'll have to take a look at that tag.
Currently I got the story stuff working but now it is looking like there might be a problem using [option] inside of a [message] that is inside an [if]...
..........................
[else]
[if]
[variable]
name=nation_extinct
equals=1
[/variable]
[then]
[message]
speaker=Mordrid
message= _ "At the present time the Institute does not feel that the loss of your nation was a wrongness in t$
[option]
message="&" + "units/minor-illusionist/shadow-mage.png" + "=" + _"If my people will accept that, great."
[command]
[message]
speaker=Mordrid
message= _ "Understand that you are here because your nation has not yet been expunged from our Freec$
[/message]
[message]
speaker=Tourist
message= _ "I understand. Lets do it."
[/message]
[message]
speaker=narrator
image=wesnoth-icon.png
..........................
Mordrid does say the line about the Institute not thinking its a wrongness in the timestream, but no options appear, its just plain dialog.
So evidently the nested ifs are choosing the correct message block to use, but the message block is ignoring its options.
(Copy/paste put $ where a line was too long to fit on screen)
-MarkM- ("knotwork"; Digitalis Data Services.)
EDIT: Wow, spooky, suddenly it works. No idea why but it does. Posting must be magickal.
Currently I got the story stuff working but now it is looking like there might be a problem using [option] inside of a [message] that is inside an [if]...
..........................
[else]
[if]
[variable]
name=nation_extinct
equals=1
[/variable]
[then]
[message]
speaker=Mordrid
message= _ "At the present time the Institute does not feel that the loss of your nation was a wrongness in t$
[option]
message="&" + "units/minor-illusionist/shadow-mage.png" + "=" + _"If my people will accept that, great."
[command]
[message]
speaker=Mordrid
message= _ "Understand that you are here because your nation has not yet been expunged from our Freec$
[/message]
[message]
speaker=Tourist
message= _ "I understand. Lets do it."
[/message]
[message]
speaker=narrator
image=wesnoth-icon.png
..........................
Mordrid does say the line about the Institute not thinking its a wrongness in the timestream, but no options appear, its just plain dialog.
So evidently the nested ifs are choosing the correct message block to use, but the message block is ignoring its options.
(Copy/paste put $ where a line was too long to fit on screen)
-MarkM- ("knotwork"; Digitalis Data Services.)
EDIT: Wow, spooky, suddenly it works. No idea why but it does. Posting must be magickal.
Re: Conditional story parts & part components
I got a new computer, installed Fedora 13 on it, and installed BfW from its package system, BfW 1.8.1-1.
The scenario with the conditional story stuff generates a segfault...
EDIT: turns out the [else][/else] container is mandatory in an [if] inside a [story]. It can be empty, but must exist...
-MarkM-
The scenario with the conditional story stuff generates a segfault...
EDIT: turns out the [else][/else] container is mandatory in an [if] inside a [story]. It can be empty, but must exist...
-MarkM-
- Attachments
-
- 05c_Space_Missions.cfg
- This scenario generates a segfault...
- (34.73 KiB) Downloaded 136 times
Re: Conditional story parts & part components
WML should never generate a segfault. Please report it on bugs.wesnoth.org
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."