Howdy, Stranger!

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

Several questions: Hooks, History, and Setter Links

Hi, I'm brand new to twine and running into some difficulties.

First, I am getting a "missing ] after element list error" for the following hook:

leaving me behind in a pool of my own(if: $bloodied lte 1) [[[blood. | Art Gallery]]]

I did put an extra bracket at the start and end but it doesn't register I guess?

Second, I have a "Missing ) after argument list" for the following:

(if: $light is 0 and not $history: contains "Art Gallery")

I'm guessing I need some parentheses for adding the not history condition but I've tried multiple combinations and all of them return syntax errors. Is there something about using "and" statements I don't understand?

I also couldn't find any documentation about using "setter links" to alter variables in this version.

Any help would be greatly appreciated!

Comments

  • If you haven't seen it yet, the Harlowe documentation.

    Sinthioth wrote:

    First, I am getting a "missing ] after element list error" for the following hook:
    leaving me behind in a pool of my own(if: $bloodied lte 1) [[[blood. | Art Gallery]]]


    You have two issues here:
    [list type=decimal]
    There is no lte operator in Harlowe, you want the <= operator.  That's what's causing the "missing ]" error.
    You probably do not want to put leading/trailing whitespace in your link markup.  Harlowe treats leading and trailing whitespace in the link markup as significant, meaning your like goes to " Art Gallery" (note the leading whitespace) instead of "Art Gallery" as you probably intended.


    Sinthioth wrote:

    Second, I have a "Missing ) after argument list" for the following:
    (if: $light is 0 and not $history: contains "Art Gallery")


    You murdered the (history:) macro and it seems that you must wrap the history contains expression in parens or it breaks when used with the not operator.  For example:

    (if: $light is 0 and not ((history:) contains "Art Gallery"))[]

    Sinthioth wrote:

    I also couldn't find any documentation about using "setter links" to alter variables in this version.


    Setter links do not exist in Harlowe, though someone may have figured out a workaround.  SugarCube has them.  I'm unsure about Snowman.
  • Ahhhh I see, thank you very much!
  • One way to simulate Setter Links in Harlowe is by using a hook, click, set, and goto macro combo like the following:

    [Option 1]<link1|
    [Option 2]<link2|

    (click: ?link1)[(set: $var to "A")(goto: "Next Passage")]
    (click: ?link2)[(set: $var to "B")(goto: "Next Passage")]
    In the Next Passage passage you can selectively show text based on the value of the variable:

    (if: $var is "A")[The text to be shown if Option 1 was selected in previous passage.]
    (if: $var is "B")[The text to be shown if Option 2 was selected in previous passage.]
  • Interesting, I may try that out! Also, after applying it the "not history" code isn't working as MadExiles described; I entered it as follows

    (if: $light is 0 and not (($history:) contains "Art Gallery"))
    but still get a syntax error. Does something special have to happen to the "history" macro if it's in an and statement maybe? I'm at a loss.

  • Sinthioth wrote:

    (if: $light is 0 and not (($history:) contains "Art Gallery"))

    Small syntax error in your code, (history:) is a macro so you don't want/need a $ before the macro name.

    Try without the extra $:

    (if: $light is 0 and not ((history:) contains "Art Gallery"))
  • You've misspelled the macro name (again).  It's (history:) not ($history:).  There is no dollar sign ($) in macro names (that's the $variable sigil).
  • SON OF A

    I must've looked at that line a hundred times I can't believe I didn't notice that -.- Thanks for being patient with me, can you tell this is the first programming-esq thing I've ever done? P:
  • Another way to simulate a Setter Link, and the one I should of thought of first, is to use a link, set, and goto macro combo:

    (link: "Option 1" )[(set: $var to "A")(goto: "Next Passage")]
    (link: "Option 2" )[(set: $var to "B")(goto: "Next Passage")]
  • I have a similar (history:) question.

    I created a game that's a personality quiz, and I want to display different sentences based on what passages the reader has visited. This is what I have so far:

    (if: ((history:) contains "SlantRight"))You are a people person with a nice balance between your head and your heart.

    (if: ((history:) contains "SlopeDown"))You can be pessimistic and worry easily.

    The problem is that both sentences appear even if those passages are not visited. Can anyone help me with the syntax?
  • The format of your (if:) macros are wrong, the contents needs to be surrounded with square brackets.

    Try the following:

    (if: ((history:) contains "SlantRight"))[You are a people person with a nice balance between your head and your heart.]

    (if: ((history:) contains "SlopeDown"))[You can be pessimistic and worry easily.]
    NOTE: Even though the Harlowe documentation shows many examples of the (if:) macro without the square brackets they are required, as show by the following example from there:

    (if: $x is 2)[This text is only displayed if $x is 2.]
Sign In or Register to comment.