Bad label error

I’m having trouble with my code.
A portion of the code in my choicescript_stats.txt…

*label gauntlet
*if show_armour != false
	*choice
		#	[i][b]POWER GAUNTLET[/b][/i]
			[i][b]ARMOUR[/b][/i]
			*stat_chart 
				percent armour_durability Durability
				percent armour_power Power
			*line_break
			[i][b]ABILITIES[/b][/i]
			*stat_chart
				percent re_gen Regeneration
				percent techno Techopathy/Technokinesis
				percent force_field Force field
				percent xray_infrared X-ray/Infrared Vision
				percent strength Strength
				percent speed Speed
				percent illusion Illusion
				percent cyborg Cyborgial Transformations
				percent flight Flight
	*choice
		#Abilities
			*gosub_scene power_gauntlet abilities

…is supposed to go to an unregistered scene labelled power_gauntlet

*label abilities
Regeneration
*choice 
	#Power Gauntlet
		*goto gauntlet

But it keeps giving me an error: Bad label gauntlet.
I could use some help

I’m not sure if this is what is upsetting the tester, but this looks wrong to me. Why is there a tab between the # and the [i]. Also why use a *choice for a single option? If it’s meant to be part of the same choice section, get rid of the choice above #abilities.

Edit: Is the*label abilities text on the same file as the choicescript_stats? You need to have them on the same page to direct properly using that command.

		#	[i][b]POWER GAUNTLET[/b][/i]
			[i][b]ARMOUR[/b][/i]
4 Likes

I did use a gosub command to link the two files together

You can’t use *goto to jump to a *label in a different scene. *goto and *gosub only work within the current scene.

Ordinarily, you have two options:

  • *gosub_scene scenename label, if you want to go label in scenename and then return to this scene; and
  • *goto_scene scenename label, if you want to permanently leave the current scene.

But since you’re in power_gauntlet as part of a *gosub, you probably want to just *return.

One problem: you can’t *return to a different label than where you left from. Instead, you’ll need to mark that condition with a global *create variable, and handle the *goto once you’re back in the original scene.

Add to startup.txt:

*create returning_label ""

choicescript_stats.txt:

...
*choice
   #Abilities
      *gosub_scene power_gauntlet abilities
      *if returning_label != ""
         *goto {returning_label}

power_gauntlet.txt:

*label abilities
Regeneration
*choice
   #Power Gauntlet
      *set return_label "gauntlet"
      *return
3 Likes

…But.

After saying all that, I suspect your system of breaking choicescript_stats.txt into multiple scenes connected by *gosub_scene, each of which has *choices of their own, is not going to be very efficient or easy to work with, as you’ve already seen. I mainly use *gosub_scene for little utility tools, like math calculations or string manipulation.

You do know you can keep all your labels in the same scene file, and just bounce down to them with *gosub and *return, right? That way you can use *goto to exit from them in certain cases, and it works just as you’d expect. I think setting choicescript_stats.txt up this way would be simpler. Just remember to add a *finish command somewhere above the subroutine labels so they don’t get triggered accidentally.

3 Likes

I decided to try this method and it’s worked beautifully. Thanks a bunch :grin:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.