Need help with goto macro

Twine Version: 2
Story Format: harlowe 3.2.1
so im trying to make it so my goto command for winning a fight will take you to the respective enemies win dialog
(if: $hp <1)[(goto: “Elose”))]
(if: $ehp <1)[(goto: “Ewin”))]

so i was wondering how do i make the Elose and Ewin correspond to a variable or something to make them take you somewhere else or do i have to create my fight code for every enemy instead

Please use the toolbar’s Preformatted text option when including a code example in your comment, it helps to make the code easier to read and stops the forum’s software converting valid standard quotes into invalid Typographical (curvy) quotes.

There are a couple of issues with your example:

  1. You have an extra close bracket ) after each of your (goto:) macro calls.
  2. The second of your (if:) macro calls should be an (else-if:) macro, because you only want to action one of those two conditions at any time. Known as mutually exclusive.

The following is a corrected variation of your original example.

(if: $hp < 1)[(goto: "Elose")]
(else-if: $ehp < 1)[(goto: "Ewin")]

You can use variables to store the Name of each of two Passages you want to be visited, those variables can be either Temporary or Story based depending if the code that determined which Passage Names to use is contained within the same Passage as the (if:)/(else-if:) related condition checks.

The following example assumes the target Passage Names will be assigned within the same Passage as the condition checking, so Temporary variables are used. If the target Passage Names are determine in a different Passage then you should change the code to use Story variables instead.

(set: _EnermyLose to "Elose")
(set: _EnermyWin to "Ewin")

(if: $hp < 1)[(goto: _EnermyLose)]
(else-if: $ehp < 1)[(goto: _EnermyWin)]