0 votes
by (210 points)

I know I ask a lot of quetions... it's just because I'm very ambitious with my game, but don't know much about code yet- sorry...

What I'm trying to do is have only one clickable go-to-passage link appear at a time, depending on whether or not a variable is set.. here's an example of what I've tried: 

<<if $variable is 1>>[normal text goes here|page5]<</if>>
<<if $other variable is 1>>[altered text goes here|page5]<</if>>

Now, a friend of mine said this might not work.. whivh is fine. I can just make a page6 with the exact same information as page 5, have the "altered text" link to to page6 and normal go to page5 then have them both link to page7 after. That's fine. But my problem is that either they both appear at once, neither appear and in DebugMode it only shows the "if" statements- not even the links inside, just the if(and in non-degub mode it just has empty space there) or only one link appears and it doesn't switch to the other link/link-text ever, even with the variable set.

1 Answer

0 votes
by (68.6k points)

You have a few issues:

  1. If you only want one of those links to show, then you probably should be using one <<if>> macro, with an <<elseif>> subclause, rather than two.
  2. Your second variable is invalid.  Variable names may not contain whitespace.
  3. Your links are invalid.  Link markup uses two opening and closing square brackets.

Try something like the following:

<<if $variable is 1>>
[[text goes here|some passage]]
<<elseif $otherVariable is 1>>
[[alternate text goes here|some other passage]]
<</if>>

 

by (210 points)
It still doesn't appear to be working.. is there somewhere that I can privately send code? Maybe you can make heads/tails of it?
by (68.6k points)

Assuming you mean either the project file or the compiled file, you may PM me (TheMadExile#6503) on the Twine Games Discord if you feel the need to privately send me the file, elsewise uploading to one of the many filesharing services (e.g., Google Drive, Dropbox, OneDrive, etc) and posting a share link here would work just as well.

by (44.7k points)
Also, Leon, please do not lock your threads here.  You should select an answer as the best answer instead.

I wrote a note about an error in your code in your last question, and somewhere between the time I started writing and the time I tried to post my note, you locked your thread, leaving me no way to point out the error to you.

Thanks.
by (210 points)
Exile, thank you very much and I have messaged you on Discord. I will send code shortly. A thousand thanks.

HiEv, I apologize for that. I had thought that was standard, to lock  a thread after it was finished. I suppose I should have waited though, or left open in ccase other members had tips or questions of their own of similar nature
...