Gosub nightmare

I have created a lucktest and originally it was in a separate scene but that didn’t work so now I am using gosub
Here is the gosub, at the bottom of my scene page:

*label lucktestgosub
*temp lucktest 0
*rand lucktest 0 12
*if (luck > lucktest)
	*set lucktext "lucky"
	*set luck -1
	*set lucky true
*else 
	*set lucktext "unlucky"
	*set luck -1
	*set lucky false
*return

It doesn’t return to where I called it though, which looks like this:

#Sneak upstairs
				*label sneakup
				*set snuck_stairs +1
				*choice
					#Test your luck
						*gosub lucktestgosub
						*selectable_if (lucky = true) #Lucky


Apologies, I have tried all I can to get it working

The problem seems to be in the selectable_if instead. You didn’t add a *choice for it. To make sure your gosub is returning to where you want to, simply add a text after it like "We returned here" or something.

Btw you can use gosubs from other scene files if you use *gosub_scene instead of just *gosub, the effect is the same.

1 Like

Thank uou, long day and I missed this
I am getting an error of:

club line 358: It is illegal to fall in to an *else statement; you must *goto or *finish before the end of the indented block

Try with the *return after the last line inside the “if”

You are having that error because you need to add a *goto inside the *if and *else chain or the *return in both as was suggested by Loudbeat.

This is a requirement from choicescript which you can disable if you use implicit control flow. I was using it when I made that *gosub for you a while back so you would need to use it to correct it.

Disabling it will remove the requirement allowing you to use *if and *else without getting annoyed with redundant labels all the time.

I don’t know if this necessarily the issue, but the tabs on these lines are wildly messed up.

#Sneak upstairs
	*label sneakup
	*set snuck_stairs +1
	*choice
		#Test your luck
			*gosub lucktestgosub
			*choice
				*selectable_if (lucky = true) #Lucky
				#[Unlucky choice?]

Many thanks to all, you fixed it!

It was an error with the return and I hadn’t tabbed the text after #Lucky

Just as an aside, I am trying to approach this logically and in my mind the code would go back as soon as it hit return, ie it could never reach a second return?! anyway…

Cheers!!

1 Like