I have links in my storymenu which open passages (standard) but then I want them to alter their function to switch back to the last story passage when clicked again.
How can I do this?
I'm guessing I'd have to use tags in non-story passages (like stat sheets and maps) that identify them as such with an if statement attached to the storymenu link, asking if I'm in a non-story passage.
Thanks in advance!
I'm currently using Sugarcube 2 or just Sugarcane.
Comments
For example, let's say I made an RPG in Twine and wanted to have help files that are passages that are linked in other passages that have elements I want explained to the players. I put the following link in one of those help passages:
previous()
This is fine and works perfectly... except, what if I have further links in the help passage that lead to other help passages? Then previous() doesn't work, because we're more than one step away from the original passage. If previous() doesn't suit your needs, you'll have to use normal passage links, perhaps with conditions (like you mentioned).
Either way I don't think that's gonna help me but thanks for your comment.
Here's a better solution for multiple passages. Put this setter link in the main story passage you're starting from:
helpfile][$last=state.active.title
Where helpfile is the name of the first passage you're going to. In that passage (and all passages after it in your chain, I'm using "helpfile" because that's the only situation where I tend to use this) you can put:
$last
If you're not using sugarcube, the syntax will be different. It used to be something like state.history[0].passage.title for other story formats, I'm not sure if that still holds true.
Let me know if this helps.
So the answer to your question essentially is no. I'm not using Sugarcube but I might go back to Sc2 at some point so learning both cane and cube sounds like a good idea. Then I can get a better idea of which is best for me. (Possibly neither).
As for the setter links for multiple passages that you offered; I'm not sure it's what I was looking for but I'll give it a go in both formats as I'm sure it'll be useful to know in any case.
I'll have a fiddle when I get a moment.
Thanks again!
passagenametogoto][$last=state.history[0].passage.title works for that storyformat and I'd assume all others. Sugarcube does things a little differently--I can certainly understand issues with it, I had the same when I switched to it initially.
Once you've gone through that initial setter link, at any further passage down the line you can have a $last passage that will go back to whatever passage $last was set at.
...OK, I had a go. I'm not sure how to set a passage as a variable.
How do I use this exactly?
'passagenametogoto][$last=state.history[0].passage.title'
I'm still a bit confused about how you're implementing this, how it works, what it is or if it's even what I need.
Just to clarify, I want a link in the UI bar which does two things.
1. Opens an inventory passage or suchlike with links to further non-story passages.
2. Changes when clicked, to a link that would close said passages. That link would revert to the original link when clicked again.
For instance, in the UI bar you might have a link called 'Inventory'.
Click on that link and it changes to 'Close Inventory' whilst opening up your inventory. Even if you open up new passages within your inventory, the 'Close Inventory' link will be able to direct you to your last story passage.
If this is what you're trying (so very patiently) to show me, please try again! :S
The <<if>> macro selects the correct version of the link depending on whether the $_return variable is set to a non-empty string. The <<if>> works here because StoryMenu is processed each turn.
If $_return is set to a non-empty string, that means the inventory is open and the value of $_return is the passage to return to. When clicked, the yielded "Close Inventory" link sends the player to the $_return passage and sets the value of $_return to the empty string.
If $_return is set to the empty string, that means the inventory is closed and the value of $_return is the empty string. When clicked, the yielded "Open Inventory" link sends the player to the "Inventory" passage (change that to whatever your inventory passage is named) and sets the value of $_return to the name of the current passage.