This matter has been solved
I scrapped the whole quest, script, and FormList. Created them entirely new with new EditorIDs. Now it reports the correct size.
Original post here:
So I have this script here:
Scriptname RaestlozArmorChangerPlayerScript extends ReferenceAlias{Script that runs on Player.Changes the instance of armor that player gets}FormList Property VanillaArmorList AutoFormList Property CustomArmorList AutoBool Property ArmorChangingEnabled AutoSpell Property switcherSpell Autoint TempIndex = 0Event OnInit() AddInventoryEventFilter(VanillaArmorList) if (Game.getPlayer().hasSpell(switcherSpell) == false) Game.getPlayer().addSpell(switcherSpell) endifendEventEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) if (Game.getPlayer().hasSpell(switcherSpell) == false) Game.getPlayer().addSpell(switcherSpell) end GetFormIndex(VanillaArmorList ,CustomArmorList ,akBaseItem,aiItemCount)endEventFunction GetFormIndex(FormList SourceList, FormList TargetList, Form Member, int iItemCount) global{Gets the index of Member in List. Returns -1 if not found} if (!SourceList.HasForm(Member)) Return endif debug.messagebox("item is present in formlist"); int Index = 0 int MaxIndex = SourceList.getSize() bool letGo = false While (letGo == false) if(SourceList.GetAt(Index) == Member) Game.GetPlayer().removeItem(Member, iItemCount,false) Game.getPlayer().addItem(TargetList.GetAt(Index),iItemCount,false) debug.messagebox("You got something"); letGo = true elseif (Index == MaxIndex) letGo = true; trace("finally... it's over"); else debug.trace("test " + Index); Index +=1 endif endwhile Return IndexEndFunctionIn case your eyes are a bit sore at the moment, I'm trying to exchange an item that a player takes with something else when they take the item.The items are listed in a FormList, which literally consists of only 11 items.
You may have noticed that I've put a trace to see how many times the function counts (how many times that "Index" is increased)
The script log prints "test 0" and "test 1072" in the same file.
It defies logic, as counting 12 times is already an overkill. Not to mention if it goes beyond 12 it shouldn't even be able to stop at all. The item in question is at index 5 in 0-10 range. So the 6th count should have done the job.
What I need to know is goddang why? This is not even about my game being slow (it's not, the test environment has 60 fps at all times to make sure no lag hinders the script engine). iPresentInterval is also at value 1, in case it has any impact
The game managed to count well past the limit, ignoring the safe guard I put there in form of MaxIndex and managed to find something that is present at index 5 after counting 1073 times.
Don't tell me that FormList actually do not behave like Arrays and that an 11 item list has more than 11 indexes?
EDIT:
Okay, I traced the size of the FormList and HOLY MOTHER******* it has 1374 slots! To be sure, I created an entirely new FormList to test the size (now with only 9 items) and sure enough, there are 1374 slots there. This is extremely confusing.
On a side note, the script engine managed to count 6 times in one second. Very slow I think, but perhaps it's because there is that if check there?
