Howdy, Stranger!

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

Back or Return in Harlowe?

I can't seem to figure out if there's a simple macro to return to the previous passage, with variables or not.

I'm also trying an automatic return; if the player opens a closet, it displays the closet passage and returns automatically after a pause. This does not seem to work:

(time: 2s)[(goto: "2nd")]

Where "2nd" is the return passage.


(on edit DOH "live" not "time")

Comments

  • edited June 2015
    Along the same lines, I'm trying to have a character's dialogue appear sequentially in segments. This looks like it should work, but I don't get the last part in quotes:
    (link: "'What do you think of the current state of politics?'") [The mousy librarian looks up at you. (live: 3s) ['Oh, I have so much to say about *that*!' (live: 3s) ['The current state of our economic crises has grown to epic proportions, and I don't think our current leaders are functionally working on any way of escaping it...']]]
    
  • edited June 2015
    I don't think you need to nest the (live:) macros in this case. And if you want things to display sequentially, you need to have the second (live:) macro be a different value (perhaps 6s if you want it to appear 3 seconds after the first one).

    Also, it seems you have put a space between (live:) and the [hook] and there needs to be no space there.

    And remember to put a (stop:) at the end of the final hook, so that the page doesn't keep reloading the (live:) macro endlessly.

    Try this:
    (link: "'What do you think of the current state of politics?'")[The mousy librarian looks up at you. (live: 3s)['Oh, I have so much to say about *that*!'](live: 6s)[ 'The current state of our economic crises has grown to epic proportions, and I don't think our current leaders are functionally working on any way of escaping it...'](stop:)]
    

    PS: you could remove the single quotation marks of the displayed text so that it all looks as one text.
  • @Hanon Ondricek
    Instead of creating multiple (live:) events, I suggest you use a singe (live:) macro and a variable to control which piece of text is to be displayed next.

    Based on your original example:
    (link: "'What do you think of the current state of politics?'") [The mousy librarian looks up at you. |output>[]
    (set: $var to 0)(live: 3s)[(set: $var to it + 1)(if: $var is 1)[(append: ?output)['Oh, I have so much to say about *that*!']](elseif: $var is 2)[(append: ?output)[ 'The current state of our economic crises has grown to epic proportions, and I don't think our current leaders are functionally working on any way of escaping it...']](else:)[(stop:)]]]
    

    The above re-formatted to make it more readable:
    (link: "'What do you think of the current state of politics?'") [
    	The mousy librarian looks up at you. |output>[]
        (set: $var to 0)
        (live: 3s)[
        	(set: $var to it + 1)
            (if: $var is 1)[
            	(append: ?output)['Oh, I have so much to say about *that*!']
    		]
            (elseif: $var is 2)[
            	(append: ?output)[ 'The current state of our economic crises has grown to epic proportions, and I don't think our current leaders are functionally working on any way of escaping it...']
    		]
            (else:)[(stop:)]
    	]
    ]
    
  • greyelf wrote: »
    Instead of creating multiple (live:) events, I suggest you use a singe (live:) macro and a variable to control which piece of text is to be displayed next.

    Hi @greyelf,

    Is there a disadvantage with the multiple (live:) method, and/or advantage with the changing variable method?

    I ask because I have been using a multiple (live:) option and perhaps I am messing things up in the long run or creating uknown problems for myself.

  • Each (live:) macro on a passage sets up their own background timer, a background timer can (depending on how often it is firing) cause a slight delay to the User's ability to interact with the story. The more background timers running at the same time the great the possibility, again depending on how often each one is firing.

    eg. Say you have three timers running but each one is set to three seconds then the user should not notice anything. On the other hand if each of those three timers is set to 1/2 a second then the user may notice a slow down.

    Generally if you need multiple things to happen at different times it is better to use a single timer and just track the elapsed time or use a variable like my above example.

    Also remember that a (live:) macro timer keeps firing until you either (stop:) it or the section (ie. passage) it is attached to is removed from the DOM (ie. move to a different passage)
  • greyelf wrote: »
    Also remember that a (live:) macro timer keeps firing until you either (stop:) it or the section (ie. passage) it is attached to is removed from the DOM (ie. move to a different passage)

    Sounds effective. Does (stop:) end all the timers on the page, or is there a need for multiples?

    This type of thing almost seems like it could use a macro to replace that big block of code greyelf suggests and automatically use one timer:
    (sequence:)[[3s]Hey, three seconds have gone by.[6s]Now six seconds have gone by, are you paying attention?][9s]Hey, pay attention!  You only have a minute to answer!]
    

    The (stop:) would be implicit when the last part of the sequence fires.
  • greyelf wrote: »
    Each (live:) macro on a passage sets up their own background timer, a background timer can (depending on how often it is firing) cause a slight delay to the User's ability to interact with the story. The more background timers running at the same time the great the possibility, again depending on how often each one is firing.

    Thanks for the explanation. It makes sense. I need to change the way I've been doing things, because I didn't understand the (live:) macro properly.
    Does (stop:) end all the timers on the page, or is there a need for multiples?

    That's a question I would like to know the answer to as well.
    (sequence:)[[3s]Hey, three seconds have gone by.[6s]Now six seconds have gone by, are you paying attention?][9s]Hey, pay attention!  You only have a minute to answer!]
    

    The (stop:) would be implicit when the last part of the sequence fires.

    Just clarifying (in case some readers misunderstand) that this is a SUGGESTION for how such a function could be incorporated in future versions of Harlowe, and not actual code that currently works.

    Good suggestion, by the way.

  • Sounds effective. Does (stop:) end all the timers on the page, or is there a need for multiples?
    If you look at my example you will see that the (stop:) is being called within the container (hook) associated with the (live:) macro it is stopping, so a (stop:) only effects a single (live:) macro.

    Based on the Harlowe source code a (live:) macro will also automatically stop if the section containing it (eg. Passage) is removed from the DOM (eg. via moving to another Passage). The source code documentation implies that there are other ways of removing a section containing a (live:) macro.
  • So in short, there is no simple Back or Return macro.

    If a player clicks on a painting they can see from different room/passages and I go to a passage called "Painting" that says "Here's the description of the painting." I need to then do a Return->[History's Last to put them back wherever they were

    ?
  • Well..."Return->[History's Last to put them back wherever they were" seems pretty simple to me.

  • Is that the correct syntax?
  • Is that the correct syntax?

    I don't think so. All that will do is create a new passage called History's Last. I'm fairly new to twine myself, but I think the syntax you are looking for is ...
    (link-goto: "Return", (history:)'s last)
    

    Hope that helps

    GL
  • That does. I wonder if I can

    (set:) [$return to "(link-goto: "Return", (history:)'s last)"]

    And then just put $return in the passage.
  • This : (set:) [$return to "(link-goto: "Return", (history:)'s last)"]

    Isn't right, but I think I can make it work.
  • Try the following, note the backslashes being used to escape the double quotes around the Link Text:
    (set: $return to "(link-goto: \"Return\", (history:)'s last)")
    
    You would just need to add $return to any passage you want to add that link to.

    note: In SugarCube there are two macros <<back>> and <<return>>, the first macro moves the Reader backwards to the relevent passage and rewinds History so that any changes done to $variables in the passage containing the macro are undone, while the second macro move the Reader forward to the relevant passage and any changes done to $variables in the current passage are kept.

    The above Harlowe example works like the <<return>> macro, it moves the Reader forward to the relevant passage.
Sign In or Register to comment.