Howdy, Stranger!

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

Displaying additional text within same passage

Hi there,

New to Twine and still trying to figure out some basics. I'm using Sugarcube and Twine 2.0. One of my passages has the following text:

Day
after
Day
after
Day

For this, I'd like to start with just the first 'Day' showing. Clicking on it would reveal the 'after' below, which would be a link to the next 'Day', and so forth (all within the same passage). I've been trying to use a combination of <<click>> and <<replace>>, but I'm get an error (I think because I'm trying to replace with another <<click>>, as it works fine if I just reveal plain text).

Is there any way to get this to work?

Comments

  • There are two different flavours of SugarCube, which are SugarCube 1 and SugarCube 2, knowing which you are using can help because there are differences between the two.
    I am going to assume you are using the version of SugarCube 1 which comes with Twine 2.0.10.

    There are a number of ways to do what you want, the following example consists of five passages: Start, Day 1, Day 2, Day 3, Day 4

    a. Start
    <div id="output"><<display "Day 1">></div>
    
    b. Day 1
    <<click "Day">><<replace "#output">><<display "Day 2">><</replace>><</click>>
    
    c. Day 2
    after day 1
    <<click "Day">><<replace "#output">><<display "Day 3">><</replace>><</click>>
    
    d. Day 3
    after day 2
    <<click "Day">><<replace "#output">><<display "Day 4">><</replace>><</click>>
    
    e. Day 4
    just keep repeating
    
    ... as you can see you store what you want displayed for each day in it's own passage and then use a <<replace>> macro to <<display>> the relevant passage.

    note: If you are planning to use the above to emulate the Jonah story format or to make your story one long page then be aware that doing so will mean that your story will have no History which means that the reader will not be able to undo a selection and that it may also effect the Save feature of SugarCube.
  • You may find a click counter easier to follow:

    Wait:

    <<if $count is 0>>Wait][$count to $count + 1<<else>Day <<endif>>
    <<if $count is 1>>Wait][$count to $count + 1<<else>After<<endif>>
    <<if $count is 2>>Wait][$count to $count + 1<<else>Day<<endif>>
    <<if $count is 3>>Wait][$count to $count + 1<<else>After<<endif>>
    <<if $count is 4>>Elsewhere][$count to $count + 1<<else>Day<<endif>>

    If you're going to reuse it you need to reset $count to 0 before you call it...
Sign In or Register to comment.