0 votes
by (150 points)
Hello there,

I am quite new to both Twine and Sugarcube, so please forgive me any silly question.

I have been trying to find documentation about this, but I having a hard time to get the effect I wanted. What I am trying to accomplish is to propose the reader two links where to click. After choosing one of them, both links will disappear, and a paragraph is revealed instead, with no change in the current passage.

I have tried to play around with <<replacelink>>, <<linkreplace>>, and <<replace #output>>. While it's rather easy to accomplish with one link only, I can't find a way of replacing both links at the same time. <<choice>> seems to require another passage, and when I try to assign the current passage, it doesn't have really have the desired effect.

So I am a little stuck in this regard. I would really appreciate if someone could point me in the right direction.

1 Answer

0 votes
by (63.1k points)
selected by
 
Best answer

Something like this will probably work: 

Blah blah

@@#links;
<<link "Choice 1">>
    <<replace "#links">>\
       You chose 1. 
    <</replace>>
<</link>>
<<link "Choice 2">>
    <<replace "#links">>\
       You chose 2. 
    <</replace>>
<</link>>
@@

 

by (150 points)
This has worked perfectly, thank you very much.

So, if I understood well, you assigned a css class(?) called #links, which could have been anything else, and then you wrapped it around both replace macros.

In case this is true, I guess I could even control the look of it by calling its properties in the stylesheet, right?
by (63.1k points)
That's correct, but it's an id, not a class. An id is prefixed by a hash (#), while a class is prefixed by a dot (.). An element can have any number of classes, and multiple elements on the page can have the same class, but an id must be unique on the page, and an element can only have one id. In this case you can substitute a class for the id and the effect will be the same. I went with an id, though, because in this case we only want one element to be targeted and replaced.
by (150 points)
Brilliant, thank you very much for your reply! Much appreciated.
...