Elseif error (cannot fall into else)


#1
"How..how long was I out?" you ask.

She points behind you. You turn and see a shaky row of fifteen tiny scratches on the wood of the cot. "You made those, one each day."

You grasp her hand. "Thank you" you say.

*if take_tyres
	"Oh don't thank me, I don't have much else to do anyway. If you really want to thank someone it should be that fellow you came here with"
	
	"Tyres?" you ask surprised.
	
	"Is that his name? I never bothered asking. He came in here every chance he could and helped me, even shared half his rations so you wouldn't stave. And trust me, they don't give much around here. Said you he owed you."
*elseif take_tyres = false
	She cackles. "You think this was free? Salves and bandages don't grow out of the sand. You owe Mama Jay now."
	*goto walking_to_arena_no_whip

*label walking_to_arena_no_whip
You eat some cold food and return to bed. Hours later you wake up feeling rested and step out into the sun.

The fire beats down across your back immediately, sweat picks your skin and dampens the bandages. You look around but it seems you're alone out here. All the tents are empty. A slave runs past you, scampering downhill. 

I keep getting this error: It is illegal to fall in to an *else statement; you must *goto or *finish before the end of the indented block.

Any ideas why?


#2

at the end of the *if take_tyres there’s no *goto, it skips directly to the *elseif


#3

Yup. Because you can’t fall into on else (which apparently also counts for an elseif) statement. Either end the block of text below the if statement with a goto or finish or change the elseif to an if. (Because you are allowed to fall in to an if statement.)


#4

Thanks! fixed it (twentyyyyyyy)


#5

Umm, not to be rude… But it’s spelled Tires, not tyres.

P.S. Good way to find the correct pronunciation? Type the word in your search browser.


#6

Just an FYI for other readers, there’s actually two main ways to fix this:

*if foo
    true text
    *goto next
*else
    not true text
    *goto next
*label next

or

*if foo
    true text
*if (foo = false)
    not true text
*label next

@COGZealot Kinda a little rude, and you’re wrong. :-p (Seriously, never include ‘I don’t mean to be rude’ or ‘I’m not ___ but’ at the start of the sentence. All it does it put the idea that you are what you’re saying you aren’t in people’s minds.) (Oh, and, one of those things where you need to to exactly what you said.)


#7

The intent wasn’t to be rude… What did you think that I misspelled?


#8

Guys Guys…Tyres is the name of one of my characters, hence the capitalization. No harm done.


#9

Also remember if using *elseif the last statement must be an *else


#10

Really? I have other places where I ended with an elseif


#11

Check the link above, just edited my post XD :slight_smile:


#12

Did they pass randomtest, though? I had a terrible time with randomtest getting stuck for a while, until I realised it was because of not making sure to always end a string of mutually exclusive *ifs with an *else.


#13

Yeah they do, they work fine, which is what confuses me.

*if take_tyres
	"Oh don't thank me, I don't have much else to do anyway. If you really want to thank someone it should be that fellow you came here with"
	
	"Tyres?" you ask surprised.
	
	"Is that his name? I never bothered asking. He came in here every chance he could and helped me, even shared half his rations so you wouldn't stave. And trust me, they don't give much around here. Said you he owed you."
	*goto walking_to_arena_after_recover
*elseif take_tyres = false
	She cackles. "You think this was free? Salves and bandages don't grow out of the sand. You owe Mama Jay now."
	*goto walking_to_arena_after_recover

This bit works fine


#14

Yikes… Alright that is akward :laughing:. I apologize and hope that you all have a great weekend, I’m out.


#15

That’s interesting! Maybe because it’s not a choice sequence requiring *goto, and you could theoretically have done the same thing using @RETowers’s second example?

My frozen *ifs always revolved around redirecting after choices.


#16

True, that section is standalone, it isn’t linked to a choice


#17

Pretty sure that _should_n’t past random/quicktest. There’s a little more information on why there’s requirements in the docs here. Basically it’s to prevent typos and ‘didn’t consider everything’ errors.

@COGZealot http://grammarist.com/spelling/tire-tyre/


#18

Tangential FYI, since it’s a name, but “tyres” is the correct spelling of “tires” in British English.


#19

I think it passed since it was a true/false. So I didn’t really need the elseif since there was only one other option