Thread Tools Display Modes
05/16/14, 11:59 AM   #1
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Junk events

Hello,

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

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.
  Reply With Quote
05/16/14, 12:11 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Those constants are string IDs to get the text for the dropdown to mark and unmark as junk.
  Reply With Quote
05/16/14, 12:23 PM   #3
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Is there any MARK_AS_JUNK event or only the EVENT_INVENTORY_SINGLE_SLOT_UPDATE ?
  Reply With Quote
05/16/14, 12:28 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Install Zgoo if you don't have it installed.

Type /zgoo events

Mark an item as junk

See what it displays
  Reply With Quote
05/16/14, 12:41 PM   #5
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Right !

Will check that thx.
  Reply With Quote
05/16/14, 03:57 PM   #6
zolan
 
zolan's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 11
Originally Posted by Edda View Post
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.
  Reply With Quote
05/17/14, 09:01 AM   #7
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
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.

Last edited by lyravega : 05/17/14 at 09:06 AM.
  Reply With Quote
05/17/14, 09:19 AM   #8
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
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)

Last edited by Garkin : 05/17/14 at 11:36 AM. Reason: Do not log items junked by my addon...
  Reply With Quote
05/23/14, 01:33 AM   #9
Edda
 
Edda's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 60
Originally Posted by lyravega View Post
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 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 (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.
  Reply With Quote
05/27/14, 01:18 PM   #10
katkat42
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 155
Originally Posted by Edda View Post
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
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 )
  Reply With Quote
05/28/14, 10:23 AM   #11
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Originally Posted by Edda View Post
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
"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.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Junk events


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off