[Resource] ReturnHighestGlobal()

Post » Thu Apr 24, 2014 11:54 am

Hey guys I needed a function to run through a bunch of global variables and return the one that had the highest value. See below, tested and works :smile:


Calling it example:
GlobalVariable kMyGlobal = ReturnHighestGlobal(kArray)

The function:
GlobalVariable Function ReturnHighestGlobal(GlobalVariable[] akGlobalArray)	Int iElement = akGlobalArray.Length	Int HighestValue = http://forums.bethsoft.com/topic/1499497-resource-returnhighestglobal/0	GlobalVariable HighestGlobal	While iElement		iElement -= 1		Int iGlobalValue = (akGlobalArray[iElement]).GetValue() as Int			if iGlobalValue> HighestValue				HighestValue = http://forums.bethsoft.com/topic/1499497-resource-returnhighestglobal/iGlobalValue				HighestGlobal = akGlobalArray[iElement]			endif	EndWhile	if HighestValue == 0		Return none	endif	if HighestGlobal == none		Return none	endif	Return HighestGlobalEndFunction
User avatar
Lawrence Armijo
 
Posts: 3446
Joined: Thu Sep 27, 2007 7:12 pm

Return to V - Skyrim