Iām just wondering how Iād make it so that variable āappearsā inside the āeitherā passage so itās like someone finds it or does not, depending on that.
Like maybe I should set the variable to being ātrueā or something?
What Iāve done right now is Iāve put:
<<if $passage is true>>The Passage is here!
You spot the Passage!
<<else>>No sign of the passage here!
<</if>>
<<if $passage>>The Passage is here!
You spot the Passage!
<<else>>No sign of the passage here!
<</if>>
Iām struggling. The code either makes it not appear in both and appear in both.
The premise is basically someone is hunting for the right thing and I want it to be either one or the other, but not both. So the player has a 50/50 chance of finding it (hence why I wanted to try and get the random thing used).
Assuming youāre using TMEās example to set $passage, the first of your codes snippets will always fail because a string assignment isnāt going to equal true. The second one will always pass because any string that isnāt empty (not "" in other words) is truthy, so <<if "bleh">> will pass.
So what you need to do is something like
<<if $passage is "passage a">>
Be sure to either match the case exactly or use $passage.toLowerCase() instead.
Variables with a $ (example: $passage) are story variables, once set they will be part of the whole story, or until unset.
Variables with a _ (example: _passage) are passage variables, they are set inside a passage and automatically deleted when the user hit a link or button leaving the passage.
If I understand you correctly, you want the player to be sent to a random passage. Hereās one way to do so.
Given Passage 1 and Passage 2 created.
<<set _advance to random(1,2)>>
<<if _advance == 1>><<set _passage to "Passage 1">><<else>><<set _passage to "Passage 2">><</if>>
<<link "You venture forth" _passage>><</link>>
Ok folks Iām trying but this is still being a PITA.
Iām not getting errors but itās just showing the āelseā bit and never the true bit.
<<set $passage to either("Passage1", "Passage2") >>
Which corridor do you take?
[[Head down the left corridor!|Passage1]]
or
[[Head down the right corridor!|Passage2]]
You follow the bright corridor that winds around on itself and see....
<<if $passage is "passage1">><<set $passage to true>><</if>>
<<if $passage is true>>The thing is here and up ahead of you!
You race closer to try and stop it!
[[Continue|Magazine - Agent Sighted!]]
<<else>>No sign of him here!
[[Continue|Magazine - Hear the Agent!]]<</if>>
You follow the dark corridor that winds around on itself and see....
<<if $passage is "passage2">><<set $passage to true>><</if>><<if $passage is true>>The thing is here and up ahead of you!
You race closer to try and stop it!
[[Continue|Magazine - Agent Sighted!]]
<<else>>No sign of him here!
[[Continue|Magazine - Hear the Agent!]]<</if>>
I think itās just that youāre setting the variable to āPassage1ā (capital āPā) and then checking if itās āpassage1ā (lowercase āpā).
As a side note, if you plan to keep the same flavour text for each corridor, and if they point to the same exits, you donāt need two passages, but only one.
Which corridor do you take?
[[Head down the left corridor!|Corridor]]
or
[[Head down the right corridor!|Corridor]]
<<set _passage to either(1,2) >>
You follow the bright corridor that winds around on itself and see....
<<if _passage==1>>The thing is here and up ahead of you!
You race closer to try and stop it!
[[Continue|Magazine - Agent Sighted!]]
<<else>>No sign of him here!
[[Continue|Magazine - Hear the Agent!]]<</if>>