Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Deactivating Link

I've been playing around choice links and it does what it does.
What about if I just want to deactivate a link once it was clicked? And the other links are not affected?
Because
<<choice ...>>
deactivates the other choice links too.

Using:
Twine 2.1.0(Download - MacOS)
SugarCube 2.16.0

Comments

  • Maybe look into <<linkreplace>> in the Sugarcube Docs? That's a single click link which won't be useable - but you do have to make sure it's not a forwarding type of link, otherwise, I believe. (Meaning the link won't take you to another passage). If others have a better idea, chime in :)
  • I'm pretty sure <<actions>> does essentially what you're asking, though I could be misunderstanding you.
  • edited March 2017
    If the player may revisit the passage in question, then you'll need to track the state of the link with a story variable and wrap it within an <<if>> for control. For example:
    → Using the <<link>> macro.
    <<if $usedLeftPath>>Left Path<<else>><<link [[Left Path]]>><<set $usedLeftPath to true>><</link>><</if>>
    
    → Using a setter link.
    <<if $usedLeftPath>>Left Path<<else>>[[Left Path][$usedLeftPath to true]]<</if>>
    


    If the player cannot revisit the passage, then you could probably get away with using one of the combo link macros: <<linkappend>>, <<linkprepend>>, <<linkreplace>>.
  • Chapel wrote: »
    I'm pretty sure <<actions>> does essentially what you're asking, though I could be misunderstanding you.
    It does, as long as one is willing to accept the unordered list it wraps the links within.
  • @mega01man: Is the link meant to stay deactivated when the reader returns to the passage containing the choices?

    If so then you will need track the state of each of the links, two ways to do this are:

    1. Use the hasVisited() function to check if the target passage has been visited yet, this method only works if the target passage for each link is different.
    <<if not hasVisited("Next A")>>[[link A|Next A]]<<else>>link A<</if>>
    <<if not hasVisited("Next B")>>[[link B|Next B]]<<else>>link B<</if>>
    <<if not hasVisited("Next C")>>[[link C|Next C]]<<else>>link C<</if>>
    


    2. Use variables to track if the associated link has been used.
    <<if not $linkA>>[[link A|Next][$linkA to true]]<<else>>link A<</if>>
    <<if not $linkB>>[[link B|Next][$linkB to true]]<<else>>link B<</if>>
    <<if not $linkC>>[[link C|Next][$linkC to true]]<<else>>link C<</if>>
    
    NOTE: You need to set the related variables to false before the passage containing the links is visited, ideally this is done in your StoryInit special passage like so.
    <<set $linkA to false>>
    <<set $linkB to false>>
    <<set $linkC to false>>
    
  • edited March 2017
    greyelf wrote: »
    2. Use variables to track if the associated link has been used.
    […]
    NOTE: You need to set the related variables to false before the passage containing the links is visited, ideally this is done in your StoryInit special passage like so.
    […]
    While I, normally, strongly encourage the initialization of story variables, as long as the story variables in question are only used to deactivate the links—i.e. they're not checked anywhere else—initialization may be skipped in this case, as undefined variables are falsy in a boolean context.
  • Thank you very much for the answers!
    I'm sorry for the incomplete question. Yes, the player will revisit the passage.

    I'm trying to make a small jeopardy game. I used one passage for displaying the questions and one passage for displaying the answers. Each questions and answers have their own passages. I used variables to change which passages to display, I used the include macro.

    I'm going to use the variables method. I'm thinking of also using arrays, but I don't think I have time or skills for that yet. I'll just improve the game later. XP

    Thank you again for the answers!

    (PS. I'm pretty sure I clicked the Ask a Question button, but my post still ends up as a discussion ?)
  • initialization may be skipped in this case
    *smile* I guess I'm just old-school and that manual initialisation is just too ingrained.

    That and seeing too many cases (both my own but mostly other peoples) over the last 35 yrs where relying on a system to consistently set defaults and not doing your own initialisation has lead to problems.
Sign In or Register to comment.