Howdy, Stranger!

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

(hook:) macro

So, I've got a handle on most of the macros in the Harlowe documentation, except (hook:). "This macro, when attached to a hook, give it a specified name. It's equivalent to attaching a tag like |this> but you can programmatically determine the name this way (e.g. you can write (hook: $var))."
Can someone give me one or two real code examples? Tags, I totally get, but how you use (hook:) is not immediately apparent to me. Thanks.

Comments

  • As you can see from the third example, a variable based hook gets it's hook name from the variable's current value.

    (set: $var to "somevalue")

    |thetag>[This is a tag based hook]

    (hook: "hookname")[This is a hook macro based hook using a literal hook name]

    (hook: $var)[This is a hook macro based hook using a variable based hook name]

    (click: ?thetag)[clicked]
    (click: ?hookname)[clicked]
    (click: ?somevalue)[clicked]
  • Okay. So you can change  the value of variable as you go along and use it with a (click:) macro.
    Like, following your example I wrote this:

    (set: $tool to "saw")
    You arrive at the worksite and and get out your (hook: $tool)[saw].
    (click: ?saw)[It's a new Makita saw.]
    Later:
    (set: $tool to "hammer")
    It's time to nail a stud so you reach for your (hook: $tool)[hammer].
    (click: ?hammer)[It's on your toolbelt.]
    I guess I see the "how", but I'm still not sure about the "why." Why wouldn't I  just use a |saw> and |hammer> tag? Asking myself that question, the only answer I can come up with is that I can use the same variable over and over, but I'm not sure how that would really prove to be an advantageous thing.... Is it just a difference in preference or is there an application where (hook:) works better than separate nametags?

    Thanks.

    BTW, the variable-based hooks didn't work in the new Harlowe beta.



  • Denny wrote:

    BTW, the variable-based hooks didn't work in the new Harlowe beta.

    You may want to mention that on the Harlowe 1.1 thread (with an example)
Sign In or Register to comment.