Thread Tools Display Modes
04-06-17, 04:06 AM   #1
Eommus
An Aku'mai Servant
Join Date: Apr 2017
Posts: 34
Addon to log all the loot I get

Hi,

For my own purposes, I need the following ability:

When I get loot (any type of loot) from a mob, from a quest reward, by opening a container, by opening mail, by crafting or by trading (shortly, in any way a character can get loot), I want this addon to record the "name, id, type, item level" of the loot I got in a text file (lua file is ok too). To give example, let's say I looted Corpsemaker, and Iron Ore, it will record the following:

Corpsemaker|6687|Two-Handed Axes|35
Iron Ore|2772|Metal & Stone|30


I have the following so far:

LootLog.toc

Code:
## Interface: 70200
## Title: Loot Log
## Notes: Logs the loot you get.
## SavedVariables: LootLog

main.lua
main.lua

Code:
LootLog = {}

local f = CreateFrame("Frame")

local function Log_Loot(tooltip) -- How to get the info about just looted item?
	-- 1. Get looted item id, name, item level, type, subtype
	local item = tooltip:GetItem()
	local itemName = GetItemInfo(item)
	local _, itemLink = GetItemInfo(item) -- I need to extract item ID from this somehow.
	local _, _, _, itemLevel = GetItemInfo(item)
	local _, _, _, _, _, itemType = GetItemInfo(item)
	local _, _, _, _, _, _, itemSubType = GetItemInfo(item)
	
	-- 2. Save the above info to saved variables file.
	table.insert(LootLog, itemName.."/"..itemLink.."/"..itemLevel.."/"..itemType.."/"..itemSubType.."\n")
end

f:SetScript("OnEvent", Log_Loot)
f:RegisterEvent("ITEM_PUSH")
Thanks for any help.
  Reply With Quote
04-06-17, 11:04 PM   #2
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Hi,

I used something like this in an addon that monitors loots of anyone.
It extracts loot from chat.

Lua Code:
  1. if event == "CHAT_MSG_LOOT" then
  2.    
  3.         local lootstring, _, _, _, player = ...
  4.         local itemLink = string.match(lootstring,"|%x+|Hitem:.-|h.-|h|r")
  5.         local itemString = string.match(itemLink, "item[%-?%d:]+")
  6.         local _, _, quality, _, _, class, subclass, _, equipSlot, texture, _, ClassID, SubClassID = GetItemInfo(itemString)
  7.  
  8.         if UnitName("player") == player then
  9.                  -- your code .
  10.  
  11. -- other code

Hope it is usefull.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote
04-07-17, 08:40 AM   #3
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
These are interesting ideas. Being able to go back at the end of a session and see what you looted would be interesting and possibly useful if you are collecting things.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
04-07-17, 09:33 AM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Cross-post for reference

http://www.mmo-champion.com/threads/...the-loot-I-get
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Addon to log all the loot I get


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