Howdy, Stranger!

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

Disabling a link in all passages?

Hi! Nice forum.

Would it be possible, once a link has been visited, to disable it in all other passages? I could do this with variables, but I was wondering if I could alter the story settings somehow to avoid having to code each instance. To clarify, I would still want the text to appear, just not as a link. So, for example, if three separate passages all contained a link from the word tree that led to the same passage, the word tree would then not be highlighted should the player visit one of the others after following the link in one of them.

Sorry for the poorly worded question!


  • Hey, I see you made it over from Welcome! Hope someone can help you out.

    Unfortunately, as far as I know, there's no, like, "setting" that does as you wish. Variables, like you say, will do it.

    It's not quite what you're seeking, but there's the <<choice>> macro. I haven't used it, but from this quote, it seems like it does something similar: "choice is now usable in Sugarcane. It now creates a link that can only be clicked once in the whole story."

    There's also Leon Arnott's <<replace>> macro, but again, it's not quite what you want.

    Maybe someone will come along and offer more help than I'm able. :)
  • I'm not sure if you're wedded to a particular header, but SugarCube's <<link>> macro has that ability.
  • Edit: I'm realizing I didn't completely read your question.

    Seems like the easiest way to conditionally make the word "tree" a link would be with something like:

    <<if $variable>>tree<<else>>[[tree]]<<endif>>
    You can set a variable as Boolean and true by:
    <<set $variable>>
    I think using Twine's "Replace across entire story..." would make implementing the above trivial.

    Most of original post below:

    ...what about using find and replace to find all instances of the link you want to disable and replacing it with whatever code is needed to accomplish what you want?

    I just ran across this today and it seems pretty neat: you can give a variable a passage name and then make that variable your link.

    So you could code something up where, once the player follows the link, the variable changes to a different passage name, and from then on the link goes to that second passage.

    [quote]Passage One
    <<set $storedPassage = 'Passage One'>>
    [[Check Inventory|Inventory]]

    You have:
    + Item A
    + Item B
    <<print "[[Close Inventory|"+$storedPassage+"]]">>

    will render a link to your storedPassage (Passage One);"

    From: [url=!searchin/tweecode/find/tweecode/zU2FRmMbK14/vJZaBCYIbIYJ]here.

  • @TheMadExile

    Do you mean <<autolink>>? Google isn't helping me here.


    Oh nice, I never noticed 'replace across entire story', that does make things a bunch easier. Thanks!

    One more thing. Is there a way to treat all uninitialised variables as 0? Basically I'd like to avoid having to set the 'visited' variables for every passage to 0 at the start of the story.
  • According to the twine 1.4 release notes,

    [quote]All new variables are now 0 by default, regardless of whether you've set them or not. As for checking visited passages, you can try the
    function that gives a result of however many times you've visited the passage, so that e.g.
    <<print visited("Brewery")>>
    might give 2 if you've been to the Brewery passage twice. visited() on its own gives the results for the current passage.
    <<if visited() is 1>>
    checks if it's the first time you've been to the passage.
  • Thanks Birion, that's helpful stuff. And thanks everyone for the warm welcome! I will be pestering you with another question in around two minutes. ;)

    Edit: scrap that, I actually figured something out for myself!
Sign In or Register to comment.