0

I'm making a simple text-based battle between the player and a dragon. I use Menus to have the player select from a set of options. The Menu then obviously goes to the Lbl assigned to the selected option. Within the while loop for the game I can end the Lbls by using the End command to go back to the start of the loop, but when the player chooses the difficulty, there is no loop. How do I prevent all the subsequent Lbls from being executed in this code:

:Menu("DIFFICULTY?", "EASY", 00, "MEDIUM", 01, "HARD", 02)
:Lbl 00
:75->D
://some end statement
:Lbl 01
:150->D
://some end statement
:Lbl 02
:300->D
://some end statement

Because currently, all Labels are executed resulting in the dragon having 300 health no matter the option chosen. (I don't want a work around with scalars or some other trick, I want to know how I can emulate what I described in a general situation so I can use the technique in future programs).

StrongJoshua
  • 975
  • 10
  • 24

1 Answers1

2

You can add another label at the end and go to it after setting the dragon's health.

Like this:

:Menu("DIFFICULTY?", "EASY", 00, "MEDIUM", 01, "HARD", 02)
:Lbl 00
:75->D
:GoTo 03
:Lbl 01
:150->D
:GoTo 03
:Lbl 02
:300->D
://you don't need a GoTo here since there are no more labels and Lbl 03 is the next line.
:Lbl 03
://The rest of your code...

This will exit out of the switch-style setup you are using and continue with the code.

Personally, I would use an if then, elseIf then, else, endIf block to achieve this goal.

PGmath
  • 381
  • 3
  • 16