Howdy, Stranger!

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

[Harlowe] Help with basic/easy hyperlink syntax

edited March 2015 in Help! with 2.0
So given how new Twine 2.0 is, it seems the wiki/guide isn't yet very comprehensive. For the past two hours I've been going round and round in a loop trying to figure out some of the most basic commands, with zero success. And that's after reading the Harlowe documentation everyone keeps linking to. Maybe I'm just an idiot.

I feel like the best way to learn would be an uncompiled twine file so users can just dig in and see the code, then play/test to see the results of that code. Is something like that available yet? Or can someone post one?

Anyhow, what I've been trying to do is this:

1. Display two strings of clickable text.

2. When you click one choice, the other disappears, and new text appears advancing the story.

i.e.

"Which pill do you want to take?"

[The red pill] or [the blue pill]?

The user clicks [The red pill], and the words [the blue pill] disappears. Then some new text would appear on the next line, i.e.

"Your body starts convulsing uncontrollably! What action do you take?"

[Drink some water] or [call 911]?

I'd like a passage to be extended this way indefinitely, without players/readers ever being directed to a totally new passage/page. This is easy enough to do, right? Can someone explain how? And what is this type of linking/choosing "called"? I did forum searches, but I wasn't sure of the right terms.

Thanks in advance for any help.

Comments

  • In Twine 1.x there is a story format named Jonah which appears as a "Continuous Page", where each new passage appears below the existing one. I don't know of a Twine 2.x story format that works this way but by using Harlowe's (display:) macro you can get something that at least looks similar.

    The following code consists of three passages, the first asks the pills question using (link:) macros, and then based on which link the Reader chooses replaces the pills question with the contents of another passage using a hook, and the (replace:) / (display:) macros.

    (note: the following uses TWEE notation, lines starting with two colons indicate a new passage, text on same line as the two colons is the new passage's title.)

    :: Start
    Which pill do you want to take?

    |pills>[(link: "The red pill")[(replace: ?pills)[(display: "The red pill")]] or (link: "the blue pill")[(replace: ?pills)[(display: "The blue pill")]]]


    :: The red pill
    The red pill!

    Your body starts convulsing uncontrollably! What action do you take?

    [Drink some water] or [call 911]?


    :: The blue pill
    The blue pill!

    Whatever you want to appear when they take the blue pill!
    The following is a copy of the Start passage from above formatted to make reading easier:

    |pills>[
    (link: "The red pill")[
    (replace: ?pills)[
    (display: "The red pill")
    ]
    ] or
    (link: "the blue pill")[
    (replace: ?pills)[
    (display: "The blue pill")
    ]
    ]
    ]
  • Thanks greyelf, that's beautiful, exactly what I needed.

    This was very educational, loading this up and being able to see the results.
  • I'm sorry to intrude, but this code is for Twine 2.0? I tried and didn't get anything. I'm trying to make a sms conversation on my game and this tool of having the text appearing on the screen without leaving the page is perfect. Can you get me a quick run on how to make macros work (please)?
  • My code example is meant to be used with the Twine 2 Harlowe story format, which is the default story format for Twine 2.

    The example consists of three separate passages:

    1. Start

    Which pill do you want to take?

    |pills>[(link: "The red pill")[(replace: ?pills)[(display: "The red pill")]] or (link: "the blue pill")[(replace: ?pills)[(display: "The blue pill")]]]
    This passage contains two (link:) macros which when clicked run the code contained within the associated [] code block.
    Both of the (link:) macros are wrapped within a hook named pills, the hook is the part that looks like:

    |pills>[ ........ ]
    Each of the (link:) macros contains a (replace:) macro, these macros are going to replace the contents of the pills hook with whatever is contained within the (replace:) macro's associated code block:
    (replace: ?pills)[ .... ]
    Contained within each (replace:) macro is a (display:) macro which is used to insert the contents of a different passage into the Start passage.

    2. The red pill
    This passage contains the text which is going to be inserted into the Start passage if the The red pill link is clicked.

    The red pill!

    Your body starts convulsing uncontrollably! What action do you take?

    [Drink some water] or [call 911]?
    3. The blue pill
    This passage contains the text which is going to be inserted into the Start passage if the The blue pill link is clicked.

    The blue pill!

    Whatever you want to appear when they take the blue pill!
    I hope that helps
Sign In or Register to comment.