Jump to content

MIsmatched Begin/end blocks


Recommended Posts

Greets! So far, this is my first post, but that's not the thing. I am a newbie on scripting, and, I get an error: 'Script AltarofSUmmoningScript', line 18 Mismatched begin/end blocks starting on line 18.' Here is the script:

scn AltarofSummoningScript

 

short button

short summoned

 

begin OnActivate

 

if ( IsActionRef Player == 1 )

if ( Summoned < 1 )

Messagebox "What kind of creature do you wish to summon?","Xivilai","Clannfear","Spider Daedra","Done"

else

Message "You may only have one Familiar at a time."

endif

endif

 

end

 

begin gamemode

 

set button to getbuttonpressed

if button > -1

if button == 0

if ( Player.GetItemCount DaedraHeart >= 1 )

Playsound SPLPoisonCast

XivilaiSummon.Placeatme SUmmonXivilai

Player.RemoveItem DaedraHeart 1

set Summoned to 1

else

Message "This requires 1 Daedra Heart."

endif

elseif button == 1

if ( Player.GetItemCount ClannfearClaws >= 2 )

Playsound SPLPoisonCast

ClannfearSummon.Placeatme ClannfearSummon

Player.RemoveItem ClannfearClaws 2

set Summoned to 1

else

Message "This requires 2 Clannfear Claws."

endif

elseif button == 2

if ( Player.GetItemCount DaedraSilk >= 3 )

Playsound SPLPoisonCast

SpiderDaedraSummon.Placeatme SummonSpiderDaedra

Player.RemoveItem DaedraSilk 3

set Summoned to 1

else

Message "This requires 3 Daedra Silk."

endif

elseif button == 3

endif

endif

endif

 

I know, I copied it off the Frostcrag script, but whatever. Help, please?

Link to comment
Share on other sites

Whoop. The forums made it in one line. Yes, I did have spaces everywhere.

scn AltarofSummoningScript

 

short button

short summoned

 

begin OnActivate

 

if ( IsActionRef Player == 1 )

if ( Summoned < 1 )

Messagebox "What kind of creature do you wish to summon?","Xivilai","Clannfear","Spider Daedra","Done"

else

Message "You may only have one Familiar at a time."

endif

endif

 

end

 

begin gamemode

 

set button to getbuttonpressed

if button > -1

if button == 0

if ( Player.GetItemCount DaedraHeart >= 1 )

Playsound SPLPoisonCast

XivilaiSummon.Placeatme SUmmonXivilai

Player.RemoveItem DaedraHeart 1

set Summoned to 1

else

Message "This requires 1 Daedra Heart."

endif

elseif button == 1

if ( Player.GetItemCount ClannfearClaws >= 2 )

Playsound SPLPoisonCast

ClannfearSummon.Placeatme ClannfearSummon

Player.RemoveItem ClannfearClaws 2

set Summoned to 1

else

Message "This requires 2 Clannfear Claws."

endif

elseif button == 2

if ( Player.GetItemCount DaedraSilk >= 3 )

Playsound SPLPoisonCast

SpiderDaedraSummon.Placeatme SummonSpiderDaedra

Player.RemoveItem DaedraSilk 3

set Summoned to 1

else

Message "This requires 3 Daedra Silk."

endif

elseif button == 3

endif

endif

endif

Link to comment
Share on other sites

Don't write your scripts in block format. This makes it so it is hard for you to visually find your mismatched begin/end blocks. You should indent in the fashion that Bethesda used.

 

BAD:

begin OnActivate

if ( IsActionRef Player == 1 )
if ( Summoned < 1 )
Messagebox "What kind of creature do you wish to summon?","Xivilai","Clannfear","Spider Daedra","Done"
else
Message "You may only have one Familiar at a time."
endif
endif

end

 

GOOD:

begin OnActivate

    if ( IsActionRef Player == 1 )
         if ( Summoned < 1 )
              Messagebox "What kind of creature do you wish to summon?","Xivilai","Clannfear","Spider Daedra","Done"
         else
              Message "You may only have one Familiar at a time."
         endif
    endif

end

 

Line 18 in your script is probably:

begin OnActivate

 

You do not have this at the end of your script:

End

 

You need to use one "End" at the end of each block of scripting that uses "Begin *****"

Link to comment
Share on other sites

The forum software always strips away the leading blanks unless it's inside a "code" tag.

 

The last "endif" in this script needs to be replaced by an "end", as it's now 1 "endif" too much and an "end" missing.

 

With a later version of OBSE the syntax checking got improved, so while previously the editor let those broken scripts pass compilation (perhaps was more forgiving, ignored the bogus "endif" and added the missing "end" itself), now it won't anymore. That's why the original script is indeed broken in syntax but works. You just can't compile it anymore unless you fixed it now.

Link to comment
Share on other sites

Also, if you are, don't use the CS's script editor for writing up scripts. It's just terrible.

 

Notepad++ features full syntax highlighting for most scripting languages: including Oblivion with the appropriate script definitions. It also marks indents, so you have a visual marker indicating how far down each IF case goes so you can make sure you get them all capped.

 

An example snippet from one of my old scripts:

http://i1192.photobucket.com/albums/aa336/septfox/screxample.png

Link to comment
Share on other sites

Actually, he was right; that last endif should be an end. You can see it if you indent the script properly.

 

Changing that and the placeatme functions to reference the player, the script compiles without any complaints for me.

 

scn AltarofSummoningScript

short button
short summoned

begin OnActivate

if ( IsActionRef Player == 1 )
if ( Summoned < 1 )
	Messagebox "What kind of creature do you wish to summon?","Xivilai","Clannfear","Spider Daedra","Done"
else
	Message "You may only have one Familiar at a time."
endif
endif

end

begin gamemode

set button to getbuttonpressed
if button > -1
	if button == 0
		if ( Player.GetItemCount DaedraHeart >= 1 )
			Playsound SPLPoisonCast
			player.Placeatme SUmmonXivilai
			Player.RemoveItem DaedraHeart 1
			set Summoned to 1
		else
			Message "This requires 1 Daedra Heart."
		endif
	elseif button == 1
		if ( Player.GetItemCount ClannfearClaws >= 2 )
			Playsound SPLPoisonCast
			player.Placeatme ClannfearSummon
			Player.RemoveItem ClannfearClaws 2
			set Summoned to 1
		else
			Message "This requires 2 Clannfear Claws."
		endif
	elseif button == 2
		if ( Player.GetItemCount DaedraSilk >= 3 )
			Playsound SPLPoisonCast
			player.Placeatme SummonSpiderDaedra
			Player.RemoveItem DaedraSilk 3
			set Summoned to 1
		else
			Message "This requires 3 Daedra Silk."
		endif
	elseif button == 3
	endif
endif

end

Link to comment
Share on other sites

Actually, he was right; that last endif should be an end. You can see it if you indent the script properly.

 

Changing that and the placeatme functions to reference the player, the script compiles without any complaints for me.

 

scn AltarofSummoningScript

short button
short summoned

begin OnActivate

if ( IsActionRef Player == 1 )
if ( Summoned < 1 )
	Messagebox "What kind of creature do you wish to summon?","Xivilai","Clannfear","Spider Daedra","Done"
else
	Message "You may only have one Familiar at a time."
endif
endif

end

begin gamemode

set button to getbuttonpressed
if button > -1
	if button == 0
		if ( Player.GetItemCount DaedraHeart >= 1 )
			Playsound SPLPoisonCast
			player.Placeatme SUmmonXivilai
			Player.RemoveItem DaedraHeart 1
			set Summoned to 1
		else
			Message "This requires 1 Daedra Heart."
		endif
	elseif button == 1
		if ( Player.GetItemCount ClannfearClaws >= 2 )
			Playsound SPLPoisonCast
			player.Placeatme ClannfearSummon
			Player.RemoveItem ClannfearClaws 2
			set Summoned to 1
		else
			Message "This requires 2 Clannfear Claws."
		endif
	elseif button == 2
		if ( Player.GetItemCount DaedraSilk >= 3 )
			Playsound SPLPoisonCast
			player.Placeatme SummonSpiderDaedra
			Player.RemoveItem DaedraSilk 3
			set Summoned to 1
		else
			Message "This requires 3 Daedra Silk."
		endif
	elseif button == 3
	endif
endif

end

 

FInally. Thanks, thanks, thanks!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...