Howdy, Stranger!

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

How to include function in if statement - Harlowe

Is there any way possible to include a function inside an if statement?

Say if I have something like this:
(if: introcheck is 0)[(set: ($name) as (prompt: "What's your name?"))]

When I run the game, it says something like this:
☕ Unexpected identifier►☕ Unexpected identifier►

Help!

Comments

  • There are a number of syntax errors in your example:

    a. your introcheck variable is missing a dollar sign at the start, this results in the first Unexpected identifier error.

    b. you have unnecessary brackets around the $name variable.

    c. you are incorrectly using an as operator to do an assignment, when it should be a to operator.

    Try the following:
    (if: $introcheck is 0)[(set: $name to (prompt: "What's your name?"))]
    

    note:
    If the $introcheck variable is meant to track if something has occurred or not, then you should use a boolean value (true/false) instead of 0 and 1.
    Initialize the variable in your startup tagged passage like so:
    (set: $introcheck to false)
    
    ... and change the check to be:
    (if: not $introcheck)[(set: $name to (prompt: "What's your name?"))]
    
  • You seem to be missing the variable sigil on introcheck, have unnecessary parenthesis wrapped around $name, and are trying to use as for assignment when you should be using to.

    Try something like the following:
    (if: $introcheck is 0)[(set: $name to (prompt: "What's your name?"))]
    
Sign In or Register to comment.