Howdy, Stranger!

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

More if questions

Twine: 2.1.1
Harlow: 2.0

Ok so, I've been working with Harlow on and off today and I've come to something that has me stumped. In a normal programming language it would be simple, but I'm not sure how to proceed with Harlow.

So the idea that I want to run with is to have long passages slowly build themselves as the user makes choices. Basically, scenes evolve as a whole rather than one passage to the next.

For instance:

Name?

(Choices
Dennis
Hailey)

(User chooses Dennis and both choices vanish and a new block of text appears:)

Nice to meet you Dennis, how old are you?

(Choices
18
25)

Etc.

This is something I used to do in Quest Text, but everyone told me to move to Twine so that's what got me here.

So I've figured out that I need to use Hooks, so I've got:
"Name?"

["Jesse Jackson"]<nameDisplay|
["Taylor Swift"]<nameDisplay|

(click: ?nameDisplay)[(if: ?nameDisplay is "Jesse Jackson")[Right] (else:)[Wrong] ]

e0c26fd869c73fd84449e2de3d66aeba.png

I attempted to convert the ?nameDisplay to a variable ($nameDisplay) but I think I'm missing something?

Comments

  • edited March 2017
    You can use a variation on the techniques listed in the Chat like Conversations for Harlowe thread to do what you want.

    1. The passage the conversation will appear in:
    The following example uses a Harlowe 2.x temporary variable named _setp to track which part of the conversation the reader is up to.
    (set: _step to 1)\
    |output>[]
    
    |choices>[]\
    |workarea>[(display: "Scene 1 Logic")]
    


    2. The Scene 1 Logic passage:
    The following uses (if:) related macros to determine what text and choices are displayed to the reader.
    (if: _step is 1)[
    	(append: ?output)["Name?"]
    	(replace: ?choices)[\
    		(link: "Jesse Jackson")[
    			(set: $name to "Jesse Jackson")
    			(set: _step to 2)
    			(replace: ?workarea)[(display: "Scene 1 Logic")]
    		]
    		(link: "Taylor Swift")[
    			(set: $name to "Taylor Swift")
    			(set: _step to 2)
    			(replace: ?workarea)[(display: "Scene 1 Logic")]
    		]
    	]
    ](else-if: _step is 2)[
    	(append: ?output)[<br><br>Nice to meet you $name, how old are you?]
    	(replace: ?choices)[\
    		(link: "18")[
    			(set: $age to 18)
    			(set: _step to 3)
    			(replace: ?workarea)[(display: "Scene 1 Logic")]
    		]
    		(link: "25")[
    			(set: $age to 25)
    			(set: _step to 3)
    			(replace: ?workarea)[(display: "Scene 1 Logic")]
    		]\
    	]
    ](else-if: _step is 3)[
    	(append: ?output)[<br><br>$age is a good age to be.]
    	(replace: ?choices)[]
    ](else:)[
    	(append: ?output)[]
    	(replace: ?choices)[]
    ]
    


    3. The CSS to hide the workarea so that it does not add a blank area to the bottom of the page. This goes in your story's Story Stylesheet area.
    tw-hook[name="workarea"] {
      display: none;
    }
    


    WARNING: Changes to story variables made in the Passage currently being shown to the reader are only saved to History during passage traversal. This means that if the web-browser refreshes the current page for any reason then all changes made to the variables based on the reader's selections will be lost, and they will need to make their selections again.

    NOTE to Harlowe 1.x users:
    You can also use the above technique but you will need to change the temporary variable into a story variable for the code to work. eg. change all occurrences of _step to $step
  • I'm working with this now, I can see and understand the logic and this seems like a pretty solid solution. I see a lot of use of \ in the code, is that just to define that the code moves to a new line?
  • Also I'm afraid I can't get this working. I get a number of errors even when I copy-paste the code.

    07969c4d88a28a51336ae820f00658a1.png
    b585f603390810b2a4d8f7c2fa1b83e6.png
  • avamarine wrote: »
    I see a lot of use of \ in the code, is that just to define that the code moves to a new line?
    I suggest reading the Harlowe 2 manual, and in this case the Escaped line break markup section.
    avamarine wrote: »
    Also I'm afraid I can't get this working. I get a number of errors even when I copy-paste the code.
    You will need to supply examples of the content of the your related passages and describe what errors you are getting if you want people to debug them. Screen shots only show us what is outputted, not what code was used to generate the output.

    Your images show extra blank lines in the output which is normally caused by adding extra line-breaks to the contents of a passage.
Sign In or Register to comment.