–1 vote
by (120 points)
retagged by
I have a [[SETTINGS]] page that can change a few critical variables with a <<return "SAVE" go 1>> button. Everything works perfectly, but the problem is the [[SETTINGS]] link is in the StoryCaption, so you have access to it from the SETTINGS passage, which then breaks the <<return "SAVE" go 1>> button (Looping back to the SETTINGS passage indefinitely).

The only solution I have, to my limited knowledge of SugarCube, is to <<set $settingspassage to 1>> while in SETTINGS, and <<set $settingspassage to 0>> on every single other passage, then wrapping the [[SETTINGS]] link in <<if $settingspassage is 0>>[[SETTINGS]]<</if>>

Is there a way I can detect what passage is currently being displayed as a variable to wrap the [[SETTINGS]] link away? Or maybe having a variable set itself to the title of each new passage other than SETTINGS, to then call back to like <<return "RESTART" to $restartvariable>>?
closed with the note: Correct answer received

1 Answer

+2 votes
by (68.6k points)
edited by

First.  You really shouldn't be using SugarCube v1 for even semi-new projects at this point as it has been end-of-life'd for quite a while now.  SugarCube v2 is the current major version and is a significant improvement over v1.


If your settings passage does not have sub-passages, then you may use the passage() function to determine what the currently displayed/navigated passage happens to be.  For example, you may wrap the link thus:

<<if passage() isnot "SETTINGS">>[[SETTINGS]]<</if>>

That will show the link as long as the current passage is not SETTINGS.

 

If your settings passage does have sub-passages, then you'll probably need to use the tags() function to determine whether the player is somewhere within your settings menu.  For example, tag each passage of your menu with something—e.g. menu—and then wrap the link thus:

<<if not tags().includes("menu")>>[[SETTINGS]]<</if>>

That will show the link as long as the current passage's tags do not include menu.

 

SEE: SugarCube v1 documentation.


PS: Please tag your questions with the name+major version of both the compiler you're using (e.g. twine1, twine2, tweego1) and story format (e.g. harlowe2, sugarcube2), because it can, and often does, make a difference to the answers you'll receive and how quickly you receive them.  I'd also suggest specifying the full version of each somewhere, either as additional tags (e.g. twine2-1-3, sugarcube2-1-8) or within the post, because that can matter too.

A blurb in the subject/title is not sufficient.

by (120 points)

Edited and closed, thanks for the answer. I've been using your answers to other questions to learn to use Twine/SugarCube, this is the first time I couldn't find an answer.

Also, I use SugarCube 1 because you can use the back/forward mousebuttons as back/return shortcuts by default. No idea if this is achievable in 2, but the important part was the by default part.

I normally just search forums for answers when I run into issues I can't solve myself and generally avoid asking on such forums... until I lack enough of a fundamental understanding of the language to logically brute force my way through. And you have been a huge part of this process for me so, again, thank you.

by (68.6k points)
Generally, when you've gotten the answer you want, you mark that answer as best.  You shouldn't need to close a question.

The reason that SugarCube v2 has its own history navigation UI and no longer uses the browser's backward/forward buttons is because the relevant API has been intentionally broken several times by browser manufacturers, with disastrous results for those using it (that would be you in this case).  They've made it toxic at this point.
by (120 points)
Don't know what that means, don't necessarily care. Not to shit on any of this forum stuff but I'm not a person that enjoys community, so all of these general etiquette intricacies are foreign to me. This is guaranteed to be my only question asked here anyway. Good luck dealing with lowly savages like me in the future, man. Stay safe.
by (63.1k points)
He wasn't asking you to become our community president, he was just asking you to mark the question as answered. That's a pretty easily understandable feature of a Q&A site and it doesn't seem like it'd be all that intricate to me. You said yourself you found forums like this valuable; marking a question as answered just helps people searching for answers (people like you) known this came to a satisfying conclusion.
...