Howdy, Stranger!

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

I figured out cycling links in Harlowe 2.1.0

I spent all evening working on cycling links, but couldn't find any guides written specifically for the newest version of Harlowe, so here's my solution for links that you click again and again to cycle through options:
(set:$place to (a:
"the cave",
"the bridge",
"the cliff",
"the lake"))
p>You walk until you reach (link-repeat:"|this>[it]")[(set:?this to $place's 1st)(set:$place to(rotated:1, ...$place))].
</p>
This will start with a link that says it, then cycle through the four locations.
I hope this helps somebody! If you have any questions please ask.

Comments

  • Thank you so much! This is (one of) the things that was really annoying me, so I'm glad you just happened to post this today!

    For anyone else looking at this and not following how it works, here's the relevant section in the docs: (it took me a minute to find it) https://twine2.neocities.org/2.html#type_array
  • Hmm, actually.. this code doesn't seem to work for me. When I try it, I get this error:
    I can't put a new value into ?this (a hook name).►
    I tried to perform an operation on some data, but the data's type was incorrect.
    

    I tried switching it to (replace:) but then it prints the entire array instead of just one item:
    (link-repeat:"|this>[it]")[(replace:?this)[$place's 1st](set:$place to(rotated:1, ...$place))]
    

    Prints: "You walk until you reach the cave,the bridge,the cliff,the lake's 1st."
  • I'm not sure why my code's not working for you, but I changed yours a little so it works for me:
    You walk until you reach (link-repeat:"|this>[it]")[(replace:?this)[(print: $place's 1st)](set:$place to(rotated:1, ...$place))]
    What I did was I changed "$place's 1st" to "(print: $place's 1st)". I hope that helps!
Sign In or Register to comment.