Bagnon

Bagnon

124M Downloads

API to get the ItemSlot from bag id and slot id

Pierre-Sassoulas opened this issue ยท 3 comments

commented

Hi, this is more of a question than a feature request.

I'm trying to make an item glow inside Bagnon from my own addon, given that I have its bag id and slot id. I saw the issue #117 that seem somewhat related but did not find an answer here. So I was wondering the proper way to recover an ItemSlot from bag id and slot id? I read some bagnon's code (very clean by the way, good job) and making the ItemSlot glow seem possible once I have the ItemSlot object, but I don't know how I could recover it.

Would Lib:GetItemInfo(owner, bag, slot) using my player name without the server for "owner" work ? I did not manage to import and use this function in my own code, do you know how I could do that ? Maybe it's accessible from _G[..] ?

Thank you in advance for any help you could give.

commented

I'm answering under the assumption that by itemSlot you mean the physical button frame: look at Bagnon_Scrap code. It does something very similar to that. In essence, you monitor the Item:UpdateBorder function and, when its called, you check whether the instance's bagID and slotID matches the one you are looking for.

Alternatively, you could look at itemFrame.lua. It is responsible for managing the buttons, and, if I remember correctly, might be aware of which they are. But no guarantees.

commented

Yes I was talking about the physical button frame. Thank you for your answer, it permitted to do something reasonably understandable to integrate inside Bagnon very fast. Should I create a new addon called Bagnon_GreyHandling ?

Though to be fair, I think the code I have is very inneficient because we're using a different paradigm here, I would want to apply a slow one-time calculation that results in the "bag" and "slot" of an item when the player launch the addon, The way Bagnon work is by doing a fast calculation for each button frame very often so working properly with Bagnon's way would mean a total shift of paradigm in the way my addon work. Maybe it's better to do it like Bagnon does, it certainely open some possibilities, but it also closes others.

For example for other addons I make an item glow temporarily until the player hover it with:

self.NewItemTexture:SetAtlas("bags-glow-orange")
self.NewItemTexture:Show()
self.flashAnim:Play()
self.newitemglowAnim:Play()

And with Bagnon the glow would be permanent (because each time we use updateBorder() we reapply the glow).

Would an API to get the button frame from bag and slot would be feasible ?

commented

I'm clearly not used to event-based programming, I'll have to refactor a bit to make it efficient and I think I could make it work using hooksecure. Closing the ticket.