paladicprince Posted October 15, 2009 Share Posted October 15, 2009 Does anyone know if a user defined function can return an array to an array? Like inside the function it creates an array, I can get that to work perfectly, but is there some way to copy that array from the function to a quest script? Link to comment Share on other sites More sharing options...
paladicprince Posted October 15, 2009 Author Share Posted October 15, 2009 This posts information was irrelevent. Thus deleted. Link to comment Share on other sites More sharing options...
paladicprince Posted October 15, 2009 Author Share Posted October 15, 2009 And Nevermind, I got it worked out. But if anyone has suggestions about the script let me know. Link to comment Share on other sites More sharing options...
QQuix Posted October 15, 2009 Share Posted October 15, 2009 What does PPEnemyScan do? Why not placing the GetFirst/nextREf loop in a function?I don't see where you reset 'Position' to 0. Link to comment Share on other sites More sharing options...
paladicprince Posted October 15, 2009 Author Share Posted October 15, 2009 Hmm. It looks like there was a bit of code left in there. I actually am calling to a User-Defined function now which is labelled PPEnemyScan. Here's the code copy-pasted from CS (instead of semi-editted like the above was):(Also note the runbatchscript defines the *Key variables) scn PPTargettingScript Float fQuestDelayTime Array_Var EnemyTargets Short ClearKey Short NextEnemyKey Short PrevEnemyKey Short CurrentEnemy Short Position Ref PlayerCell Ref Target Ref Temp Begin GameMode If (fQuestdelayTime != .01) Let fQuestDelayTime := .01 EndIf If (GetGameLoaded) RunBatchScript "Data\PPTargetting.ini" Let EnemyTargets := Ar_Construct Array Let EnemyTargets := Call PPEnemyScan Let PlayerCell := Player.GetParentCell EndIf If (Player.GetParentCell != PlayerCell) Let EnemyTargets := Call PPEnemyScan Let PlayerCell := Player.GetParentCell EndIf If (OnKeyDown ClearKey) Print "ClearKey Pressed" Print $ CurrentEnemy Ar_Dump EnemyTargets Let PlayerCell := 0 Let Target := 0 ElseIf (OnKeyDown NextEnemyKey) Print "NextEnemyKey Pressed" Let CurrentEnemy := (Ar_Next EnemyTargets CurrentEnemy) If (CurrentEnemy == -99999) Let CurrentEnemy := (Ar_First EnemyTargets) EndIf Print $ CurrentEnemy Let Target := EnemyTargets[CurrentEnemy] Print $ Target ElseIf (OnKeyDown PrevEnemyKey) Print "PrevEnemyKey Pressed" If TestExpr (Ar_Prev EnemyTargets CurrentEnemy) Let CurrentEnemy := (Ar_Prev EnemyTargets CurrentEnemy) If (CurrentEnemy == -99999) Let CurrentEnemy := (Ar_Last EnemyTargets) EndIf Print $ CurrentEnemy Let Target := EnemyTargets[CurrentEnemy] Print $ Target EndIf EndIf End And here's the User-defined function: scn PPEnemyScan Array_Var EnemyTargets Short Position Ref Temp Begin Function {} Let EnemyTargets := Ar_Construct Array Let Temp := GetFirstRef 69 1 While (Temp) If (Temp.GetDead == 0) Let EnemyTargets[Position] := Temp Let Position += 1 EndIf Let Temp := GetNextRef Loop SetFunctionValue EnemyTargets End And since it's a function the Position is stored localy and deleted once the function is done running. Thus it self resets. Good input thanks. Link to comment Share on other sites More sharing options...
QQuix Posted October 16, 2009 Share Posted October 16, 2009 Looks good to me.Have fun. . . Link to comment Share on other sites More sharing options...
Recommended Posts