Illegal to fall into an else statement


#1

I ran the quicktest on my game so far, and all was going well until my savegame file came up with "Error: savegame line 175: It is illegal to fall in to an *else statement; you must *goto or *finish before the end of the indented block."
I am at a loss on how to fix it. There are 8 lots of the goto in the indented block. I thought I had just messed up the indentation somewhere, but it is the restore section which is basically a clone of the save just above it which passes with no errors. Any idea’s would be greatly appreciated.


It is illegal to fall in to an *else statement; you must *goto or *finish before the end of the indented block
#2

It sounds like you are missing a *goto or *finish in one of your *if branches. Check the lines above the error and make sure that every *if option ends with a *goto or *finish.

If you wish the *if statement to apply without a *goto, you can’t use *else.


#3
*if save_flag = "save"
	*set save_flag ""
	GAME SAVED!
	*line_break
	If your adventures prove too much and you become one of the "living impaired" you can always start again from here.
	*line_break
	(Unless you close the browser... then you are on your own)
	*set save_msg true
	*page_break Continue
	*if return_to_scene = "home"
		*goto_scene home
	*elseif return_to_scene = "chapter1"
		*goto_scene chapter1
	*elseif return_to_scene = "chapter2"
		*goto_scene chapter2
	*elseif return_to_scene = "chapter2b"
		*goto_scene chapter2b
	*elseif return_to_scene = "chapter3"
		*goto_scene chapter3
	*elseif return_to_scene = "chapter4"
		*goto_scene chapter4
	*elseif return_to_scene = "chapter5"
		*goto_scene chapter5
	*elseif return_to_scene = "chapter6"
		*goto_scene chapter6
	*elseif return_to_scene = "chapter7"
		*goto_scene chapter7
*elseif save_flag = "restore"
	*page_break
	Couldn't quite cut it huh? Well thats ok, backtrack a bit and see if you         can do better.
	*page_break Continue
	*if return_to_scene = "home"
		*goto_scene home
	*elseif return_to_scene = "chapter1"
		*goto_scene chapter1
	*elseif return_to_scene = "chapter2"
		*goto_scene chapter2
	*elseif return_to_scene = "chapter2b"
		*goto_scene chapter2b
	*elseif return_to_scene = "chapter3"
		*goto_scene chapter3
	*elseif return_to_scene = "chapter4"
		*goto_scene chapter4
	*elseif return_to_scene = "chapter5"
		*goto_scene chapter5
	*elseif return_to_scene = "chapter6"
		*goto_scene chapter6
	*elseif return_to_scene = "chapter7"
		*goto_scene chapter7

This is basically it. The indents slipped a bit on the text when I copied it over. I still can’t see why I am wrong :frowning:


#4

Oh got it, sorry to waste your time. Didn’t finish the elseif column with an else. All sorted now. :smile:


#5

Hey, i keep getting the error shown in the title of this post. i really am stumped because it seems like all my lines have a goto.
heres my code

Blockquote
*selectable_if (cPush = true) #Push the Centre
*if (warscore > 0) and (deployment = 2)
You manage to push back the villains forces, inflicting heavy losses and gaining ground!
*set warscore +10
*set hero -50
*set villain-150
*goto combat
*elseif (warscore < 0) and (deployment !=2)
The attempted push is a catastrophic failure! As a result, the villain counterattacks the flanks!
*set hero -150
*set villain -50
*goto vPush
*elseif (warscore > 0) and (deployment !=2)
Your men gain some ground in the push, however it is more or less a stalemate.
*set hero -50
*set villain -50
*goto combat
< BlockQuote

*note on the code
the indentation isnt appearing properly in the post, but i have done the indentation properly in the actual code.


#6

If you have if/elseif/elseif you need to finish with an *else. You can’t end with an elseif.


#7

FYI, use triple grave accent ``` (below Esc key) as a tag to preformat your code. Keyboard shortcut is Ctrl + C + Shift.


#8

I’ve tried that but it still gives te same error


#9

As @Szaal says, we need to see the format of your code to troubleshoot it. Repost it here properly formatted?

I’m guessing the issue has something to do with the exterior “if”–the one with *selectable_if (cPush = true) #Push the Centre–rather than the if/elseif/elseifs posted above.