Howdy, Stranger!

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

Forcing code to continue running until two variables are not equal (Harlowe 1.2.2, Twine 2.0.11)

Okay, another problem that probably has an easy solution that I'm just missing.
The goal is this:
1. Assign the last room visited to $lastroom via (history: )
2. Randomly determine a destination room via (either: ), assign this to $destroom
3. Check if $destroom and $lastroom are the same;
3a. If they are, repeat Steps 2 & 3.
3b. If not, display a link to $destroom.

I have all of this working except for Step 3a; I can't work out a method to do this that doesn't require player input. Any thoughts?

Comments

  • Hello,
    I too have similar issues. There's no looping method built into Harlowe that I've been able to discover.
    What I have done is use a passage like I would a function.
    In your case you will need a separate passage that contains the (either:) statement.
    We will call it "getRandom"
    For example:
    You are in "RoomA". Assign "$lastroom". Have a link to next room
    Next Room->getRandom

    The getRandom passage has:
    (set: $destRoom = (either: x,y,z etc. )
    (goto: "checkDestination")

    Passage "checkDestination" has:
    (if: $destRoom is $lastRoom)[(goto: getRandom)]
    (else:)[(goto: $destRoom]

    So, in other words you build your loop with two intermediate passages between rooms.
    This will result in a LOT of arrows pointing to "getRandom". That's sort of a pain but so far it's the only way I've been able to figure it out.

    Hope it helpsl.
Sign In or Register to comment.