Howdy, Stranger!

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

The (if:) command should be assigned to a variable or attached to a hook.► Macros like this should a

I have limited education on coding so bare with me on the lingo as I will probably use it incorrectly, but I get this error message all the time on what seems like very basic code statements involving if and else. Copied and pasted below is one of many pieces of code I have that gives the same error, feel free to let me know whats going on here and in general so I can apply to other code as well please.

I am basically trying to set up a (if your Wisdom score is 9 or higher, a link will be displayed to take you to the 'create a cleric' passage, else, text stating that the class is unavailable is displayed).

The error occurs after the line ...
Cleric ~ (if: $Wis>8)(set: $WisTemp1= "Available")(else:)(set:$WisTemp1= "Unavailable")

Code for whole passage is as follows:

{
(set: $Str=((random:1,6)+(random:1,6)+(random:1,6)))
(set: $Int=((random:1,6)+(random:1,6)+(random:1,6)))
(set: $Wis=((random:1,6)+(random:1,6)+(random:1,6)))
(set: $Dex=((random:1,6)+(random:1,6)+(random:1,6)))
(set: $Con=((random:1,6)+(random:1,6)+(random:1,6)))
(set: $Cha=((random:1,6)+(random:1,6)+(random:1,6)))
(set: $StatArray=(a:$Str,$Int,$Wis,$Dex,$Con,$Cha))
(set: $PP=0)
(set: $GP=(((random:1,6)+(random:1,6)+(random:1,6))*10))
(set: $EP=0)
(set: $SP=0)
(set: $CP=0)
}
**CHARACTER SHEET**

**Attributes**
STRENGTH: (print:$Str)
INTELLIGENCE: (print:$Int)
WISDOM: (print:$Wis)
DEXTERITY: (print:$Dex)
CONSTITUTION: (print:$Con)
CHARISMA: (print:$Cha)

**Coins**
PP: (print: $PP)
GP: (print: $GP)
EP: (print: $EP)
SP: (print: $SP)
CP: (print: $CP)

**Class Choices**

Cleric ~ (if: $Wis>8)(set: $WisTemp1= "Available")(else:)(set:$WisTemp1= "Unavailable")

Elf ~
Dwarf ~
Fighter ~
Halfling ~
Magic-User ~
Thief ~

Roll a Character

Comments

  • You need to state the name and full version number of the Story Format you are using, as answers can be different for each one. I will assume you are using the default version of Harlowe which is currently v1.2.4. Please use the code tag when posting examples - it's the C on the editor bar.

    Shutt wrote: »
    Cleric ~ (if: $Wis>8)(set: $WisTemp1= "Available")(else:)(set:$WisTemp1= "Unavailable")
    As demonstrated in the (if:) macro's examples, you need to use a hook to contain the code associated with that macro. This is also true for the (else-if:) and (else:) macros.

    After adding the required hooks, your example would look like the following:
    Cleric ~ (if: $Wis>8)[(set: $WisTemp1= "Available")](else:)[(set:$WisTemp1= "Unavailable")]
    
Sign In or Register to comment.