Howdy, Stranger!

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

Two Questions: Variables and Sidebar Display

Hi all,

I'm new to Twine and have been trying to learn by making a game and by using this forum and documentation, but I'm stuck on two things. Sorry if these have been covered before or are dumb questions - I've tried searching to no end. I'm using Harlowe/Twine 2.

1) Is it possible to set a variable to be either one of two things? For instance, if I were trying to make $party display either "Kitten Party" or "Puppy Party" completely randomly. Is there an easy (or even a convoluted) way to achieve this?

2) Is there a way to display a passage in the sidebar? For example, I've made a fake social media account that gets updated as you progress through the game and I'd like to have it appear in the sidebar. The whole thing is built in a passage, so I had assumed I would be able to (display:) it, but have not been able to get that to work. Any suggestions?

Thanks - I appreciate any help or suggestions!

Comments

  • edited May 2016
    1. ... make $party display either "Kitten Party" or "Puppy Party" completely randomly ...
    You are closer to the answer than you realize, you can use the (either: ) macro to do what you want although there are two ways it can be used.

    1a. Value is randomly determine only once, and there after the $party variable displays the same value.
    (set: $party to (either: "Kitten Party", "Puppy Party"))
    
    party 1: $party
    party 2: $party
    party 3: $party
    party 4: $party
    party 5: $party
    

    1b. Value is randomly determine each time you display the $party variable.
    (set: $party to '(either: "Kitten Party", "Puppy Party")')
    
    party 1: $party
    party 2: $party
    party 3: $party
    party 4: $party
    party 5: $party
    
    note: because 1b is random it is possible that all five outputs will be the same, if so then refresh the page until they are not. lol

    2) Is there a way to display a passage in the sidebar?
    Harlowe's sidebar is an illusion, it is actually additional content added to the start of the current Passage's generated HTML, that has been visually "moved" sideways using CSS.

    A very simplified version of that generated HTML:
    <tw-story>
    	<tw-passage>
    		<tw-sidebar>
    			<tw-icon>↶</tw-icon>
    			<tw-icon>↷</tw-icon>
    		</tw-sidebar>
    		...The HTML generated based on the content of the current Passage ...
    	</tw-passage>
    </tw-story>
    
    The answer to the Harlowe: CSS Help - Three screen divisions, two with independent scrollbars thread explains how to position one of your own Passages so that it appears in the same general location as the sidebar. I suggest also reading the two linked threads found at the start of that answer.

    p.s. You could also use Javascript to "move" (detach/reattach) HTML content displayed on the current page into the sidebar so that it would actually be part of the the sidebar but that is more complex and would need to be done each time the Reader navigates between Passages because the sidebar is destroyed and then recreated.
  • Thank you so much! I was so close yet so far. Truly you are a God among twine forum users.
Sign In or Register to comment.