Jump to content

Recommended Posts

Stupid past me moved the function call but didn't change the variable names in that call.

 

I've been getting an inexplicable runtime error on this function:

scn aaZefirosReorderEffects

;Main script
;-----------------------------------------------------------------------------
;aaZefirosManager
;-----------------------------------------------------------------------------

;Used scripts
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------

;Related scripts
;-----------------------------------------------------------------------------
;aaZefirosSetMergeEnch
;-----------------------------------------------------------------------------

;Used globals
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------

;Related globals
;-----------------------------------------------------------------------------
;-----------------------------------------------------------------------------

;Description
;-----------------------------------------------------------------------------
;Given a table containing MagicEffect and ActorValue codes and an array of
;enchantments, moves all listed effect items to the back of each enchantment
;by deleting and undeleting them.
;
;Effects:
;[0]EffectCode
;[1]ActorValueCode
;-----------------------------------------------------------------------------

;Parameters
;-----------------------------------------------------------------------------
array_var Effects
array_var Enchs

short Size
short Count
short i
short j

long EffC
long Magn
long Area
long Dura
short Rang
short AuxC

ref Spl

array_var Ench
array_var Data
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
begin Function { Effects, Enchs }
;-----------------------------------------------------------------------------
	
	Let Size := ar_Size Enchs
	DebugPrint "Reorganizing effects on %.0f enchantment(s)..." Size
	

	Let Data := ar_Construct Array

	Let Size := ar_Size Effects
	ForEach Ench <- Enchs

		Let Spl := *Ench
		

		;-----------------------------------------------------------------------------
		;Find and remove each effect
		;-----------------------------------------------------------------------------
		Let Count := GetMagicItemEffectCount Spl
		Let i := Count
		while ( i > 0 )
			Let i -= 1

			;Check if this effect is on the list
			Let j := 0
			while ( j < Size )

				;If it is...
				if eval( Effects[j][0] == GetNthEffectItemCode Spl i && Effects[j][1] == GetNthEffectItemActorValue Spl i )

					;Remove effect and store its values
					ar_Append Data GetNthEffectItem Spl i
					RemoveNthEffectItem Spl i

				endif

				Let j += 1
			loop

		loop


		;-----------------------------------------------------------------------------
		;Add each removed effect back
		;-----------------------------------------------------------------------------
		Let Count := ar_Size Data
		Let j := 0
		while ( j < Count )

			Let EffC := Data[j]["effectCode"]
			Let Magn := Data[j]["magnitude"]
			Let Area := Data[j]["area"]
			Let Dura := Data[j]["duration"]
			Let Rang := Data[j]["range"]

			Let i := AddFullEffectItemC EffC Magn Area Dura Rang Spl

			if eval( ar_HasKey Data[j] "actorValue" )

				Let AuxC := Data[j]["actorValue"]
				SetNthEffectItemActorValueC AuxC Spl i

			endif

			Let j += 1
		loop

		;Reset Data for next loop
		ar_Erase Data
	
	loop


	DebugPrint "Reorganized effects."
	Return
;-----------------------------------------------------------------------------
end ;Function { Effects, Enchs }
;-----------------------------------------------------------------------------

The line throwing the runtime error is:

Let Spl := *Ench

However, there is no actual error. Effects are properly re-ordered, everything behaves as desired. Yet this line keeps throwing the "Expression failed to evaluate" error.

I've tried

Let Spl := Ench["value"]

Same error.

 

I've also

ar_Dump Ench

and it looks right,

["key"] = 0.0000000
["value"] = Ench2

I have no idea what's causing this error to be thrown here.

Edited by VencGanence
Link to comment
Share on other sites

  • Recently Browsing   0 members

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