0 votes
by (300 points)

I have written a battle scene in my story but I want to add a few items that would change your stats in the battle but  i cant seem to make it work..I don't know exactly where to put the code.

This is the code that send the player to battle:
(link: "Fight Baal")[
(set: $ehp to 2000)
(set: $mhp to 2000)
(set: $ename to "Baal")
(set: $turn to "you")
(set: $hp to 1000)
(set: $mana = 100)
(set: $eatk to 85))
(set: $eatkname to "Slash")
(goto: "Baalcombat")]

but I want to add an item that would change the stats.. for instance something like this:
(if: $amulet is 1)
(set: $mana to 200)

Any help would be much appreciated.

 

1 Answer

0 votes
by (68.6k points)
selected by
 
Best answer

In future.  You should always mention both the compiler and story format, and their versions—because, yes, it's important.  Generally, you do that via tags—though it doesn't hurt to also mention them in the body of your question.

In this case, it seems like you're using some version of Harlowe with, I'm guessing, some version of Twine 2.


First.  Your example has too many closing parenthesis on the $eatk assignment.  I don't know if that was a transcription mistake in the example here or if that's in your actual code, but you might want to check on that.

The (if:) macro, and its siblings (else-if:) and (else:), require a hook after the macro tag.  For example:

(if: $amulet is 1)[(set: $mana to 200)]

In your case, it looks like you'll probably want to pair it with an (else:) macro since you have two conditions.  For example:

(if: $amulet is 1)[(set: $mana to 200)]
(else:)[(set: $mana to 100)]

With that, the whole thing together might look something like the following:

(link: "Fight Baal")[
(set: $ehp to 2000)
(set: $mhp to 2000)
(set: $ename to "Baal")
(set: $turn to "you")
(set: $hp to 1000)
(if: $amulet is 1)[(set: $mana to 200)]
(else:)[(set: $mana to 100)]
(set: $eatk to 85)
(set: $eatkname to "Slash")
(goto: "Baalcombat")
]

 

...