Questions about the API and clean code
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 you do something like:
Code:
local localItemLink = GetContainerItemLink Code:
localItemLine = GetGuildBankItemLink I'm not sure if it would work, but may be worth a try. |
Couldn't you wrap the calls in a local function and do the logic there? Then at least you wouldn't have lots of ifs running in the code.
You could either do those if-statements you mentioned or if you can tell for sure when a player is or isn't at the guild bank you could pass a boolean to the function. Code:
local function RetrieveInfo(gbank) |
Code:
function ProcessInfo(link, info) |
All times are GMT -6. The time now is 06:01 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI