It looks like you're new here. If you want to get involved, click one of these buttons!
<div id="you">You: $currenthp/$maxhp
You have $mana energy left
{(if: $turn is "you")[
(link: "Report")[
(set: $ehp to it - $weapondamage)
(set: $atk to "Punch")
(set: $atkdmg to $weapondamage)
(set: $turn to "enemy")
(set: $log to "atk")
(goto: "Combat")]
(link: "Repfuck")[
(if: $mana <5)(replace: ?Repfuck)[
No Energy]
(set: $ehp to it - $mdmg)
(set: $matk to "Repfuck")
(set: $mana to $mana -15)
(set: $turn to "enemy")
(set: $log to "magic")
(goto: "Combat")]
]
(elseif: $turn is "enemy")[
(link: "Continue")[
(set: $log to "enemy")
(set: $turn to "you")
(set: $currenthp to it - $eatk)
(goto: "Combat")]
]
(if: $currenthp <1)[(goto: "Lose")]
(if: $ehp <1)[(goto: "Win")]
</div>}
Comments
warning:
Based on the structure of your code example I am assuming that it's passage name is Combat and that the passage recursively calls itself (via the (goto: "Combat") statement) until the the fight is over. I also assume you are doing this because you want the section that displays the current values of your $currenthp, $maxhp, and $mana to update as the fight progresses.
The issue with using recursion like this is that every time the story engine traverses between passages it makes a copy of the current value all known variables (known as state)and makes that copy available to the passage about to be shown, it does this as part of the History system so that when the Reader uses the Undo link to go backwards the game engine can reset all the known variables back to their previous value. The copying process is expensive in both processing time and more importantly memory, because the History system currently needs to remember the state of every passage visited for each time it was visited.
A better option is to use a combination of named hooks and one of the revision macros like (replace: ), something like the following: