Howdy, Stranger!

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

Complex coding

Hello,

I'm running into quite a bit of trouble while trying to do some coding in Harlowe. So, what I'm trying to do is create a time system where I count hours and increments of 15 minutes that passes by each time you move to a different page. Because of how complex it is, I have set up multiple pages of pure coding that is displayed on the bottom of non-coding pages.

In the "first room" there is text, and then two displayed pages at the bottom. It goes something like:
(set: $location to "first room")
Text text text text

(display: "code")
(display: "navigation")

The "code" page would do something like this:
(if: $location is "first room")[
(set: $1Appear to true)
(set: $1Desciption to "Go to the left room")
(set: $1Code1 to (set: $15Passed to 1))
(set: $1Code2 to (display: "timePassCalc"))
(set: $1Code3 to (goto: "second room"))

(set: $2Appear to true)
(set: $2Description to "Go to the right room")
(set: $2Code1 to (set: $hourPassed to 1))
(set: $2Code2 to (display: "timePassCalc"))
(set: $2Code3 to (goto: "third room"))]

And then the "navigation" page would be:
(if: $1Appear is true)[(link: $1Description)[$1Code1 $1Code2 $1Code3]]
(if: $2Appear is true)[(link: $2Description)[$2Code1 $2Code2 $2Code3]]

There is nothing wrong with the "timePassCalc" page. The problem here, is that if you choose one of those options, a total of 1 hour and 15 minute passes because it has set BOTH $15Passed and $hourPassed to 1, when I only want them to run when the link is pressed. Preferably, I want to keep all the code and navigation on one page so that it would save space. Can anyone see a work around the current system? Any help would be appreciated... thank you!

Comments

  • Besides the $1Description variable missing an r character in the code passage:
    incorrect: (set: $1Desciption to "Go to the left room")
    correct: (set: $1Description to "Go to the left room")
    

    Your main issue is an assumption that you can store (set: $15Passed to 1) inside the $1Code1 variable as a macro and that it delays the assignment of the $15Passed variable, which the following test shows is incorrect:
    (set: $var to 0)
    var 1: $var   (zero because of initialization)
    (set: $container to (set: $var to it + 1))
    var 2: $var   (one, inner set macro was executed, set macro not stored in container)
    $container
    var 3: $var   (still one, container variable does not contain set macro)
    

    What you need to do is store the inner set macro as a String value, which will execute when printed.
    (set: $var to 0)
    var 1: $var   (zero because of initialization)
    (set: $container to "(set: $var to it + 1)")
    var 2: $var   (still zero, set macro string stored in container)
    $container
    var 3: $var   (one, set macro string converted to macro and executed)
    

    note: you may need to use the same technique for the (display:) and (goto:) macros in the Code2 and Code3 related variables.
  • greyelf wrote: »
    Your main issue is an assumption that you can store (set: $15Passed to 1) inside the $1Code1 variable as a macro and that it delays the assignment of the $15Passed variable...
    It ultimately worked on the pages where only $15Passed was displayed, so I didn't exactly question the syntax until I started to add the $hourPassed into it. With that said, you have saved me from reworking what code I already have down and I cannot thank you enough for that. For what it's worth though, thank you.
  • @IcarusDragon
    One thing I forgot to mention was that you can use a footer tagged passage to automatically append content to the bottom of the current passage.
Sign In or Register to comment.