View Single Post
11-23-20, 08:07 PM   #1
Walkerbo
A Cobalt Mageweaver
 
Walkerbo's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 233
Delete cursor item not working correctly

Hi all

I am the author of a small addon called Aardvark; the addon will auto destroy listed items when a vendor window is opened.

Since 90002 when I visit a vendor the destroy item messages print but the items themselves are not deleted; no matter how many times I close and reopen the vendor window the messages print about the items never leave my bags.
I can run the destroy function manually after I have already opened the vendor window and then the items are destroyed.

This is the error I get;
Lua Code:
  1. 1x [ADDON_ACTION_BLOCKED] AddOn 'Aardvark' tried to call the protected function 'UNKNOWN()'.
  2. [string "@!BugGrabber\BugGrabber.lua"]:519: in function <!BugGrabber\BugGrabber.lua:519>
  3. [string "=[C]"]: ?
  4. [string "=[C]"]: in function `DeleteCursorItem'
  5. [string "@Aardvark\Aardvark-AR 10.8.9.0.lua"]:2112: in function <Aardvark\Aardvark.lua:2084>
  6. [string "@Aardvark\Aardvark-AR 10.8.9.0.lua"]:2490: in function <Aardvark\Aardvark.lua:2482>

I cannot work out why I get the UNKNOWN() error, or why it works fine if the vendor window is already opened.

This is my destroy function which fires on the "MERCHANT_SHOW" event;
Lua Code:
  1. local function avkDestroy()
  2.     local destroyedItemCount = 0 -- Destroyed items counting variable
  3.     local destroyedSlotCount = 0
  4.     -- Destroyed slots counting variable
  5.     for destroyBag = 0, 4 do -- Check each bag
  6.         destroyBagSlot = GetContainerNumSlots(destroyBag)
  7.         for destroySlot = 0, destroyBagSlot do -- Check each bag slot
  8.             currentItemID = GetContainerItemID(destroyBag, destroySlot)
  9.             if currentItemID then -- If current bag slot has an item then get the item info
  10.                 local _, itemLink, _, _, _, _, _, _, _, _, itemValue = GetItemInfo(currentItemID)
  11.                 local _, itemCount, _, _, _, _, _, _ = GetContainerItemInfo(destroyBag, destroySlot)
  12.                 if
  13.                     checkItemOnGlobalProtectList(currentItemID) or
  14.                         checkItemOnCharacterProtectList(currentItemID) and itemValue == 0
  15.                  then
  16.                     if AVKGlobalSettings.Destroy.dddm and AVKGlobalSettings.Protect.pdpm then -- Print protected item
  17.                         if itemLink then
  18.                             print(" - Protected: " .. itemLink .. " not destroyed.")
  19.                         end
  20.                     end
  21.                 elseif checkItemOnGlobalDestroyList(currentItemID) or checkItemOnCharacterDestroyList(currentItemID) then
  22.                     destroyedItemCount = destroyedItemCount + itemCount
  23.                     destroyedSlotCount = destroyedSlotCount + 1
  24.                     -- If item Destroy messages are on print
  25.                     if AVKGlobalSettings.Destroy.dddm then -- Print each item destroyed
  26.                         print(" - Destroyed: " .. itemCount .. " " .. itemLink)
  27.                     end
  28.                     PickupContainerItem(destroyBag, destroySlot)
  29.                     DeleteCursorItem() -- Destroy current item
  30.                 end
  31.             end
  32.         end
  33.     end
  34.     if destroyedSlotCount ~= 0 then -- If items were destroyed print out total -- If no items destroyed print out bag space message
  35.         print(
  36.             ColourList.textBluePrefixSuffix ..
  37.                 ColourList.textRed ..
  38.                     "Items destroyed :-|r " ..
  39.                         destroyedItemCount .. ColourList.textRed .. "  ~  Bagslots cleared :-|r " .. destroyedSlotCount
  40.         )
  41.     elseif AVKGlobalSettings.Destroy.dntdm then
  42.         print(ColourList.textBluePrefixSuffix .. ColourList.textRed .. "Nothing destroyed. No bag space saved.")
  43.     end
  44. end

And here is my full code.

I am really stumped with this one, and I am looking for some help to get this going again.
__________________
"As someone once told me, frames are just special types of tables, and tables are special types of pointers."
Fizzlemizz
  Reply With Quote