View Single Post
05/13/14, 02:03 PM   #17
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Edda View Post
Know issue : nothing is working - lawl

The addon doesn't even get loaded. And it's good as such cuz it's still not working the way it should - Im trying to find how to detect items marked as junk right now :/

And I think I didn't fully understand your request. You want your tagged 'Junk' items being moved to your 'Junk' tab automatically is that right ??? I understood you only want to somehow display a list of any items you actually tagged as such - didn't get the auto-move request here :|

But I think it's totally doable just need to figure out how to bloody detect those junk items. I thought I found the right function but it seems it doesn't do what it should :/

Ill keep you in the know
Lets try some hack

To mark item as junk game uses function:
SetItemIsJunk(integer bagId, integer slotIndex, bool junk)

I didn't try it, but it could work:
Lua Code:
  1. local myJunkMemory = {}
  2.  
  3. ZO_PreHook(SetItemIsJunk, function(bagId, slotId, junk)
  4.       local itemLink = GetItemLink(bagId, slotId)
  5.       local itemId = select(4, ZO_LinkHandler_ParseLink(itemLink))  --string, if you want number use tonumber(itemId)
  6.       myJunkMemory[itemId] = junk and true or nil
  7.       return false
  8.    end)

Then you can use something like this:
Lua Code:
  1. local function OnInventorySlotUpdate(eventCode, bagId, slotId, isNewItem, itemSoundCategory, updateReason)
  2.    if updateReason == INVENTORY_UPDATE_REASON_DURABILITY_CHANGE or bagId ~= BAG_BACKPACK then
  3.       return
  4.    end
  5.  
  6.    local itemLink = GetItemLink(bagId, slotId)
  7.    local itemId = select(4, ZO_LinkHandler_ParseLink(itemLink))
  8.    if myJunkMemory[itemId] then
  9.       SetItemIsJunk(bagId, slotId, true)
  10.    end
  11. end
  12.  
  13. EVENT_MANAGER:RegisterForEvent("myAddon_InventorySingleSlotUpdate", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnInventorySlotUpdate)

Last edited by Garkin : 05/13/14 at 04:56 PM.
  Reply With Quote