dylbill Posted October 15, 2020 Share Posted October 15, 2020 Hey, actually I did some testing, and I forgot you have to use floats when working with decimal places. Here's the revised code: Scriptname MiscStorageItemScript extends ObjectReference ;Attach this script to a MiscObject Int[] Property IntArray Auto Scriptname StorageQuestScript extends Quest MiscStorageItemScript[] Property StorageScripts auto ObjectReference Property StorageObjectRef Auto ;this is the object reference in the empty cell MiscObject Property StorageMiscItem Auto ;The misc item with the MiscStorageItemScript script attached Event OnInit() StorageScripts = New MiscStorageItemScript[128] ;must initialize the array first EndEvent Event SomeEvent() SetUpMultiArray(StorageScripts, 5000) ;Set up the multi array with a minimum 5000 entries SaveToMultiArray(StorageScripts, 1222, 777) ;save the value 777 to entry 1222 in the multi array. Int X = GetValueFromMultiArray(StorageScripts, 1222) ;Gets value from entry 1222 in multi array. Will return 777 EndEvent Function SetUpMultiArray(MiscStorageItemScript[] MultiArray, float NumbOfEntries) Float A = NumbOfEntries / 128 Int NumOfScripts = Math.Floor(A) Int I = -1 While I < NumOfScripts I += 1 If MultiArray[I] == None MultiArray[I] = StorageObjectRef.PlaceAtMe(StorageMiscItem, 1, 1, 0) as MiscStorageItemScript MultiArray[I].IntArray = New Int[128] Endif EndWhile Debug.MessageBox(MultiArray[NumOfScripts].IntArray.Length) Utility.Wait(1) EndFunction Function SaveToMultiArray(MiscStorageItemScript[] MultiArray, float akEntry, Int akValue) Float A = akEntry / 128 float ScriptIndex = Math.Floor(A) Float ArrayIndex = (A - ScriptIndex) * 128 MultiArray[ScriptIndex as int].IntArray[ArrayIndex as int] = akValue EndFunction Int Function GetValueFromMultiArray(MiscStorageItemScript[] MultiArray, Float akEntry) Float A = akEntry / 128 Float ScriptIndex = Math.Floor(A) Float ArrayIndex = (A - ScriptIndex) * 128 Return MultiArray[ScriptIndex as int].IntArray[ArrayIndex as int] EndFunction Function FullTest() ;save a print 16384 entries, the max amount for the multi array. SetUpMultiArray(StorageScripts, 16383) Utility.Wait(1) Float I = -1 While I < 16383 I += 1 SaveToMultiArray(StorageScripts, I, I as int) EndWhile Debug.MessageBox("Done Saving") Utility.Wait(1) Debug.Notification("Start Printing") Debug.OpenUserLog("Full_MultArray_Test") Float IA = -1 While IA < 16383 IA += 1 Int Value = GetValueFromMultiArray(StorageScripts, IA) Debug.TraceUser("Full_MultArray_Test", Value) EndWhile Debug.MessageBox("Done Printing") Debug.CloseUserLog("Full_MultArray_Test") EndFunctionI did the test function which saved 16384 ints, the max entries the multi array can have, and then printed them all to a user log. It actually happened pretty fast, faster than I expeted. About 1 second for saving and printing. Link to comment Share on other sites More sharing options...
Recommended Posts