Hi,
I'm using Twine 2.2.1 Sugarcube 2.21.0
What I'm trying to do is have a dialogue tree where the player would be presented with several choices. If the player were to select one choice, it can change a variable which causes another choice to appear. I attempted this with the <<replace>> macro.
The problem I ran into is that, since the passage doesn't update, the new choice doesn't appear. My solution to this was to nest <<replace>> but that is heavily limiting and makes the code look awful.
This is what I've come up so far with nesting <<replace>> macros:
<span id="dialogue1">Replace Me</span>
<<link "1">>
<<replace "#dialogue1">>
Choice 1
<</replace>>
<</link>>
<<link "2">>
<<replace "#dialogue1">>
Choice 2
<</replace>>
<</link>>
<<link "3">>
<<replace "#dialogue1">>
Choice 3
<</replace>>
<</link>>
<<link "4">>
<<replace "#dialogue1">>
4
<<replace "#dialogue2">>\
<<link "5">>
<<replace "#dialogue1">>
5
<</replace>>
<</link>>
<</replace>>
<</replace>>
<</link>>
<span id="dialogue2">Choice 5 goes here</span>
I'd like it to work something like this:
<span id="dialogue1">Replace Me</span>
<<link "1">>
<<replace "#dialogue1">>
Choice 1
<</replace>>
<</link>>
<<link "2">>
<<replace "#dialogue1">>
Choice 2
<</replace>>
<</link>>
<<link "3">>
<<replace "#dialogue1">>
Choice 3
<</replace>>
<</link>>
<<link "4">>
<<replace "#dialogue1">>
4
<<set $choice5 = 1>>
<</replace>>
<</link>>
<<if $choice5 == 1>>
<<link "5">>
<<replace "#dialogue1">>
5
<</replace>>
<</link>>
<<endif>>
It would make dialogue incredibly simple to create and offer limitless potential for complex trees.
While I know that Twine isn't meant to be used with a single passage, this not only makes the dialogue trees cleaner and simpler but it also makes my entire dialogue system easier to implement. I am practically new to JavaScript and HTML but have some experience in programming so I should be able to try out any solution you may offer.
Thanks in advance.