Howdy, Stranger!

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

(Harlowe) How to make confirm() function loop passages properly?

edited July 2016 in Help! with 2.0
I am trying to allow my confirm() function to act as my "restart" button, as in if player chooses "OK", they will get the chance to go back to their last decision, but if the player chooses "Cancel", then the game will restart from the beginning.

My current code is
(link: "Revisit last choice?")[
(set $Choice to (confirm: "A brigh light of memories flash pass you, would you like to revisit your last choice?")[(if $Choice is true)[(goto: "Cage open")]
](else:)[
	(goto: "Waking up in a cave")
	]

Whenever I choose "OK", it loops me correctly to the "Cage open" passage, but if I choose "Cancel". it just stays on the current passage instead of taking me to the desired "Waking up in a cave" passage.

Thank you guys for any help that you could offer.

Comments

  • There are a number of syntax errors in your code:

    1. Both your (set:) macro and (if:) macro are missing a colon after the macro name.
    2. You have an open square bracket [ instead of a close parenthesis ) at the end of your (set:) macro.
    3. You have an invalid close square bracket ] before your (else:) macro.
    4. Your (link:) macro is missing its close square bracket. see 3.

    I re-wrote your example:
    (link: "Revisit last choice?")[
    	(set: $Choice to (confirm: "A brigh light of memories flash pass you, would you like to revisit your last choice?"))
    	(if: $Choice)[(go-to: "Cage open")]
    	(else:)[(go-to: "Waking up in a cave")]
    ]
    

    notes:
    Using indentation when debugging your code can help find errors.
    The passage editor uses syntax highlighting to show parenthesis that are not both opened and closed, as well as showing if a macro name has been correctly written (missing colon)
  • greyelf wrote: »
    There are a number of syntax errors in your code:

    1. Both your (set:) macro and (if:) macro are missing a colon after the macro name.
    2. You have an open square bracket [ instead of a close parenthesis ) at the end of your (set:) macro.
    3. You have an invalid close square bracket ] before your (else:) macro.
    4. Your (link:) macro is missing its close square bracket. see 3.

    I re-wrote your example:
    (link: "Revisit last choice?")[
    	(set: $Choice to (confirm: "A brigh light of memories flash pass you, would you like to revisit your last choice?"))
    	(if: $Choice)[(go-to: "Cage open")]
    	(else:)[(go-to: "Waking up in a cave")]
    ]
    

    notes:
    Using indentation when debugging your code can help find errors.
    The passage editor uses syntax highlighting to show parenthesis that are not both opened and closed, as well as showing if a macro name has been correctly written (missing colon)

    Thanks! I will work on cleaning up my coding style too, I guess it's quite messy....really sorry about that :blush: !
Sign In or Register to comment.