cooking script Scripting help

Post » Wed Jun 30, 2010 12:47 pm

Hi I have been trying to script a simple grill.You click on it and a message box comes up.You pick an option and it enables a raw version of the meat on the grill.A short time later the raw one disables and a cooked one enables.You can then click the grill again and it gives you a cooked meat food item and disables the cooked meat on the grill.
However I am not very good at scripting and all my attempts so far have failed.This is the script I have been working on.It does not work and gives the error of to many nested if statements.I don't know how to fix it.I get the feeling there should be a better way to do this but I just can't seem to figure it out.
Thanks for any help.

scn rvggrilledmeatshort getit;get cooked meatshort cooking;is it cooking?short meattype;what kind of meatshort check;is player?short button;button numbershort isdone;is it cooked?short altmessage;the rest of the menufloat timer;the time it takes to cookBegin onactivateif ( isActionRef Player )		set check to 1if isdone <= 1	  showmessage rvggrillcookmenu	  set timer to 0elseif isdone == 2	showmessage rvggrilldoneset getit to 1endifendifendbegin gamemodeif (check)set button to GetButtonPressedif isdone <= 1if cooking == 0if Button == -1; No button has been pressed yet		Return	if altmessage == 0; rvggrillcookmenu		if Button == 0; cookbeef			if player getitemcount >= 1 BrahminSteak			Player.RemoveItem BrahminSteak 1			 rvgrawbeefref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 1			set cooking to 1		endif		if Button == 1; cookAntMeat			if player getitemcount >= 1 AntMeat			Player.RemoveItem AntMeat materialcount 1			 rvgrawAntMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 2			set cooking to 1		endif		if Button == 2;cookBloatflyMeat			 if player getitemcount >= 1 BloatflyMeat			Player.RemoveItem BloatflyMeat materialcount 1			 rvgrawBloatflyMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 3			set cooking to 1		endif		if Button == 3; cookDogMeat			if player getitemcount >= 1 DogMeat			Player.RemoveItem DogMeat materialcount 1			 rvgrawDogMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 4			set cooking to 1		endif		if Button == 4; cookHumanFlesh			if player getitemcount >= 1 HumanFlesh			Player.RemoveItem HumanFlesh materialcount 1			 rvgrawHumanFleshref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 5			set cooking to 1		endif		if Button == 5; cookMirelurkMeat			if player getitemcount >= 1 MirelurkMeat			Player.RemoveItem MirelurkMeat materialcount 1			 rvgrawMirelurkMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 6			set cooking to 1		endif		if Button == 6; cookMirelurkMeatHatchling			if player getitemcount >= 1 MirelurkMeatHatchling			Player.RemoveItem MirelurkMeatHatchling materialcount 1			 rvgrawMirelurkMeatHatchlingref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 7			set cooking to 1		endif		if Button == 7; cookMirelurkMeatSoftshell			if player getitemcount >= 1 MirelurkMeatSoftshell			Player.RemoveItem MirelurkMeatSoftshell materialcount 1			 rvgrawMirelurkMeatSoftshellref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 8			set cooking to 1		endif		if Button == 8; cookMoleRatMeat			 if player getitemcount >= 1 MoleRatMeat			Player.RemoveItem MoleRatMeat materialcount 1			 rvgrawMoleRatMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 9			set cooking to 1		endif		if Button == 9; More			ShowMessage rvggrillcook2menu			set altmessage to 1			Return		endifendifendifendifendifendifif (check)set button to GetButtonPressedif isdone <= 1if cooking == 0if Button == -1; No button has been pressed yet		Returnif altmessage == 1; rvggrillcook2menu		if Button == 0; cookMS05NukalurkMeat			if player getitemcount >= 1 MS05NukalurkMeat			Player.RemoveItem MS05NukalurkMeat materialcount 1			 rvgrawMS05NukalurkMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 10			set cooking to 1		endif		if Button == 1; cookRadroachMeat			if player getitemcount >= 1 RadroachMeat			Player.RemoveItem RadroachMeat materialcount 1			 rvgrawRadroachMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 11			set cooking to 1		endif		if Button == 2; cookYaoGuaiMeat			if player getitemcount >= 1 YaoGuaiMeat			Player.RemoveItem YaoGuaiMeat materialcount 1			 rvgrawYaoGuaiMeatref.enable			rvgfireref.enable			set timer to timer + GetSecondsPassed			set meattype to 12			set cooking to 1		endif		if Button == 3; exit			return;unEquip player				endif		if Button == 4; back			ShowMessage rvggrillcookmenu			set altmessage to 0			Returnendif	endifendifendifendifendifif isdone <= 1if cooking == 1if timer >= 30	if meattype == 1		rvgrawbeefref.disable		rvgcookedbeefref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 2		rvgrawAntMeatref.disable		rvgcookedAntMeatref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 3		rvgrawBloatflyMeatref.disable		rvgcookedBloatflyMeatref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 4		rvgrawDogMeatref.disable		rvgcookedDogMeatref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 5		rvgrawHumanFleshref.disable		rvgcookedHumanFleshref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 6		rvgrawMirelurkMeatref.disable		rvgcookedMirelurkMeatref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 7		rvgrawMirelurkMeatHatchlingref.disable		rvgcookedMirelurkMeatHatchlingref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 8		rvgrawMirelurkMeatSoftshellref.disable		rvgcookedMirelurkMeatSoftshellref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 9		rvgrawMoleRatMeatref.disable		rvgcookedMoleRatMeatref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 10		rvgrawMS05NukalurkMeatref.disable		rvgcookedMS05NukalurkMeatref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 11		rvgrawRadroachMeatref.disable		rvgcookedRadroachMeatref.enable		set isdone to 2			SET cooking to 0	endif	if meattype == 12		 rvgrawYaoGuaiMeatref.disable		rvgcookedYaoGuaiMeatref.enable		set isdone to 2			SET cooking to 0	endifendifendifendifendifif isdone == 2if getit == 1	if meattype == 1		player.additem rvgcookedbeef 1		rvgcookedbeefref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 2		player.additem rvgcookedAntMeat 1		rvgcookedAntMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 3		player.additem rvgcookedBloatflyMeat 1		rvgcookedBloatflyMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 4		player.additem rvgcookedDogMeat 1		rvgcookedDogMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 5		player.additem rvgcookedHumanFlesh 1		rvgcookedHumanFleshref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 6		player.additem rvgcookedMirelurkMeat 1		rvgcookedMirelurkMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 7		player.additem rvgcookedMirelurkMeatHatchling 1		rvgcookedMirelurkMeatHatchlingref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 8		player.additem rvgcookedMirelurkMeatSoftshell 1		rvgcookedMirelurkMeatSoftshellref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 9		player.additem rvgcookedMoleRatMeat 1		rvgcookedMoleRatMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 10		player.additem rvgcookedMS05NukalurkMeat 1		rvgcookedMS05NukalurkMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 11		player.additem rvgcookedRadroachMeat 1		rvgcookedRadroachMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	if meattype == 12		player.additem rvgcookedYaoGuaiMeat 1		rvgcookedYaoGuaiMeatref.disable		rvgfireref.disable		set isdone to 0		set getit to 0	endif	endifendifendifend

User avatar
Adrian Powers
 
Posts: 3368
Joined: Fri Oct 26, 2007 4:44 pm

Post » Wed Jun 30, 2010 8:36 am

Two suggestions:

1) run it through Cipscis' http://www.cipscis.com/fallout/utilities/validator.aspx
2) Instead of all of those

If
Endif
If
EndIf

Try

If
ElseIf
ElseIf
ElseIf
Endif
User avatar
HARDHEAD
 
Posts: 3499
Joined: Sun Aug 19, 2007 5:49 am


Return to Fallout 3