Gosub error

Hi everyone. I’m having an issue with a gosub where it passes quicktest, but random test says:

RANDOMTEST FAILED: Error: part10boat2 line 2728: invalid return; gosub has not yet been called

I’m not entirely sure why it would say that? I have gosub’s in the main body of the text directing to a label and then a return. That’s the correct way to use gosub isn’t it?
ie
*gosub para1

*label para1
text here
*return

(I haven’t posted the code/text as it’s really long.) It’s also in a part of a WIP which has been up without anyone telling me they’re hitting problems with it, so I think it’s working ok for everyone.

Is there possibly a way to get to that text outside of the *gosub? If another section is falling through to that passage, it will hit the *return command without having used *gosub first and then flag it as invalid.

It might also be possible that if you have some *if sections styled thusly:

*if (stat > 7)
  *goto away
*if ((stat > 4) and (stat <=7))
  *goto somewhereelse
*if (stat <=4)
  *goto anotherplace

Then randomtest is somehow falling through, and changing it to an *if *elseif *else sequence would sort it.

1 Like

Point me to it? Will be happy to take a look.

1 Like

There shouldn’t be. There’s another gosub routine above it so there’s a “return” before you hit the one it’s flagging. Even if there was some way around that, above the first gosub is a solid “goto” which would catch anything that’d fallen though I’d think.

Have you tried moving the *gosub passage to the end of the file, then seeing if you still have the problem? And can you access the passage from other scenes, by any chance?

Thanks @Carlos.R
Maybe best bet is to put the code here for everyone to look at, otherwise it’s flagging the last line in the part10boat2 file. (It’s also the last line in this code.)

Edit: @Fiogan. It is actually at the end of the file (I usually plonk all the gosubs there to make them easier to find and help stop them getting misdirects.) Shouldn’t be accessable from any other scenes either :slight_smile:

*label ivysurface

*set abyssalinterfere "yes"

The boat has sunk low enough in the water, that waves are beginning to wash over the deck. Men and women scramble about the deck, some obviously driven half way to madness by the rusalki song; while others remain on the railing, holding guns aimed at the midnight water with shaking hands. Every now and again, the ghostly shape of one of the Abyssals would rise up to puck one from the deck, dragging them beneath the water. Terror taking hold, some of the sailors start to jump into the water, swimming desperately for the reef. One by one, they disappear and do not resurface. Looking for any who may have escaped the carnage, you notice a human has almost made it to the rocks at the base of the cove. How they managed to make it that far without being caught is anyone's guess. Concentrating on the fleeing figure, you not unexpectedly feel the waves of terror radiating from her mind. Although off to the side of the rusalki song's focus, enough of it has ensnared her mind, allowing you to see the guilt and pain swirls tangibly around her like an aura.
		

*goto tanyaescapechoice	 		




*label luscashowoff


"Do you like my pet? He was going to drive that boat out of here, weren't you?" she coos, patting the terrified man on the head whose struggles are quickly becoming weaker. "You should act quickly before all the good ones are gone newborn."
		
*fake_choice
	#"Kill them if you must Lusca, but don't play with them like that."
		"Then how do [i]you[/i] think should I play with them?" She giggles. "You [i]have[/i] to play with them ${name}. Draw out their deaths, eek as much terror as you can out of each one. There's no better way."
			
		"That's inhumane," you counter. 
				
		"What luck I'm not human then," she sings brightly. "Well, nice chatting with you but I've got things to do, places to go!"
		
		With that, she disappears into the darkness with her prize.
				
	#"Stop it. Let him go, he'll drown."
		"Why would I do that?" She looks genuinely bewildered. "They all belong to the sea today newborn. You know that! Now off you go. Be a good little rusalka and catch your own human."
				
		With that, she disappears into the darkness with her prize.
			
	#"Have you seen Ivy?"
		"Ivy? No, no, no," she sings brightly. "Just my little helmsman here. But soon, all your friends will be joining us. Soon, soon, soon."
				
		Her voice has developed a manic edge as she swims into the darkness with her prize.
			
	#"I'm meant to be looking for the escapees."
		"Hah!" She grins wildly. "There'll be no escapes today. Go up to the surface and see for yourself newborn."
				
		With that, she disappears into the darkness with her prize.
			
	#"There's no one in the water yet for me to grab."
		*set humanity -5
		"Oh there will be. Soon. Very soon." She giggles. "Have fun newborn."
				
		With that, she disappears into the darkness with her prize.
				
*return		


*label girlescaping


*set humanity +5
*set rage -5		
*label alexmemory
		
*set alexmemory "yes"
		
Something compels you to look further, skimming down below the broadcast emotions, to the memories that have surfaced below. Buoyed by the siren song they play out in vivid strings, like a movies without sound. Curiously you extend your mental presence to touch one.
		
Everything spins wildly as you're sucked downward, landing with a jolt into a body that is not your own. 
		
*page_break
		
Fugitively you sneak through darkened corridors to the rumbling of engines as they push the boat farther out to sea. You duck through a narrow hatch, pulling it closed behind you with a soft click. 
		
The figure wearily raises his head, blood matting the short blond hair into a caked mess over his right ear. He blinks red rimmed eyes. "I already told you, I don't know where it is."

"Shhh. It's me Alex," you whisper urgently, brushing long auburn hair back from your face and blinking hazel eyes to adjust to the sun streaming through the porthole above. 
		
*page_break
		
"Alexia? What are you doing here?! They'll kill you!" The man struggles vainly against the ropes that bind his arms to chair behind his back. 
		
"For goodness sake Jared, will you be quiet," you hiss desperately. "Do you want someone to come down here and find me here with you? As long as they don't know I'm here to break you out, they won't kill me. I'm part of the crew."
		
"You're [i]what?![/i] Are you insane? These are no two bit criminals Alex. How on earth did you convince them to even let you onto the boat. You know how to handle a boat I'll give you that, but if you knew one end of a rifle from the other, I'd be very much surprised. Oh my... you went to see Johnny J. didn't you? He set you up with this gig. Don't you know he's the one who got me into this mess in the first place?!"
		
"No," you snap angrily. "Trying to cheat a syndicate out of what you promised to get for them got you into this."  
		
He may be your brother, but he's such a fool sometimes. This wouldn't be the first time you've had to bail him out of a mess, but it's certainly the most dangerous. 
		
"I didn't..."
		
"That's what you always say," you cut him off sharply. "What matters is how to get you out of here. Now that I've found you, we can try and work that out."
		
*page_break
		
"You don't get me out," He drops his head to rest his chin against his chest. "I'm sorry Alex, but since I can't give them what they want, I'll serve as a warning to others instead. Unless you've got an armour plated speed boat parked outside, this is where it ends."
		
"You don't know that..."
		
"I won't get you killed over my mistakes. I trust you were at least smart enough to get that scoundrel to set you up with an alias?"
		
You nod silently.
		
"Then get off this ship as soon as you can and disappear. You have no idea who you're dealing with... I didn't."
		
A metallic clank of steel capped boots on metal stairs sounds faintly from down the corridor. 

"Someone's coming," you hiss. "I have to go. But I promise you that I'll come back as soon as I can."
		
Quickly you duck out the door, clicking it closed behind you as one of the more senior crew members appears around the corner. He brushes past you without recognition, and walks through a doorway at the end of the corridor. You hesitate, debating whether to slip back into the room where your brother remains bound. With a shake of your head, you dismiss it as unnecessarily risky. Once you've to devised a plan of escape for you both, it'll be time enough. Maybe you can even get Johnny to help... Although it's the kind of help that is sure to cost you. No matter, you'll get the money somehow. 
		
*page_break [i]...Skip...[/i]
		
The memory jolts jarringly... flickering over something too painful to remember despite the seductive music trying to force it to the surface. 
		
Your brother led onto the deck... [i]Skip...[/i] Wide blue eyes bore into your own, warning you not to make a move... [i]Skip...[/i] Lifeless eyes stare blindly at the sky, glazed and unmoving... 
		
It's all your fault... You knew he was up to something, but you were too busy to investigate... Too annoyed at the risks he continually took... Too slow to realise something was critically wrong and look for him... Too stupid to take the chance to free him when it was given in the cabin that day... Too cowardly... perhaps you deserve to die as well... 
		
*page_break [i]...Snap...[/i]
	
You're thrown from the vision like a rubber band snapping back into place, the transition sharp and disorientating. Despite her silent accusations that she deserves to join her brother, something compels her to continue to thrash weakly towards the shore. Given a few more minutes, she'll no doubt be hidden from view among the rocks. 
		
*return


		

So all the branches *finish or *goto_scene above that point, then? Did you check in case you have a stray *goto (the label name) typo somewhere instead of *gosub?

1 Like

Your *return in the code you posted is at the end of *label girlescaping

Maybe try cutting all the page breaks in this label just as an experiment, in case they somehow break a *gosub

1 Like

Actually that’s a good point. Maybe I’ve messed one of those up in there. Will have to have a hunt though it.

Edit: Great idea, and definitely something I’d do. But doesn’t seem to be the case. I’ll try @Carlos.R’s idea when I get back :slight_smile:

1 Like

If you have any of the two in your file:

*goto girlescaping

or

*goto alexmemory

It will lead to an error because both will reach the *return at the end of the file without being *gosubs. If you do, you will need to change them to *gosub instead.

2 Likes

I missed a goto for alexmemory :confounded: Feeling a bit silly now. Thank you everyone for the help! (Knew that was something I’d be likely to do @Fiogan!)

2 Likes