Howdy, Stranger!

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

Making hooks clickable multiple times in Harlowe

I have a few hooks that, when clicked, make text appear elsewhere that describes an item. This new text that contains two more hooks, for whether to select the item or not. If "No" is clicked, the hook disappears. The problem is that I would like the item descriptions to appear as many times as the player clicks on them, but the links disappear after one click. I know I could just use multiple passages, but I'd like to figure out how to do it with hooks if possible.

Current code:
Three weapons are laid out before you. Which do you choose?

|weaponChoice>[A gleaming |sword>[longsword].
An elegant |bow>[bow and quiver].
A glowing |staff>[mage's staff].]{

(click: ?sword)[(set: $weapon to "sword")(replace: ?weaponChoice)[Placeholder sword description.

Do you choose this weapon?

[[Yes->Weapon Chosen]]

(link: "No")[(replace: ?weaponChoice)[A gleaming |sword>[longsword].
An elegant |bow>[bow and quiver].
A glowing |staff>[mage's staff].]]]]

(click: ?bow)[(set: $weapon to "bow")(replace: ?weaponChoice)[Placeholder bow description.

Do you choose this weapon?

[[Yes->Weapon Chosen]]

(link: "No")[(replace: ?weaponChoice)[A gleaming |sword>[longsword].
An elegant |bow>[bow and quiver].
A glowing |staff>[mage's staff].]]]]

(click: ?staff)[(set: $weapon to "staff")(replace: ?weaponChoice)[Placeholder staff description.

Do you choose this weapon?

[[Yes->Weapon Chosen]]

(link: "No")[(replace: ?weaponChoice)[A gleaming |sword>[longsword].
An elegant |bow>[bow and quiver].
A glowing |staff>[mage's staff].]]]]

}

I wondered if the problem was because I was replacing the question with the description, then vice versa, but even putting an empty hook at the bottom for the description and using that didn't work. Is there a macro to un-click a hook or something, or is this impossible?

Comments

  • This question has been asked many, many times before.

    As explained in this comment Sensor macros like (click:) (with a hook) and (link:), and the sensor/changer combo macros like (click-replace:) are designed to be non-repeatable, it is just how they currently work.

    That comment also contains an example which explains one way to implement a solution, but basically you need to attach a new (click:) macro to your hook after the Reader has clicked it.

    This is normally done by having the logic part (the part that applies the (click:) and also what happens when that link is clicked) in a second passage and to (display:) that logic passage within you main passage (the passage you want the click-able link to appear in).

    Based on your above example In your case this is going to be quite complex.
  • Ah, thank you. Sorry for the repeated question.
  • @numberQ
    The following is an example based on your original post, it consists of four passages:

    1. The passage you want the choices to appear in:
    Three weapons are laid out before you. Which do you choose?
    
    |weaponChoice>[(display: "Weapon Choices")]
    
    2. A Weapon Choices passage, used to display the possible items:
    A gleaming |sword>[longsword].
    An elegant |bow>[bow and quiver].
    A glowing |staff>[mage's staff].
    
    (click: ?sword)[(set: $weapon to "sword")(replace: ?weaponChoice)[Placeholder sword description.
    
    (display: "Confirm Choice")
    ]]
    (click: ?bow)[(set: $weapon to "bow")(replace: ?weaponChoice)[Placeholder bow description.
    
    (display: "Confirm Choice")
    ]]
    (click: ?staff)[(set: $weapon to "staff")(replace: ?weaponChoice)[Placeholder staff description.
    
    (display: "Confirm Choice")
    ]]
    
    3. A Confirm Choice passage, so you don't have to duplicate this text for each item.
    Do you choose this weapon?
    
    [[Yes->Weapon Chosen]]
    (link: "No")[(replace: ?weaponChoice)[(display: "Weapon Choices")]]
    
    4. Weapon Chosen passage, where you end up if you answer Yes:
    You have the $weapon
    
  • That worked perfectly, thank you! I'll try to use the search feature more diligently from now on. :P
Sign In or Register to comment.