Howdy, Stranger!

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

[Sugarcube 2.12.0] How to access settings through if macro (or any macro, for that matter)?

Ok, before I begin, I'll warn that I have only beginner levels of experience with twine, so you'll have to bear with me. I'm attempting to create a setting to toggle tutorial for a game that I am creating. Basically, I wish to display a separate dialog on certain pages through an <<if>> macro that would explain the stats and give the player some pointers on what's what. This I can do just fine with regular story variables and the <<if>> macro, and I can create the dialog. The problem I am facing is getting it to work with the Settings API. I want the player to be able to toggle tutorial and have it saved between sessions and save files. So I went and created a toggleable setting called "tutorial", but now, I don't know how to call it in the <<if>> macro. The API itself details how to do it with javascript, but I am crap at that so I sort of failed to adapt the code to my needs.

Here's a mock example of what I want:
<<if tutorial is on>>
<<load dialog through script>>
<<else do nothing>>

And here's the setting in question:
Setting.addToggle("tutorial", {
    label   : "Tutorial",
		default  : true,

I'd be glad if someone could help me do this or possibly provide an alternative method.


  • I am a bit of an amateur, so I hope this helps....
    You could use a variable to designate whether or not to run the tutorial?
    <<IF $Tutorial = 1>>
    <<Print Tutorial>>

    I don't know much about Twine 2, but I should think you can still use a link to return to the previous page. That means you can make a link to an 'options menu' at any point and then just click 'return' to go back. Or even just have a button to return you to the current page, but change the tutorial variable from 1 to 0. That way, you can have the Tutorial variable control which button is shown (IE, If 0, show 'turn to 1' button. Else show 'turn to 0' button)

    I really hope that helps dude
  • You're looking for the settings special variable.

    Accessing the tutorial setting via TwineScript would be done like so:
    <<if settings.tutorial>>
    …show tutorial link or whatever…
    Notes, based on your mock example:
    • <<if>> conditional expressions resolve to booleans, so you don't need to compare a boolean to anything, you just use it. Toggle type settings contain boolean values, so simply use the value.
    • Don't include empty <<elseif>> or <<else>> macros. If you do not have something that needs done in that case, then exclude the case entirely. If you want to invert the test, use the not operator.
Sign In or Register to comment.