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>>

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

<<if $monster.VIT < 1>>
<<goto "Win">>
<</if>>
<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")]
</div>}

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:
evalJavaScript/<@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:167:5344
evalJavaScript@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:167:5315
n/<@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:167:16924
value/<@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:167:11548
r/<@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:165:24759
t/<@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:165:24536
dispatch@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:60:10263
add/q.handle@https://twinery.org/2/#!/stories/9c2e515c-7ea5-4707-b458-192720243541/play:60:8325

 

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 =.
...