RightEval Error

Post » Sun Sep 13, 2009 2:21 am

So I've been working on some of my scripts this evening, and it is getting rather late, so perhaps I'm missing something obvious. But I've been over this script twenty times now and I can't see what the problem is. At runtime, the script halts with a RightEval error and no other information =/

It compiles perfectly in the CS, and in MWEdit with "strong" warning level nothing shows up. I have extremely similar scripts for the other books in my WIP mod, and have no issues with them. This one worked until just now, too, and I can't even work out what caused it to malfunction.

If anyone with a keen eye wants to tell me what I've broken, I will certainly appreciate it. ^_^

In the meantime, I shall continue the hunt...

Spoiler
Begin NMZ_FireBook_Script; -- -- Fire Book Script Variablesshort state					; Controls adding/removing spell(s) from inventoryshort ingred1				; How many fire salts are in inventoryshort state2					; Triggers when cell changes to prevent Seal of the Inferno from being permanent upon teleportshort CastSucceed			; Controls whether or not a cast meets requirementsshort CastCache			; Store last looked NMZ_CastEarthshort CastDiff				; CastCache - NMZ_CastEarthshort CastIntervalshort CastLearn; -- -- Fire Book CastSucceed Blockif ( menumode == 0 )	;This block can be modified to allow other conditions (i.e. elemental mastery, no longer needing weather conditions, with additional elseifs)	;I'll figure out the rest later, but for now this wraps the weather condition to one place.	if ( GetCurrentWeather == 6 )		set CastSucceed to 1	elseif ( NMZ_Mastery == 1 )		set CastSucceed to 1	else		set CastSucceed to 0	endifendif; -- -- Fire Book Script -- Spell detection blockif ( menumode == 0 )	if ( Player -> GetSoundPlaying "Alteration Cast" )		if ( Player -> GetSpellEffects "NMZ_FireSpell1" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell1"			set ingred1 to ( Player -> GetItemCount "ingred_fire_salts_01" )			if ( ingred1 > 0 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				Player -> RemoveItem "ingred_fire_salts_01" 1				;MessageBox "Embers burn within your hands, and your fire salts vanish!"				ChangeWeather "Ascadian Isles Region" 6				ChangeWeather "Ashlands Region" 6				ChangeWeather "Azura's Coast Region" 6				ChangeWeather "Bitter Coast Region" 6				ChangeWeather "Brodir Grove Region" 6				ChangeWeather "Felsaad Coast Region" 6				ChangeWeather "Grazelands Region" 6				ChangeWeather "Hirstaang Forest Region" 6				ChangeWeather "Isinfier Plains Region" 6				ChangeWeather "Moesring Mountains Region" 6				ChangeWeather "Molag Mar Region" 6				ChangeWeather "Mournhold Region" 6				ChangeWeather "Red Mountain Region" 6				ChangeWeather "Sheogorad" 6				ChangeWeather "Thirsk Region" 6				ChangeWeather "West Gash Region" 6				Return			else				;MessageBox "Embers burn within your hands, seeking fire salts."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell2" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell2"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "Flames build within you, bursting into a four-point flare!"				Player -> PlaceAtMe "NMZ_FireCross" 1,1,0				Return			else				;MessageBox "Flames build within you, but die away."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell3" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell3"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "Fire erupts from the earth, creating a circle of fire!"				Player -> PlaceAtMe "NMZ_FireCircle" 1,1,0				Return			else				;MessageBox "Fire rises from the earth, but dissipates."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell4" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell4"			if ( CastSucceed == 1 )				if ( NMZ_Wildfire == 0 )					set NMZ_CastFire to ( NMZ_CastFire + 1 )					;MessageBox "Flames explode randomly into a wildfire!"					set NMZ_Wildfire to 40					set NMZ_WildfireX to ( Player->GetPos, X )					set NMZ_WildfireY to ( Player->GetPos, Y )					set NMZ_WildfireZ to ( Player->GetPos, Z )					Player -> PlaceAtMe "NMZ_FirePlume3" 1,128,0					Return				else					;MessageBox "Flames appear, but are too weak to explode."					Return				endif			else				;MessageBox "Flames appear, but are too weak to explode."				Return			endif		endif	endifendif; -- -- Fire Book Script -- Spell Detection Block 2if ( menumode == 0 )	if ( Player -> GetSoundPlaying "Alteration Cast" )		if ( Player -> GetSpellEffects "NMZ_FireSpell5" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell5"			if ( CastSucceed == 1 )				if ( NMZ_Trailblazer == 0 )					set NMZ_CastFire to ( NMZ_CastFire + 1 )					;MessageBox "Heat encapsulates your feet, and the earth beneath you burns!"					set NMZ_Trailblazer to 40					Player -> PlaceAtMe "NMZ_FirePlume4" 1,1,1					Return				else					;MessageBox "Heat encapsulates your feet, but floods back into the earth."					Return				endif			else				;MessageBox "Heat encapsulates your feet, but floods back into the earth."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell6" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell6"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "Flames gather in your palms, radiating outward into a fire nova!"				Player -> PlaceAtMe "NMZ_FireNova" 1,1,0				Return			else				;MessageBox "Flames gather in your palms, but fade away."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell7" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell7"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "Fire and rage are mirrored in your eyes, as meteors rain upon the ground!"				Player -> PlaceAtMe "NMZ_FireShower" 1,400,0				Return			else				;MessageBox "Fire and rage are mirrored in your eyes, but nothing happens."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell8" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell8"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "You gather heat, building up a cauterizing blast!"				Player -> PlaceAtMe "NMZ_FireCauterize" 1,20,0				Return			else				;MessageBox "You gather heat, but not enough to cauterize the area."				Return			endif		endif	endifendif; -- -- Fire Book Script -- Spell Detection Block 3if ( menumode == 0 )	if ( Player -> GetSoundPlaying "Alteration Cast" )		if ( Player -> GetSpellEffects "NMZ_FireSpell9" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell9"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "You condense energy about you, forming a flameshield!"				Player -> PlaceAtMe "NMZ_FireShield" 1,1,0				Player -> PlaceAtMe "NMZ_FireShield2" 1,1,0				Player -> PlaceAtMe "NMZ_FireShield3" 1,1,0				Player -> PlaceAtMe "NMZ_FireShield4" 1,1,0				Return			else				;MessageBox "You condense energy about you, but it sputters and fades away."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell10" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell10"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "Your eyes glint with fiery wrath as your hands unleash a scattershot!"				Player -> PlaceAtMe "NMZ_FireScatter2" 1,100,0				Return			else				;MessageBox "Your eyes glint with fiery wrath, but you lack the power to unleash it."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell11" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell11"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "You focus upon the heavens, and a curse escapes your hands!"				Player -> PlaceAtMe "NMZ_FireCurseArrow" 1,100,0				Return			else				;MessageBox "You focus upon the heavens, but your prayer is unanswered."				Return			endif		endif		if ( Player -> GetSpellEffects "NMZ_FireSpell12" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell12"			if ( CastSucceed == 1 )				if ( NMZ_FireSanctuary_Global == 0 )					set NMZ_CastFire to ( NMZ_CastFire + 1 )					;MessageBox "You focus upon the heavens, and are granted the Seal of the Inferno!"					set NMZ_FireSanctuary_Global to 1					Player -> PlaceAtMe "NMZ_FireInfernoSeal" 1,1,0					Return				else					MessageBox "You may only cast one Seal of the Inferno at a time."					Return				endif			else				;MessageBox "You focus upon the heavens, but your prayer is unanswered."				Return			endif		endif	endifendif; -- -- Fire Book Script -- Spell Detection Block 4if ( menumode == 0 )	if ( Player -> GetSoundPlaying "Alteration Cast" )		if ( Player -> GetSpellEffects "NMZ_FireSpell13" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell13"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;Flame Incarnate				set NMZ_TransformType to 2				set NMZ_TransformDuration to 30				Player -> PlaceAtMe "NMZ_TransformFire_Obj" 1,1,0				Return			else				;Flame Incarnate				Return			endif		endif	endifendif; -- -- Fire Book Script Learn Messageset CastInterval to 25set CastDiff to ( NMZ_CastFire - CastCache )if ( CastDiff >= CastInterval )	PlaySound "skillraise"	MessageBox "You have served Fire well, and are rewarded with a new spell."	set CastCache to NMZ_CastFire	set state to 0endif; -- -- Fire Book Script -- Spell list blockif ( state == 0 )	if ( Player -> GetItemCount "NMZ_FireBook" == 1 )		set state to 1	endif	returnelseif ( state == 1 )	set CastCache to NMZ_CastFire;Learn order:;-------------------;1. Fire Nova (0);2. Wildfire (25);3. Four Point Flare (50);4. Trailblazer (75);5. Cauterize (100);6. Scattershot (125);7. Seal of the Inferno (150);8. Circle of Fire (175);9.  Flameshield (200);10. Curse of the Inferno (225);11. Meteor Shower (250);12. Flame Incarnate (275);13. Embers Invocation (300)		set CastLearn to ( CastInterval * 12 )	if ( NMZ_CastFire >= CastLearn )		;Embers Invocation		Player->AddSpell "NMZ_FireSpell1"	endif	set CastLearn to ( CastInterval * 2 )	if ( NMZ_CastFire >= CastLearn )		;Four point flare		Player->AddSpell "NMZ_FireSpell2"	endif	set CastLearn to ( CastInterval * 7 )	if ( NMZ_CastFire >= CastLearn )		;Circle of Fire		Player->AddSpell "NMZ_FireSpell3"	endif	set CastLearn to ( CastInterval * 1 )	if ( NMZ_CastFire >= CastLearn )		;Wildfire		Player->AddSpell "NMZ_FireSpell4"	endif	set CastLearn to ( CastInterval * 3 )	if ( NMZ_CastFire >= CastLearn )		;Trailblazer		Player->AddSpell "NMZ_FireSpell5"	endif	set CastLearn to ( CastInterval * 0 )	if ( NMZ_CastFire >= CastLearn )		;Fire Nova		Player->AddSpell "NMZ_FireSpell6"	endif	set CastLearn to ( CastInterval * 10 )	if ( NMZ_CastFire >= CastLearn )		; Meteor Shower		Player->AddSpell "NMZ_FireSpell7"	endif	set CastLearn to ( CastInterval * 4 )	if ( NMZ_CastFire >= CastLearn )		;Cauterize		Player->AddSpell "NMZ_FireSpell8"	endif	set CastLearn to ( CastInterval * 8 )	if ( NMZ_CastFire >= CastLearn )		;Flameshield		Player->AddSpell "NMZ_FireSpell9"	endif	set CastLearn to ( CastInterval * 5 )	if ( NMZ_CastFire >= CastLearn )		;Scattershot		Player->AddSpell "NMZ_FireSpell10"	endif	set CastLearn to ( CastInterval * 9 )	if ( NMZ_CastFire >= CastLearn )		;Curse of the inferno		Player->AddSpell "NMZ_FireSpell11"	endif	set CastLearn to ( CastInterval * 6 )	if ( NMZ_CastFire >= CastLearn )		;Seal of the inferno		Player->AddSpell "NMZ_FireSpell12"	endif	set CastLearn to ( CastInterval * 11 )	if ( NMZ_CastFire >= CastLearn )		;Flame incarnate		Player->AddSpell "NMZ_FireSpell13"	endif	set state to 2	returnelseif ( state == 2 )	if ( ( Player->GetItemCount "NMZ_FireBook" ) == 0 )		set state to 3	endif	returnelseif ( state == 3 )	Player->RemoveSpell "NMZ_FireSpell1"	Player->RemoveSpell "NMZ_FireSpell2"	Player->RemoveSpell "NMZ_FireSpell3"	Player->RemoveSpell "NMZ_FireSpell4"	Player->RemoveSpell "NMZ_FireSpell5"	Player->RemoveSpell "NMZ_FireSpell6"	Player->RemoveSpell "NMZ_FireSpell7"	Player->RemoveSpell "NMZ_FireSpell8"	Player->RemoveSpell "NMZ_FireSpell9"	Player->RemoveSpell "NMZ_FireSpell10"	Player->RemoveSpell "NMZ_FireSpell11"	Player->RemoveSpell "NMZ_FireSpell12"	Player->RemoveSpell "NMZ_FireSpell13"	set state to 0	returnendifEnd


Edit: Well, I got it to stop giving the error by shifting some of the upper areas around. It was an old problem, that once I had too much inside one of the spell detection blocks the RightEval error would appear, and so I spaced a few of them out into a new block which seems to have worked for now. Crazy scripting limits :brokencomputer:
User avatar
K J S
 
Posts: 3326
Joined: Thu Apr 05, 2007 11:50 am

Post » Sat Sep 12, 2009 2:18 pm

You can probably simplify it by removing all of the if ( menumode == 0 ) and replacing them with this code block at the beginning:

if ( MenuMode == 1 )     returnendif


That way, none of the script will run if the player is in menu mode.
User avatar
N Only WhiTe girl
 
Posts: 3353
Joined: Mon Oct 30, 2006 2:30 pm

Post » Sat Sep 12, 2009 1:58 pm

You can probably simplify it by removing all of the if ( menumode == 0 ) and replacing them with this code block at the beginning:

if ( MenuMode == 1 )     returnendif


That way, none of the script will run if the player is in menu mode.



That's true, and is what I typically do, but previously I had separate blocks for some things that were menumode == 1 strewn about and so kept them separated like that... I should simplify them in that way, at least. Thanks =)
User avatar
Nicole M
 
Posts: 3501
Joined: Thu Jun 15, 2006 6:31 am

Post » Sat Sep 12, 2009 8:37 pm

Put any menu-mode independent parts above the return, any ones that require menumode in it, and any that shouldn't run after it.

Also, I see you have a lot of Gets inside of Ifs. Try to put them in variables first, that can be more stable.
User avatar
Rowena
 
Posts: 3471
Joined: Sun Nov 05, 2006 11:40 am

Post » Sat Sep 12, 2009 9:14 pm

More good calls. I will have to add those to the to-do list =).


Thanks all!
User avatar
DeeD
 
Posts: 3439
Joined: Sat Jul 14, 2007 6:50 pm

Post » Sun Sep 13, 2009 3:49 am

Unless you plan to eventually have those commented MessageBoxes back, it might be useful to remove unnecessary else-branches. Remember: in a script too long, an if-limit may hit you so that you won't notice it and will desperately try to understand why your script doesn't follow prescribed logic.
		if ( Player -> GetSpellEffects "NMZ_FireSpell2" == 1 )			Player -> RemoveSpellEffects "NMZ_FireSpell2"			if ( CastSucceed == 1 )				set NMZ_CastFire to ( NMZ_CastFire + 1 )				;MessageBox "Flames build within you, bursting into a four-point flare!"				Player -> PlaceAtMe "NMZ_FireCross" 1,1,0			endif			Return		endif

User avatar
Robyn Howlett
 
Posts: 3332
Joined: Wed Aug 23, 2006 9:01 pm


Return to III - Morrowind