Howdy, Stranger!

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

[Harlowe] Re-usable hooks

edited March 2015 in Help! with 2.0
Hay guys!

It seems, that hooks are one-offs - when I use (click:) and (mouseover:) sensor macros on some hook, I can't use them on this hook again (so, when I click on hook, or move mouse cursor over it, it does what it has to and then becomes unavaiable).

I've figured out, that I can re-animate hooks using (live:) macros.

My question is:
Is there any way to make hooks re-usable without (live:) macros and re-entering current passage?

Thanks :)

Comments

  • I believe the simple answer is No.

    If you look at the HTML generated by a hook without any associated sensor macros it is just the related text wrap in a <tw-hook> tag, so:

    |hook>[Click this link]

    becomes

    <tw-hook class="" name="hook" title="Hook: ?hook">Click this link</tw-hook>
    When you attach a sensor macro to the hook the generated HTML changes:

    |hook>[Click this link]
    (click: ?hook)[link was clicked]

    becomes

    <tw-enchantment class="link enchantment-link">
    <tw-hook class="" name="hook" title="Hook: ?hook">Click this link</tw-hook>
    </tw-enchantment>
    <tw-expression class="" type="macro" name="click" title="(click: ?hook)"></tw-expression>
    When you click on the link the HTML dynamically changes to:

    <tw-hook class="" name="hook" title="Hook: ?hook">Click this link</tw-hook>
    <tw-expression class="" type="macro" name="click" title="(click: ?hook)"></tw-expression>
    As you will notice, the <tw-enchantment> (and the code associated with the tag) is dynamically removed when the link was clicked and this is basically why you need to re-attach a new sensor macro to re-enable the hook.
  • Thanks for information! :)

    Still, I guess I found a workaround to solve this. Basically, I replace hooks with (display:) of passages, in which I store my mouseover macros, which also call display of themselves, so it is a recursion of some kind. I'll give more info and examples of the code after investigating this further.

    Added: so, here is my explanation.
    The main thing is, you'll have to put your sensor macros into another passage. Lets call it click_macros
    {
    (click: ?c1)[
    (if: $count is 0)[
    (replace: ?description)[$str1]
    (set: $count to 1)
    ]
    (else:)[
    (replace: ?description)[$str2]
    (set: $count to 0)
    ]

    (replace: ?code)[(display: "click_macros")]
    ]
    }
    You will see these ?description and ?code hooks in the main passage:
    {
    (set: $str1 to "Description1")
    (set: $str2 to "Description2")
    (set: $count to 0)

    }
    You see a [Button]<c1| and [[Erase all->main]] here.

    []<description|{
    []<code|
    (replace: ?code)[(display: "click_macros")]
    }
    So, as you see, click_macros passage code replaces itself into ?code hook every time I click the ?c1 hook, and so it lives.

    I'll attach this example as "re-usable hooks" and another one a bit more complex, but fancier example with both (click:) and (mouseover:), maybe somebody will find them useful :)
Sign In or Register to comment.