Originally Posted by thifi
I could either ignore the inventory refresh or simply throttle my refresh to be done only once in let's say 500 ms.
|
I asked because I was curious what was happening in your handler. I peeked into RB2 and have a few suggestions.
You're scanning the whole inventory (and bank, too?) on every slot update, right? I'd say don't, but from what I understood it'd be really hard. You gather some info about items in inventory, and to do a true single slot update, you'd need to remember what was where during the last scan, so that you can remove it from the appropriate tables when it disappears from the slot. Right?
How about building one more table in InventoryContainer:refresh() to remember what you saw, SeenLinks = {[slotIndex] = itemLink}
Then you could add a function InventoryContainer:refreshSlot(slotIndex), in which you'd first compare the new itemLink with oldLink = SeenLinks[slotIndex] -- if they're equal, you're good, return -- otherwise you can get oldKey = ItemLinks[oldLink] and delete oldLink from ResearchKeys[oldKey]. If I undestand it correctly, you can't remove ItemLinks[oldLink] until ResearchKeys[oldKey] is empty. Then add the new itemLink in the same manner it is done now. It will probably be more difficult to make this work than I'm picturing it, but I think it's not unreal.
By the way, inventory slots are indexed from 0 to bagSize-1, you're 1 off