Howdy, Stranger!

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

Click and Append in Twine 2, Sugarcube 2

I used Twine 2 + Sugarcube 2 for Ludum Dare over the weekend, and ran into a problem with <<click>> and <<append>>.

My goal is to show a conversation unfold, where each paragraph ends with a clickable > that adds the next line of the conversation below it. I was able to get this 95% working with <<click>> and <<append>>. The problem is that you can click the > multiple times and get the text to repeat down the page. I tried nesting a <<remove>> in the <<click>> but it didn't seem to work because the <<click>>s themselves are nested--so removing the first also removes the code that makes subsequent <<click>>s work.

Is there an easier way to accomplish this? Here's a sample of how I have it implemented without the <<remove>> (the version that repeats text if you click > more than once).

Thanks!

"It's ugly as sh..." The girl begins but a hissed "Iris!" from her mother cuts off the profanity midway.<<click " >">>
<<append "#conv1">>"Can I look around?" the boy asks, and he's already looking through the doorway into the small downstairs bathroom. <<click " >">>
<<append "#conv2">>"Yes, but we won't be here long today. This is just to see if there's anything we need to fix or replace before we move in next week."<<click " >">>
<<append "#conv3">>The boy pelts upstairs immediately. The mother looks at Iris, then smiles. "Check the downstairs with me?"<<click " >">>
<<append "#conv4">>Iris shrugs. "Sure." The pair walk into the living room together. You DFoyer P1_T1 them leave.
<</append>><</click>>
<</append>><</click>>
<</append>><</click>>
<</append>><</click>>

<span id="conv1"></span>
<span id="conv2"></span>
<span id="conv3"></span>
<span id="conv4"></span>

Comments

  • edited April 2016
    First. Please use the code block when you're posting code (it's the C on the editor toolbar).


    You simply need to nest your <<click>> macros within the <span> elements and use <<replace>> instead of <<append>>. With that setup, each nested chuck of content will replace its parent <<click>>, thus allowing it to be clicked only once.

    For example:
    "It's ugly as sh..." The girl begins but a hissed "Iris!" from her mother cuts off the profanity midway.
    
    <span id="conv1"><<click " >">><<replace "#conv1">>"Can I look around?" the boy asks, and he's already looking through the doorway into the small downstairs bathroom.
    
    <span id="conv2"><<click " >">><<replace "#conv2">>"Yes, but we won't be here long today. This is just to see if there's anything we need to fix or replace before we move in next week."
    
    <span id="conv3"><<click " >">><<replace "#conv3">>The boy pelts upstairs immediately. The mother looks at Iris, then smiles. "Check the downstairs with me?"
    
    <span id="conv4"><<click " >">><<replace "#conv4">>Iris shrugs. "Sure." The pair walk into the living room together. You [[watch|DFoyer P1_T1]] them leave.
    <</replace>><</click>></span>
    <</replace>><</click>></span>
    <</replace>><</click>></span>
    <</replace>><</click>></span>
    
  • First. Please use the code block when you're posting code (it's the C on the editor toolbar).

    You simply need to nest your <<click>> macros within the <span> elements and use <<replace>> instead of <<append>>. With that setup, each nested chuck of content will replace its parent <<click>>, thus allowing it to be clicked only once.

    Thank you so much for providing this example. The documentation didn't make sense at all. I did manage to get the Click macro working but the replace was still giving me issues until I saw this example. :) Thanks again :)
Sign In or Register to comment.