Originally Posted by SnowmanDK
Is there a way to check for this?
I ask as I am trying to integrate support for Item Saver in my Bank Manager Revived.
Item Saver uses a global variable which I pull (ItemSaver_IsItemSaved(item.bag, item.slot)),
It returns 1 if the checked item is saved, otherwise nil.
I made that work fine, but when Item Saver is not enabled in AddOns, then I get a "function expected instead of nil" error.
So... I guess I need to make sure Item Saver is enabled in AddOns before even running this check.
Can this be done?
|
It can be easily done. At first check if global function exists and if it does then use it.
Lua Code:
if ItemSaver_IsItemSaved and ItemSaver_IsItemSaved(item.bag, item.slot) then
--your code here
end
This is a function which I use in Dustman:
lua Code:
local function IsItemProtected(bagId, slotId)
--pets
local iconTexture = GetItemInfo(bagId, slotId)
if iconTexture:lower():find("icons/pet_") then
return true
end
--Item Saver support
if ItemSaver_IsItemSaved and ItemSaver_IsItemSaved(bagId, slotId) then
return true
end
--FCO ItemSaver support
if FCOIsMarked and FCOIsMarked(GetItemInstanceId(bagId, slotId), -1) then
return true
end
return false
end