I don't know what the invoiceType string exactly looks like, but I guess it is something like "Sold item: Seller ..."?
In that case you'll have to search for the pattern "seller" inside the string. Comparing the full string does not work as "seller" is not equal to "Sold item: Seller ....".
Lua Code:
if string.find(invoiceType, "seller") then
If you are unsure if it is "seller" or "Seller" or "SELLER" or whatever, then it could be helpful to convert invoiceType before comparing them:
Lua Code:
if string.find(string.lower(invoiceType), "seller") then
And last but not least you should declare auditorMode as local and return it with you function:
Lua Code:
function Accountant_DetectAhMail()
local numItems = GetInboxNumItems()
local invoiceType = GetInboxInvoiceInfo(numItems)
local auditorMode
if invoiceType == "seller" then
auditorMode = "AH";
else
auditorMode = "MAIL";
end
return auditorMode
end
If you do not use auditorMode somewhere else then this would be a better way to do it:
Lua Code:
function Accountant_DetectAhMail()
local numItems = GetInboxNumItems()
local invoiceType = GetInboxInvoiceInfo(numItems)
if invoiceType == "seller" then
return "AH"
else
return "MAIL"
end
end
Personally I would return a boolean instead of a string as this is a bit easyer to handle. Like
Lua Code:
function Accountant_DetectAhMail()
local numItems = GetInboxNumItems()
local invoiceType = GetInboxInvoiceInfo(numItems)
if invoiceType == "seller" then
return true
end
end
Then use it like
Lua Code:
if Accountant_DetectAhMail() then
--
end
instead of doing something like
Lua Code:
if Accountant_DetectAhMail() == "AH" then
--
end
[e]
And if you're not using multiple files with you addon, then you should probably declare you function as local:
Lua Code:
local function Accountant_DetectAhMail()
local numItems = GetInboxNumItems()
local invoiceType = GetInboxInvoiceInfo(numItems)
if invoiceType == "seller" then
return true
end
end