If you are requesting technical assistance with Twine, please specify:
Twine Version: 2.5.1
Story Format: Sugarcube 2.36.1
I want a link that can go to different passages depending on state, but not evaluate that state until right when the link is clicked. I don’t think I’m formatting my destination passages correctly, but maybe there are some other errors on top of that .
Then I also have a passage named “xFlowers” and a passage named “cFlowers”
A more general question is this: If I want to create nearly every link so that it parses different outcomes depending on the current value of $nextaction, is this really the best way to do it?
I am imagining a system where each link is an object which knows its own Explore and Cast functions. Or is that something that requires fiddling with the core javascript?
As for a more efficient way to do this for multiple links, it really depends on how exactly each link works. Extrapolating from this example and saying you want each link to send you to xPassage or cPassage depending on the value of $nextaction, you could do it with a widget. Create a new passage, tag it widget (and possibly nobr to avoid extraneous line breaks), and paste this in it:
Now you can create a link like the one above by typing <<macroName "LinkName" "Passage">><</macroName>>.
Or, if you might want the destination passages to have different names, you can change the <<goto>> macros to <<goto _args[1]>> and <<goto _args[2]>> respectively, then create your link by typing <<macroName "LinkName" "explorePassage" "castPassage">><</macroName>>.
Did you test the widget thing? Because when I tried it, the goto happened immediately, not when the link was clicked. I think that’s a SugarCube bug, but…
That’s because using <<goto>> to automatically forward the player somewhere else immediately upon reaching a passage breaks history navigation. If you’re using it inside a link there’s no problem.