Displaying objectives conditionally
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.
-
- Posts: 31
- Joined: December 8th, 2008, 12:24 am
Displaying objectives conditionally
I'm working on a scenario with a total of 5 victory objectives. I'd like to be able to display just the objectives that haven't yet been met, but using [if] within an [objectives] tag doesn't work.
Is there any way to cause an objective to display only if a variable has a certain value?
(The alternative I see is to use 32 [if]s to cover all the possible sets of active objectives. For some reason, I'm not enthusiastic about that option.)
Is there any way to cause an objective to display only if a variable has a certain value?
(The alternative I see is to use 32 [if]s to cover all the possible sets of active objectives. For some reason, I'm not enthusiastic about that option.)
Re: Displaying objectives conditionally
No.Cheradenine wrote:I'm working on a scenario with a total of 5 victory objectives. I'd like to be able to display just the objectives that haven't yet been met, but using [if] within an [objectives] tag doesn't work.
Is there any way to cause an objective to display only if a variable has a certain value?
There's another alternative, but it'd be somewhat complicated and you'd have to figure out how to do it: use a single multi-line string to list several objectives (like, all the victory objectives in one string) and construct those strings before displaying the objectives using a bunch of [if]s.Cheradenine wrote:(The alternative I see is to use 32 [if]s to cover all the possible sets of active objectives. For some reason, I'm not enthusiastic about that option.)
Pseudocode:
Code: Select all
if obj1 then {VARIABLE victory_objectives_string _"Mike moves to the signpost"}
if obj2 then {VARIABLE_OP victory_objectives_string "$victory_objectives_string
@Defeat all enemy leaders"}
if obj3 then {VARIABLE_OP victory_objectives_string "$victory_objectives_string
@Survive until end of turns"}
etc.
[objectives]
[objective]
description=$victory_objectives_string
condition=win
-
- Posts: 547
- Joined: August 11th, 2008, 3:19 pm
Re: Displaying objectives conditionally
yeah, this is something I'd like to see changed myself; I had a similar difficulty, but since there were only two conditions, I only had a set of four objectives to write.
--OSJ
Edit: here was a forum post in the ideas forum concerning the same thing. It had an interesting idea about using [insert_tag] as well.
--OSJ
Edit: here was a forum post in the ideas forum concerning the same thing. It had an interesting idea about using [insert_tag] as well.
what if the Bible's claims about Christ depicted accurate, verifiable history? given some research, you might be surprised at the evidence...
-
- Posts: 31
- Joined: December 8th, 2008, 12:24 am
Re: Displaying objectives conditionally
Thanks! I couldn't quite get it working (I could build the string, but only the first line would appear green in the objectives window) but it suggested another kludgey approach that was still better than the "32 if statements" option. (I built an array of the appropriate objectives and then formatted the objectives window based on the length of the array. So it took 5 if statements instead of 32.)
-
- Posts: 547
- Joined: August 11th, 2008, 3:19 pm
Re: Displaying objectives conditionally
much nicer
--OSJ
--OSJ
what if the Bible's claims about Christ depicted accurate, verifiable history? given some research, you might be surprised at the evidence...