Hey, I'm the author of the Reagent Restocker addon, and I'm trying to add guild bank support to my addon.
Currently, Reagent Restocker makes several calls to GetContainerItemLink and GetContainerItemInfo. However, all of that changes when I want it to access the guild bank.
When the guild bank is being accessed, it needs to use GetGuildBankItemLink and GetGuildBankItemInfo for items in the guild bank.
Problem is, I'm unsure of how to do this cleanly. I started putting in a lot of if...else..end statements, but it just makes the code a lot more complex and more difficult to work with, and has to be done pretty much anywhere where I need choose between a guild bank function and the regular function.
Is there a way to cleanly use these API calls without making my code a mess?
could always pass a flag to the function ( ie function arg indicating gbank ) & in the opening lines of the function define 2 generic locals that change depending on if it's local or gbank
function scan(gbank)
local GetLink = (gbank and GetGuildBankItemLink) or GetContainerItemLink
local GetItemInfo = (gbank and GetGuildBankItemInfo) or GetContainerItemInfo
...
end
Humm, unfortunately, it doesn't look that simple with the code I have :(. The original author didn't account for people wanting that feature at all.
The biggest culprit is going to be recursiveMove in Core.lua, which is in charge of moving things around. It assumes there's a unique ID for all bags, which is normally true with the regular bank, but in the case of a guild bank. It seems that the guild bank is numbered separately as it has its own set of APIs. That may mean some IDs may overlap, I think.
I'm thinking I may have to rewrite major parts of the item movement algorithms - something I'm not terribly looking forward to because it's core code and was written by the original author - I've never had to touch it.
But - being able to use it with guild banks a commonly requested feature, so I might as well get started.
Currently, Reagent Restocker makes several calls to GetContainerItemLink and GetContainerItemInfo. However, all of that changes when I want it to access the guild bank.
When the guild bank is being accessed, it needs to use GetGuildBankItemLink and GetGuildBankItemInfo for items in the guild bank.
Problem is, I'm unsure of how to do this cleanly. I started putting in a lot of if...else..end statements, but it just makes the code a lot more complex and more difficult to work with, and has to be done pretty much anywhere where I need choose between a guild bank function and the regular function.
Is there a way to cleanly use these API calls without making my code a mess?
The biggest culprit is going to be recursiveMove in Core.lua, which is in charge of moving things around. It assumes there's a unique ID for all bags, which is normally true with the regular bank, but in the case of a guild bank. It seems that the guild bank is numbered separately as it has its own set of APIs. That may mean some IDs may overlap, I think.
I'm thinking I may have to rewrite major parts of the item movement algorithms - something I'm not terribly looking forward to because it's core code and was written by the original author - I've never had to touch it.
But - being able to use it with guild banks a commonly requested feature, so I might as well get started.