Howdy, Stranger!

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

[Sugarcube 1.0.34] Making a passage accessible from all (or most) pages

Alright, continuing on from my last one, I have another question regarding Sugarcube! I'd like to make a system using Sugarcube that allows the player to access a "Character Sheet" passage from any point in the story, without having to worry about forgetting to write a "Character Sheet" link in every single passage (Which would also make my story map an absolute mess). How would I go about doing this?

As an bonus question, would there be any way for me to exclude certain passages from having the character sheet link? For instance, my story has a few passages dedicated to actually setting up the character, and they might run into problems if they attempt to access their character sheet -before- they've made their character, so how would I go about making sure that link only shows up after the player's confirmed their character, and then shows up in every passage after that?

Comments

  • note: I am going to assume your "Character Sheet" passage is named Character Sheet.

    1. There is a Special Passage named StoryMenu which can be used to add your own menu items to the side-bar. Create a StoryMenu passage and add a markup link like the following to it.
    [[Character Sheet|Character Sheet]]
    

    2. You can use a Boolean variable to track if you have finished creating the character or not, and then use that variable to determine if the Character Sheet link should be displayed or not.

    2a. You can initialise the variable in another special passage named StoryInit, this is where you should initialise all the variables you plan to use in your story.
    <<set $character to false>>
    
    2b. You can use an <<if>> macro to check the current value of the variable, replace the markup link in step 1. with the following.
    <<if $character>>[[Character Sheet|Character Sheet]]<</if>>
    
    2c. Change the value of the variable to true in the first passage after the ones related to setting up the character, and the b]Character Sheet[/b] link should magically appear.
    <<set $character to true>>
    

    3. Potential Future question and answer:
    If your Character Sheet is actually made up of a Parent passage and has markup links to one or more Child passages you will end up wanting to know how to return the reader directly to the last non-Character-Sheet related passage they were viewing.

    This comment in the If statement, comparing previous() .... thread explains how to create a Return markup link that knows how to do return the reader to the last non-menu based passage.
  • If you don't want a sidebar in your game you can set it to hidden and use javascript to bind the link in the sidebar to a key, like c.
  • Wow, that did the trick, that was surprisingly a lot easier than I thought it'd be. The character sheet's a simple, single-page affair, but thank you for the advice, Greyelf! That's saved me a lot of headache :D

    Thank you as well, Claretta, though I do quite like the sidebar in the Sugarcube format so it's perfectly fine as it is. I was hoping I could get the link to the character sheet into the sidebar and the StoryMenu special passage has helped with that!
Sign In or Register to comment.