Invalid return; we've already returned from the last gosub


#1

Hi everyone, I seem to be having trouble with one of my scenes passing random test. The error is:
apollosphinx line 2163: invalid return; we’ve already returned from the last gosub

That line does correspond to a *return command but I’m not sure why it’s saying it’s “already returned.”

I’ve got two different sequences that have a gosub to this section (I checked they weren’t gotos).
It’s basically

*label homeending

A few paragraphs of text here (including a fake choice and some *if’s)

*return

The line above lable is a *goto_scene ending from a different storyline branch so there shouldn’t be anything from above ending up in this paragraph by mistake. I also haven’t used the *finish or *ending command anywhere in this scene. Any suggestions?


#2

(Code including the first line of the section above and below. I’ve taken out large blocks of text so there’s not pages to read through and avoid major spoilers.)

*goto_scene ending		
			
		
*label homeending
		
The time had marched by with a speed that made it hard to believe it'd been five years to the day since
*if (leaveegypt = "no")
	Text here
*if (leaveegypt != "no")	
	Text here
		
Text here

*fake_choice
	#"You know there's not.....
		Text here

	#"Sometimes I miss......
		Text here

	#"There are times....
		Text here

Text here

*if (sphinxinjury != "dead")
	Although    
*if (sphinxinjury = "dead")
	Surprisingly given everything that transpired, 

More text here

*return

*label spearchoice


#3

My coding guess would be that somehow your subroutine is being used as the story passes through it, and that might not count as a call. Maybe a choice hasn’t been finished, so the random test goes through in a way you weren’t counting. You could try putting the subroutine in a different or entirely new file and see what happens.


#4

It means that, for some reason, you are in the subroutine while not have actually called the subroutine. Honestly, I don’t think this is a problem that can be solved by sharing code, short of sharing the entire game. (Then again, maybe it’s a bug IDK, never count anything out.) That said, randomtest lists the choices it made for a reason. Can you reproduce by selecting the same options randomtest did?


#5

Thanks for the replies. I think I’ve worked it out. One of the gosub’s was within a fake choice which seemed to upset it. (Which I should have thought about since fake choices don’t usually link anywhere.) I changed the fake_choice to a normal choice and it seems to pass random test now :slight_smile: