Thread Tools Display Modes
10-25-22, 07:39 PM   #1
pflueger92
A Murloc Raider
Join Date: Oct 2022
Posts: 6
[Help] WeakAuras Custom LUA Modification

I really don't know of a community to post something like this in, and I'm aware the purpose of this forum isn't for free work but I hope it's a simple modification and I just simply do not understand LUA to this level.

I found a pretty cool WeakAura that tracks loot. I was hoping to modify it to replace an existing loot display when another is looted. Making it session based. So you loot cloth for example, the WeakAura shows this with an item count, you loot another cloth and instead of two entries it just replaces the old one 'consolidating' if you will.

I know it is tracked by time right now and I think I can wrap my head around modifying that to be session based but don't know how to modify the script to essentially say "hey if this has already been looted, or the quantity is > 0 then just update the original message.

Code:
function(allstates, track_event, event, params)
    if not params then return end
    local text,_,_,_,player,_,_,_,_,_,guid = unpack(params)
    local itemLink, itemIcon, message, count, amount, questID, currencyId,_
    local name = UnitFullName("player")
    local itsMe = player == name

    if event == "PLAYER_MONEY" then 
        local msg, copper = aura_env.money()
        message = msg
        itemIcon = aura_env.get_currency_icon(copper)
        shouldGlow = false

    elseif event == "QUEST_CURRENCY_LOOT_RECEIVED" then
        questID, currencyId, count = select (1, unpack(params))
        if currencyId then
            local info =  C_CurrencyInfo.GetCurrencyInfo(currencyId)
            text = info.name
            amount = info.quantity
            itemIcon = info.iconFileID
            shouldGlow = false
            message = aura_env.currency(text,count,amount)
        end

    elseif event == "QUEST_LOOT_RECEIVED" then
        questID, itemLink, count = select (1, unpack(params))
        if itemLink then 
            _, _, _, _, _, itemType, _, _, _, itemIcon = GetItemInfo(itemLink)
            message = aura_env.message(itemLink,count,amount)  
            shouldGlow = false      
        end        

    elseif event=="CURRENCY_DISPLAY_UPDATE" then
        currencyId, amount, count = select(1,unpack(params))
        if currencyId then
            local info =  C_CurrencyInfo.GetCurrencyInfo(currencyId)
            text = info.name
            amount = info.quantity
            itemIcon = info.iconFileID
            shouldGlow = false
            if itemIcon and count ~=0 then
                message = aura_env.currency(text, count, amount)
            end            
        end        

    elseif event == "CHAT_MSG_CURRENCY" then
        itemLink, count = string.match(text, "(|c.+|r) ?x?(%d*).?")
        local info = C_CurrencyInfo.GetCurrencyInfoFromLink(itemLink)
        text = info.name
        itemIcon = info.iconFileID        
        amount = info.quantity
        message = aura_env.message(itemLink, count, amount) 
        shouldGlow = false       

    elseif event == "CHAT_MSG_LOOT" and (guid and guid == UnitGUID("player") or itsMe) then  
        itemLink, count = string.match(text, "(|c.+|r) ?x?(%d*).?")
        count = tonumber(count)
        if itemLink then
            local quality
            _, _, quality, _, _, itemType, _, _, _, itemIcon = GetItemInfo(itemLink)
            --SendChatMessage(text, "WHISPER", nil, name)
            if quality and quality >= (aura_env.config.minQuality or 0) or itemType == "Quest" then
                amount = GetItemCount(itemLink, aura_env.config.countFromBank)
                message = aura_env.message(itemLink, count, amount)
                shouldGlow = itemType == "Quest"
            end            
        else
            message = text
        end
    end

    if not itemIcon then itemIcon = 133784 end

    if message then 
        allstates[#allstates+1] = {
            show = true,
            changed = true,
            progressType = "timed",
            duration = (aura_env.config.duration or 5),
            expirationTime = GetTime() + (aura_env.config.duration or 5),
            autoHide = true,
            name = message,
            icon = itemIcon,
            link = itemLink,
            shouldGlow = shouldGlow
        }
    end

    return true
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » [Help] WeakAuras Custom LUA Modification


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