Howdy, Stranger!

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

Different types of links, help!

Hi there! first off, I am a newbie to Twine and CSS (and Java and HTML...) this forum and all the documentation has been incredibly helpful but I'm still struggling with some things that seem very opaque to a beginner. I usually work coding stuff out by reverse engineering, inspecting the element in browser or just googling my question, but haven't been able to do that with this problem.

I'm using Harlowe, Twine 2.0 on iOS

I've got how to link to a new passage - putting it in double square brackets - What I want to do is have the user click on a word, and the text display underneath, rather than take them to a new passage. I think I've figured out how to replace a hook, like below, but ideally I'd like the text to appear underneath.

|slip>[slip it from my shoulders.]
(click:?slip)[(replace:?slip)[Enough!]]

I know this is possible as I've seen it done, would be great to get an answer!

A bonus question is in the code of other Twines there is a thing called .enchantment-link - is that different to a tw-link?

Any help much appreciated :)

Comments

  • Instead of using a (click:) macro to create your link, use a (link:) or (link-repeat:) macro instead.
    (link: "Click Here 1")[(append: ?output)[Hello World]]
    
    (link-repeat: "Click Here 2")[(append: ?output)[Hello World]]
    
    |output>[]
    

    re: .enchantment-link
    All the different ways to create links (markup, macros, named hooks) generally result in one of two different sets of HTML elements being created. The tw-link element is part of one set and the .enchantment-link class is part of the other.

    eg. the above (link:) macro results in a tw-link element, where as your (click:) macro results in a tw-enchantment element with a class of .enchantment-link
  • Thanks, I think I understand or am at least getting there :)
  • Actually, what if I wanted to have two or more of these links, and assign them different outputs, so clicking them doesn't create repeated outputs?

    I would also ideally have links appearing in the ouput as well, if that makes sense? So a new paragraph would appear on the click, with it's own link in it....
  • Just add more named hooks (each with it's own unique name) to the passage and use them as targets of different (append:) macros.
    (link: "Click Here 1")[(append: ?output1)[Hello World]]
    
    (link-repeat: "Click Here 2")[(append: ?output2)[{
    Some text that include a (link: "link")[] in it.
    }]]
    
    (link-repeat: "Click Here 3")[
    	(append: ?output3)[
    		(display: "The contents of a different passage")
    	]
    ]
    
    
    |output1>[]
    
    |output2>[]
    
    |output3>[]
    
  • Thanks for your help! I found the display: option the most useful/easy to use for my purposes. Cheers!
Sign In or Register to comment.