Can you compare two arrays?
Get a "GetEquippedItems" array and store it, and then run a comparison every five seconds with the current array result. If the array is different, you count the number of items (lower indicates the player unequipped something rather than equipped it) and act according to that result.
Get a "GetEquippedItems" array and store it, and then run a comparison every five seconds with the current array result. If the array is different, you count the number of items (lower indicates the player unequipped something rather than equipped it) and act according to that result.
I want to compare two arrays I get from player.GetEquippedItems (one current frame and one from the previous frame), but I can't get it to work. At the moment my script looks like this :
Spoiler
ScriptName NyczModPlayerEquipWeightScriptfloat fQuestDelayTimeshort doOncearray_var oldItemsbegin GameMode if doOnce != 1 set fQuestDelayTime to 2 let oldItems := ar_Sort player.GetEquippedItems set doOnce to 1 endif ; Are they the same size? ; Sort both ; Compare them ; Changed? short isChanged short oldLength short curLength let oldLength := ar_Size oldItems let curLength := ar_Size player.GetEquippedItems PrintC "Old length: %g, Current length: %g" oldLength curLength if oldLength == curLength array_var curItems let curItems := ar_Sort player.GetEquippedItems short i ref itm ref itm2 while i < curLength let itm := curItems[i] let itm2 := oldItems[i] if eval (!(itm.GetIsReference itm2)) set isChanged to 1 break endif let i += 1 loop endif if isChanged PrintC "Changed!" else PrintC "Unchanged!" endif ; Last stuff to do: let oldItems := ar_Sort player.GetEquippedItemsend
I'm not sure if my problem is in the comparison of the arrays or the creation or something else. And I can't find much about this in either the wiki or OBSE docs.