0 votes
by (310 points)

So using this as a guide and also utilizing objects through a story init passage, I am working on setting up a combat system adapted from this guide on reddit with sugarcube and without any of the css. https://www.reddit.com/r/twinegames/comments/3mq2rs/combat_system_in_harlowe_my_twine_2_guide_3/?st=jfjuwjbd&sh=2c4e031a

I seem to have an error cropping up within the Log passage. Below is what I adapted the Harlowe code into, as well as the error and the original harlowe code. If you need more resources I will provide them.

<<if $turn == 0>>
[[Punch|Combat][$monster.VIT to -= 10, $atk to "Punch", $atkdmg to 10, $turn to 1, $log to "atk"]]

[[Sword|Combat][$monster.VIT to -= 30, $atk to "Sword", $atkdmg to 30, $turn to 1, $log to "atk"]]

<<elseif $turn == 1>>
[[Continue|Combat][$log to "enemy", $turn to 0, $VIT to -= $monster.STR]]

<<if $VIT < 1>>
<<goto "Lose">>

<<if $monster.VIT < 1>>
<<goto "Win">>
<div id="you">You: $hp/100
{(if: $turn is "you")[

(link: "Punch")[
(set: $ehp to it - 10)
(set: $atk to "Punch")
(set: $atkdmg to 10)
(set: $turn to "enemy")
(set: $log to "atk")
(goto: "Combat")]

(link: "Sword")[
(set: $ehp to it - 30)
(set: $atk to "Sword")
(set: $atkdmg to 30)
(set: $turn to "enemy")
(set: $log to "atk")
(goto: "Combat")]

(elseif: $turn is "enemy")[
(link: "Continue")[
(set: $log to "enemy")
(set: $turn to "you")
(set: $hp to it - $eatk)
(goto: "Combat")]
(if: $hp <1)[(goto: "Lose")]
(if: $ehp <1)[(goto: "Win")]

Apologies! An error has occurred. You may be able to continue, but some parts may not work properly.

Error: SyntaxError: expected expression, got '-='.

Stack Trace:


1 Answer

0 votes
by (63.1k points)
You have "to -=", which is nonsense. If you're using one of the assignment operators (-=, +=, *=, etc), you don't need "to", which is TwineScript for =.