ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Junk events (https://www.esoui.com/forums/showthread.php?t=1523)

Edda 05/16/14 11:59 AM

Junk events
 
Hello,

It looks like I am flooding the Lua/XML forum here :rolleyes:

I searched in the wiki for junk related stuff and found 2 meaty globals :

["SI_ITEM_ACTION_MARK_AS_JUNK"] = 1787
["SI_ITEM_ACTION_UNMARK_AS_JUNK"] = 1788

These look like exactly what I need for my addon but now, I need to find the Event(s) that make use of these.

Did anyone find the junk related events ? It seems from these 2 globals that there should be an ITEM_ACTION event or something.

The event I am using right now is EVENT_INVENTORY_SINGLE_SLOT_UPDATE -> eventCode, bagId, slotId, isNewItem, itemSoundCategory, updateReason but updateReason only accounts for ["INVENTORY_UPDATE_REASON_DURABILITY_CHANGE"] = 1 and ["INVENTORY_UPDATE_REASON_DEFAULT"] = 0 so no luck here.

Any info rly appreciated.

Seerah 05/16/14 12:11 PM

Those constants are string IDs to get the text for the dropdown to mark and unmark as junk.

Edda 05/16/14 12:23 PM

Is there any MARK_AS_JUNK event or only the EVENT_INVENTORY_SINGLE_SLOT_UPDATE ?

Seerah 05/16/14 12:28 PM

Install Zgoo if you don't have it installed.

Type /zgoo events

Mark an item as junk

See what it displays :)

Edda 05/16/14 12:41 PM

Right !

Will check that thx.

zolan 05/16/14 03:57 PM

Quote:

Originally Posted by Edda (Post 7872)
Is there any MARK_AS_JUNK event or only the EVENT_INVENTORY_SINGLE_SLOT_UPDATE ?

There is no MARK_AS_JUNK event last I checked.

lyravega 05/17/14 09:01 AM

In my add-on, here is how I handle junk (don't mind the if checks in front of the event registers):

Registering event & marking junk:
Code:

if QB_vars.trashTreatmentSelection >= 2 then EVENT_MANAGER:RegisterForEvent( "QB", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, QB_HandlerSingleSlotUpdate ) end
...
local function QB_HandlerSingleSlotUpdate( _, bagId, slotIndex, isNewItem )
        if not isNewItem then return end
        if GetItemType( bagId, slotIndex ) == 48 then SetItemIsJunk( bagId, slotIndex, true ) end
end

Auto-sell:
Code:

if QB_vars.trashTreatmentSelection == 3 then EVENT_MANAGER:RegisterForEvent( "QB", EVENT_OPEN_STORE, QB_HandlerStoreOpened ) end
...
local function QB_HandlerStoreOpened()
        SellAllJunk()
end

In short, when we get an item, the event will fire, and we check if it is a new item, then if it is a trash item by using the passed badID and slotIndex. The API function, GetItemType() will return 48 if it is a trash quality item. If it is so, we mark it as junk.

Garkin 05/17/14 09:19 AM

What I'm trying to use in my Dustman (testing right now)
Lua Code:
  1. local markedAsJunk = {}
  2. local handleJunk = true
  3.  
  4. local function HandleJunk(bagId, slotId, itemLink, sellPrice)
  5.  
  6.    --some code here
  7.  
  8.    if not IsItemJunk(bagId, slotId) then
  9.       handleJunk = false
  10.       SetItemIsJunk(bagId, slotId, true)
  11.       handleJunk = true
  12.  
  13.       --more code here
  14.  
  15.    end
  16. end
  17.  
  18. local function OnInventorySlotUpdate(eventCode, bagId, slotId, isNewItem, itemSoundCategory, updateReason)
  19.    if updateReason == INVENTORY_UPDATE_REASON_DURABILITY_CHANGE then return end
  20.  
  21.    if bagId == BAG_BACKPACK then
  22.       local itemLink = GetItemLink(bagId, slotId)
  23.       local itemId, quality, level = select(4, ZO_LinkHandler_ParseLink(itemLink))
  24.       if itemId == "" or quality == nil or level == nil then return end  --empty slot
  25.       local itemType = GetItemType(bagId, slotId)
  26.       local _, _, sellPrice, _, _, _, itemStyle, quality = GetItemInfo(bagId, slotId)
  27.  
  28.       --some code here
  29.  
  30.       if markedAsJunk[itemId.."_"..quality.."_"..level] then
  31.          HandleJunk(bagId, slotId, itemLink, sellPrice)
  32.          return
  33.       end
  34.  
  35.       --more code here
  36.  
  37.    end
  38. end
  39.  
  40. local function OnLoad(eventCode, name)
  41.    if name ~= "Dustman" then return end
  42.  
  43.    -- some code
  44.  
  45.    markedAsJunk = ZO_SavedVars:New("Dustman_Junk_SavedVariables", 1)
  46.    
  47.    local original_SetItemIsJunk = SetItemIsJunk
  48.    SetItemIsJunk = function(...)
  49.       local bagId, slotId, junk = ...
  50.       local itemLink = GetItemLink(bagId, slotId)
  51.       local itemId, quality, level = select(4, ZO_LinkHandler_ParseLink(itemLink))
  52.       if handleJunk then
  53.          markedAsJunk[itemId.."_"..quality.."_"..level] = junk and true or nil
  54.       end
  55.       original_SetItemIsJunk(...)
  56.    end
  57.  
  58.    --more code and events
  59.  
  60.    EVENT_MANAGER:RegisterForEvent("Dustman_InventorySingleSlotUpdate", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnInventorySlotUpdate)
  61.  
  62.    EVENT_MANAGER:UnregisterForEvent("Dustman_OnLoad", EVENT_ADD_ON_LOADED)
  63. end
  64.  
  65. EVENT_MANAGER:RegisterForEvent("Dustman_OnLoad", EVENT_ADD_ON_LOADED, OnLoad)

Edda 05/23/14 01:33 AM

Quote:

Originally Posted by lyravega (Post 7923)
In short, when we get an item, the event will fire, and we check if it is a new item, then if it is a trash item by using the passed badID and slotIndex. The API function, GetItemType() will return 48 if it is a trash quality item. If it is so, we mark it as junk.

About trash items : I am VR1 and never got any trash item (if they are supposed to go under the trash inventory tab). I still wonder what they are :D Problem is, my addon doesn't handle 'trash items' (to mark them as junk) but any 'already marked as junk' item. Could be crafting materials or anything not 'trash items'. Therefore I can't be checking the itemType == 48 thing I guess (if 48 = trash quality item).

Here is how I am handling the garbage :D (note I had issues with items gained thru deconstruction or bank retrievals)

Lua Code:
  1. -- Loot or deconstruction
  2.         if not IsItemJunk(bagId, slotId) and RJ.User.Memory[itemData.itemId] ~=nil and isNewItem then
  3.        
  4.             SetItemIsJunk(bagId, slotId, true)
  5.             if RJ.User.Options.Verbous then d(RJ.niceName .. " |cffffff[" .. itemData.itemLink .. "]|r moved to junk !") end
  6.            
  7.         -- Bank pulls
  8.         elseif GetGameTimeMilliseconds() - RJ.bankEvent < RJ.trackDelay and not IsItemJunk(bagId, slotId) and RJ.User.Memory[itemData.itemId] ~= nil and not isNewItem then
  9.        
  10.             SetItemIsJunk(bagId, slotId, true)
  11.             if RJ.User.Options.Verbous then d(RJ.niceName .. " |cffffff[" .. itemData.itemLink .. "]|r moved to junk !") end
  12.        
  13.         -- Manually inserting new junk item
  14.         elseif IsItemJunk(bagId, slotId) and RJ.User.Memory[itemData.itemId] == nil and not isNewItem then
  15.            
  16.             RJ.User.Memory[itemData.itemId] = itemData;
  17.             if RJ.User.Options.Verbous then d(RJ.niceName .. " |cffffff[" .. itemData.itemLink .. "]|r added to junklist.") end
  18.            
  19.         -- Manually removing junk items
  20.         elseif not IsItemJunk(bagId, slotId) and RJ.User.Memory[itemData.itemId] ~= nil and not isNewItem and not RJ.craftEvent then
  21.        
  22.             RJ.User.Memory[itemData.itemId] = nil
  23.             if RJ.User.Options.Verbous then d(RJ.niceName .. " |cffffff[" .. itemData.itemLink .. "]|r removed from junklist.") end
  24.         end

Might not be perfect but working so far. The GetGameTimeMilliseconds() - RJ.bankEvent < RJ.trackDelay checks if a bank pull happened in the last 50 milliseconds. The not RJ.craftEvent check if we are 'inside' a craft event (after craft started and before craft completed). Had to do this because items would sometimes (go figure) get removed from my addon junk list while deconstructing or pulling bank items.

katkat42 05/27/14 01:18 PM

Quote:

Originally Posted by Edda (Post 8320)
About trash items : I am VR1 and never got any trash item (if they are supposed to go under the trash inventory tab). I still wonder what they are :D

Some examples of trash items are ectoplasm, foul hides, carapaces. They are anything described as "sell this item to a merchant for gold". They show up under the "Misc" category by default; you have to move them to Junk manually (or with an add-on ;) )

zgrssd 05/28/14 10:23 AM

Quote:

Originally Posted by Edda (Post 8320)
About trash items : I am VR1 and never got any trash item (if they are supposed to go under the trash inventory tab). I still wonder what they are :D

"Mark as Junk" has two effects:
They are not anymore listed in thier original category, but instead in their junk category.
Junk items can be quickly sold (with value preview) at any trader by hitting X. Especially vendor trash and white gear without a trait lands in my junkyard. Same with too low potions (when I get enough of higher level), already known recipes, and the like.

Mark as junk is really just there to give you better overview and allow you to sell trash fast.


All times are GMT -6. The time now is 05:03 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI