Howdy, Stranger!

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

constantly evaluating several variables?

Hello,

I am learning Twine, new to it. I know some html css js... I am using latest 2.0 build with Harlowe.

I was wondering if it is possible to only display something, when the user has done several other things within that passage, and not before.

In example I would like that, after clicking every link in this passage, no matter in which order, a "next" link would appear, that when clicked would take the user to the next passage.

(link: "Red button.")[red button ON!]
(link: "Green button.")[green button ON!]
(link: "Blue Button.")[blue button ON!]
This way I can force the user to do a series of actions before advancing.

I would like to do this within a single passage code, and not by using several, if possible.

Thank you!

Comments

  • You can use a variable and a (live:) macro to do what you want:

    (set: $counter to 0)
    Please click each of the following links.

    (link: "Red button.")[(set: $counter to it + 1)(print: "red button ON!")]
    (link: "Green button.")[(set: $counter to it + 1)(print: "green button ON!")]
    (link: "Blue Button.")[(set: $counter to it + 1)(print: "blue button ON!")]

    {(live: 500ms)[(if: $counter is 3)[ [[Next Passage]](stop:)]]}
    The variable is used to track how many links have been clicked.
    The (live:) macro is used to check the current value of the variable every half second (*), once the variable is the correct value it will first display the passage link and then stop the (live:) macro using a (stop:) macro.

    It is very important to manually stop a (live:) macro once your finished with it, otherwise it will just keep running.

    * 1 second equals 1000  milliseconds (ms)
  • Thank you greyelf  :D

    As I understand undeclared variables are set to "0", which means that I do not really need to declare the variable counter, but you are doing this for the sake of clarity, right ?

    Thanks again
  • malmalmal wrote:

    As I understand undeclared variables are set to "0", which means that I do not really need to declare the variable counter, but you are doing this for the sake of clarity, right ?

    Yes(ish).

    Being an old programmer, experience has taught me to always assign a default value to any variable I use and to not rely on the language/system to do it for me, because you never know if the language/system will be changed to not do it automatically or to default to a different value. lol
  • Thanks for the experienced programmer advice, I'll take it!  ;D
Sign In or Register to comment.