Howdy, Stranger!

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

Missing Hook - Ignoring Conditions Except When They Apply

I want a click ignored if a hook isn't present:
(click: ?Bunyon)[(if: $located is "Quicksand")[(goto: "Lakeside")]

This works when the hook is present, but when it isn't says -
The (click:) command should be assigned to a variable or attached to a hook.

So, I want to do something to test if the hook is present - like this:
(if: $inv contains "Rusty Axe")[(click: ? ... etc.]

Or maybe -
(if: $inv contains "Rusty Axe" and click: ? ... etc.]

But that doesn't work either.

Any help would be gratefully appreciated.

Comments

  • Please state the name and full version number of the story format you are using, as answers can be different for each one.

    Hooks (both associated and named) are references, not variables and I can't think of a built-in way to determine if one has been defined of not. You can't check their 'value' like you can with a $variable using code like the following.
    [Something]<abc|
    
    (if: ?abc is "Something")[found ABC]
    
    note: In Harlowe v1.2.3 the above will just silently fail, where as in v2.0.0 it will result in a "Cannot convert undefined or null to object" error because named hooks can no longer be accessed like variables.
  • That's perfect. Thank you very much!
  • A messier solution, but one that worked, was to store all of the conditions in the object itself:
    (set: $object to "[Rusty Axe]<Axe|
    (click: ?Axe)[It has the magic word [Bunyon]<Bunyon| on it]
    (click: ?Bunyon)[(if: $located is 'Quicksand')[(goto: 'Lakeside')]
    (else:)[That doesn't work here]]")
    
  • nate wrote: »
    ...but one that worked
    As I stated in my previous comment, the example was not a solution.

    Why are you using (click:) macros combined with named hooks when you could do the same with the (link:) macros?
  • I didn't mean to imply your solution didn't work, just that I also tried a different approach that also worked. Sorry for any misunderstanding there.

    I'll try it with (link:) - It was old code I was finally getting around to revisiting. Whatever my rationale for using click: originally was has been lost in the mists of time.
Sign In or Register to comment.