Howdy, Stranger!

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

Making link hooks conditional in harlowe 2

I'm using datamaps to track the player's state, and it would be really nice if I could make the appearance of certain links depend on specific stats being set to specific values. As an experiment, I made a really quick prototype container and link:
{(set: $player to (datamap: 
"Name", "Bob", 
"strength", 10, 
"dexterity", 8,
"wisdom",3,
))}

(if: $player's strength < 5)[[You can barely move the boulder]]
(else:)[[You casually toss the gigantic rock over your shoulder and move on]]

This obviously generates an error- the if macro says "the command should be assigned to a variable or attached to a hook," but I thought I'd done both; $player's strength is a valid variable, and there are no spaces or anything between the macro and the hook. Am I making an obvious syntax gaffe, or are links not intended to be combined with the if: macro?

Comments

  • edited February 2017
    I'm not super familiar with Harlowe, so I'm not sure if this is the problem, but hooks are usually inside a pair of single brackets, whereas yours are inside double brackets. Again, no idea if that really matters, but it might be a problem, especially since double brackets are generally the link syntax.

    Hopefully someone more familiar with harlowe can help you. If not I'll load it up and play around with it and see if I can help.

    Edit: If you need a link after the if, try the (link-goto) macro.
  • Oh, I found something... this is weird to the point that I might be doing something wrong, but it does work; what you do is, you wrap the whole link in two bracket pairs instead of one. This produces an error:
    (if: condition)[[go to this link]]
    
    However, this works just fine!
    (if: condition)[[[go here instead]]]
    

    The only drawback is that the editor doesn't seem to parse it correctly, so you'll end up getting a new passage generated, but deleting that and ignoring the error indication results in something that works as intended.
  • edited February 2017
    This obviously generates an error- the if macro says "the command should be assigned to a variable or attached to a hook,"
    Your issue is a case of not enough square brackets.

    An (if:) macro with it's associated hook looks like the following:
    (if: $player's strength < 5)[...]
    
    ... and a markup based link where the Link Text and the Target Passage Name are the same looks like:
    [[You can barely move the boulder]]
    


    So you when you combine them together you need three open square brackets and three closed square brackets, but due to an error in the Auto Create Missing Passage feature of the Twine 2 application's editor you can't have three open square brackets in a row so you need to add a space between the first and second open square bracket like so:
    {(set: $player to (datamap: 
    "Name", "Bob", 
    "strength", 10, 
    "dexterity", 8,
    "wisdom",3,
    ))}
    
    (if: $player's strength < 5)[ [[You can barely move the boulder]]]
    (else:)[ [[You casually toss the gigantic rock over your shoulder and move on]]]
    
  • Oooh that's why the editor was freaking out, thank you!!! That fixes everything :)
Sign In or Register to comment.