I'm trying to make a script that replaces an armor when another one is equipped. When the player equips an armor, the script checks if the armor is in a form list, and if yes, replaces it for another armor in another formlist which is at the same position inside the formlist.
Here comes the trouble. I can easily detect if the armor is in the formlist, but I can't manage to retrieve it's position inside the formlist (didn't find a command for this...). So I made a while loop that searches for the index, as I can then use that index with the GetAt command to retrieve the new armor from the other formlist.
Now, my while loop is giving me the following error on compilation: (19,17): cannot compare a objectreference to a armor (cast missing or types unrelated)
This is in this line: If Reference == Cuirass
I think I understand why the error comes, I'm trying to compare an armor to an object reference? Anyway, how can I solve this? By the way, it's using some SKSE functions...
Scriptname ArmorReplace extends ReferenceAliasInt iIndexObjectReference ReferenceFormList property ArmorsVanilla AutoFormList property ArmorsModified AutoEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)if akBaseObject as Armor Debug.Trace("I just equipped an armor!") Armor Cuirass = Game.GetPlayer().GetWornForm(0x00000004) as Armor if (ArmorsVanilla.HasForm(Cuirass)) Game.GetPlayer().RemoveItem(akBaseObject, 1, True) iIndex = ArmorsVanilla.GetSize() While(iIndex > 0) iIndex -= 1 Reference = ArmorsVanilla.GetAt(iIndex) as ObjectReference If Reference == Cuirass Game.GetPlayer().AddItem(ArmorsModified.GetAt(iIndex), 1, true) EndIf EndWhile EndIfendifendEvent
Thanks in advance for any help!