Howdy, Stranger!

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

Enabling Forward/Back Buttons in the Midst of Story -- SugarCube 2

edited April 2016 in Help! with 2.0
So I know "config.history.controls = false;" disables the back/forward buttons (and vice versa), but it seems that if I run that code while the story is running, I can't turn them on in the midst of playing. I wanted to make it possible for people to replay the game with back/forward enabled after completing it once, but it seems that the Twine session has to be reset for that code to turn those buttons back on, thus really no way to toggle it in a single session. Any way around this?

Comments

  • edited April 2016
    Config object properties are, generally, not intended to be changed willy-nilly as the game/story progresses. They are intended to be set once, at startup. Specifically, disabling Config.history.controls causes the entire history control structure to be removed at startup—it's not hidden, it's just gone.

    That said, working around that, or doing something similar, isn't impossible, however, I'm a bit confused. How are players supposed to replay the game within the same session? To properly replay the game should require a restart anyway—unless you're manually sanitizing the variable store or have been very careful with it from the beginning.

    Are you perhaps talking about enabling the history controls at the end, thus letting the player navigate backwards within the current playthrough/session? Or are you talking about enabling the history controls at the end for the next playthrough/session? Something else? I ask because, again, replay within the same playthrough/session doesn't make a whole lot of sense to me.
  • @TheMadExile
    Is it possible to programatically save the game in the final passage and then test if that save exists during the startup after a restart?
  • @greyelf
    Yes. Although that's probably a bit complicated for this situation. It also doesn't address isaiaheverin's apparent desire to replay within the same session.

    The easiest thing to do would be to do something like the following: (in Twee notation)
    :: StoryInit
    <<if not $historyControls>>
    	<<script>>Config.history.controls = false;<</script>>
    <</if>>
    
    :: Final Passage (whatever it's actually called)
    Normal finale text.  Blah, blah, blah.
    
    <<set $historyControls to true>><<remember $historyControls>>\
    A note about the history controls being enabled in future replays.
    
    <<button "Restart Now">><<script>>Engine.restart();<</script>><</button>>
    
    That said, and again, this doesn't address the elephant in the room (i.e. replay within the same session).
  • edited April 2016
    I suppose it doesn't have to be the same session, I wasn't aware you could store variables of any kind between sessions, though I totally forgot the <<remember>> macro existed, so that solves my problem. I was purging the whole list of variables and just linking to the start passage.

    I should probably <<remember>> that every time I can't figure out how to do something, it turns out the functionality I wanted was already there. :P

    Random follow-up question, but is there any way of making an array or list of variables? Don't recall reading about it, though I may well have. I know some macros use their own arrays internally, just don't remember seeing how to create one myself. Looks like I can just do it in a Javascript tag and use this functionality to read from it?
  • <<set $theList to ['Alfa', 'Bravo', 'Charlie']>>
    
  • <<set $theList to ['Alfa', 'Bravo', 'Charlie']>>
    

    Haha, well that's simple. Thanks.
Sign In or Register to comment.