I'm quite confused with what the difference between base object and inventory object?
I understand that inventory object is kinda base object and it's not a reference, but it also includes some additional info, for example it current enchantment charge and maybe inventory slot number (I assume if you have multiple objects with different enchantment charges, so they are not displayed as a stack - then providing RemoveItem with inventory reference of that object - will only remove that object, but I might be wrong)
So can someone please explain?
And to be specific I'm trying to edit enchantment charge of the item in the inventory, I can do that by setting charge to specific value on temporal reference and then inserting it back into container, but I want to decrement value so I need to have access to specific inventory item and not just base full enchantment, or at least a way to get a hold of that current enchantment value of the specific item and not just it's base, which will always return max enchantment.
What i'm currently doing:
begin OnEquip set item to GetBaseObject ... let AAEHquest.activeFistWeapon := item ; this is used as "item" in a function below ... end
;===Edit weapon charge through temporal reference=== Print "Attempting to edit temp ref charge" containerRef.RemoveItem item 1 Print "Getting temp ref" let itemRef := CreateTempRef item Print "Editing charge of " + $itemRef.GetName let enchantment := GetEnchantment item let chargeCost := GetEnchantmentCost enchantment let currentCharge := itemRef.GetCurrentCharge if currentCharge >= chargeCost let chargeCost := chargeCost * -1 itemRef.ModCurrentCharge chargeCost Print "Subtracted " + $chargeCost + " from " + $currentCharge else Print "Not enough charge!" Message "Not enough charge!" endif Print "Putting edited weapon into " + $containerRef + " container" itemRef.CopyIR containerRef let itemRef := 0 Print "Done editing temp ref" ;==========================================
As a result I get an item with a charge decremented from it's max and not it's current since ModCurrentCharge, as i assume was run on a temporal reference created from the base and not from my specific item... which makes sense since item is from GetBaseObject from onEquip, but I haven't found any way to get more of a proper inventory item reference and not just base object, so, what do?
Update:
I've used this now to get proper inventory reference now:
let inventoryRefs := containerRef.GetInvRefsForItem item Print "Array " + $inventoryRefs + " " + $ar_Size inventoryRefs ForEach ir <- inventoryRefs Print $itemRef let itemRef := ir["value"] Loop
but itemRef.GetCurrentCharge still returns max charge and not current
Thank you in advance!
Update 2: Ok i poked around and i think i solved it in some strange quirky way by using RemoveMeIR with a destination being player inventory which somehow actually properly replaces reference of the item in inventory with this temporary in a way that even the initial itemRef gets updated!
I'll post my code changes tomorrow, too tired rn, have a good night/day everyone!
Edited by SinnerSmile, 19 May 2021 - 09:08 PM.