#Unpacking nameplate data from tables

25 messages · Page 1 of 1 (latest)

zenith barn
#

So....
I know there might be other solutions already out there but i want one of mine and play and learn from it further.

To my setup in general, i have plenty custom options.. can link key names if needed but theyre all mentioned here anyway:

In Actions > On Init:

aura_env.spellOptions = {}

for _, spell in ipairs(PrephUIUpcomingSpells) do
    local spellID = spell.PrephUIUpcomingSpellsSpellID
    aura_env.spellOptions[spellID] = {
        active = spell.PrephUIUpcomingSpellsSpellIDActive,
        stunnable = spell.PrephUIUpcomingSpellsSpellIDStunnable,
        selfCast = spell.PrephUIUpcomingSpellsSpellIDSelf,
        colors = {
            interruptable = spell.PrephUIUpcomingSpellsSpellIDColorInt,
            stunnable = spell.PrephUIUpcomingSpellsSpellIDColorStun,
            uninterruptable = spell.PrephUIUpcomingSpellsSpellIDColorUnint,
        },
        glow = {
            enabled = spell.PrephUIUpcomingSpellsSpellIDGlow,
            glowColor = spell.PrephUIUpcomingSpellsSpellIDGlowColor,
            glowOnSelf = spell.PrephUIUpcomingSpellsSpellIDGlowOnSelf,
            glowOnSelfColor = spell.PrephUIUpcomingSpellsSpellIDGlowOnSelfColor,
        },
        sound = {
            enabled = spell.PrephUIUpcomingSpellsSpellIDSound,
            soundChoice = spell.PrephUIUpcomingSpellsSpellIDSoundChoice,
        }
    }
end
#

1sec, pulling stuff out of game

For the Trigger Setup:

Trigger 2:
Player/Unit Info > Cast > Nameplate

  • Nameplate Type: Hostile
  • Ignore Self

Trigger 1:
Custom > Trigger State Updater

  • Check On: Events
    • TRIGGER:2
#
function(allstates, event, ...)
    if event == "TRIGGER" then
        local triggerId, unitTable, spellID = ...
        print("TSU fired: event =", event, "triggerId =", triggerId, "unitTable =", tostring(unitTable), "spellID =", spellID)
        if type(unitTable) == "table" then
            for nameplateKey, innerTable in pairs(unitTable) do
                print("unitTable key:", nameplateKey, "value:", tostring(innerTable))
                if type(innerTable) == "table" then
                    local unit = innerTable.unit or nameplateKey
                    spellID = innerTable.spellID or spellID
                    
                    print("Extracted from nested table: unit =", unit, "spellID =", spellID)
                    
                    if unit and spellID then
                        break
                    end
                end
            end
        end
        
        if triggerId == 2 and spellID and unit and UnitIsEnemy("player", unit) then

            local spellData = aura_env.spellOptions[spellID]
            if spellData and spellData.active then
                print("Spell is active and tracked: ", spellID)

                local spellName, _, spellIcon = GetSpellInfo(spellID)
                local castDuration = select(4, UnitCastingInfo(unit)) or 0
                local expirationTime = GetTime() + (castDuration / 1000)
                
                allstates[spellID] = {
                    show = true,
                    changed = true,
                    name = spellName,
                    icon = spellIcon,
                    progressType = "timed",
                    duration = castDuration / 1000,
                    expirationTime = expirationTime,
                    autoHide = true,
                    color = spellData.colors.interruptable
                }
                
                print("Bar created for spell: ", spellID, spellName)```
#
            else
                print("Spell not active or not tracked: ", spellID)
            end
        else
            print("Invalid unit or spellID for TRIGGER 2: unit =", tostring(unit), "spellID =", tostring(spellID))
        end
    elseif event == "UNIT_SPELLCAST_STOP" or event == "UNIT_SPELLCAST_FAILED" or event == "UNIT_SPELLCAST_INTERRUPTED" then
        local unit, spellID = ...
        if allstates[spellID] then
            allstates[spellID].show = false
            allstates[spellID].changed = true
            print("Spell bar removed for: ", spellID)
        end
    else
        print("TSU fired with unrelated event: ", event)
        return false
    end
    
    return true
end
#

With my setup yet i get [17:30] Extracted from nested table: unit = nameplate2 spellID = nil [17:30] Invalid unit or spellID for TRIGGER 2: unit = nil spellID = nil [17:30] TSU fired: event = TRIGGER triggerId = 2 unitTable = table: 00000237B8B05C80 spellID = nil [17:30] unitTable key: nameplate1 value: table: 00000237B0DD9810 [17:30] Extracted from nested table: unit = nameplate1 spellID = nil [17:30] Invalid unit or spellID for TRIGGER 2: unit = nil spellID = nil [17:30] TSU fired: event = TRIGGER triggerId = 2 unitTable = table: 00000237B8B05C80 spellID = nil [17:30] Invalid unit or spellID for TRIGGER 2: unit = nil spellID = nil from my debug prints, so i am getting trigger 2 correctly now, and i am finding nameplate1 and nameplate2 and such. Though, im just fighted with nameplate1.

#

I really just want a WA that based on a spellID in my custom options when detected displays a bar, per mob/cast

#

Unpacking nameplate data from tables

limber shard
#

sharing auras is A LOT easier if you just upload to wago.

#

!linkit

buoyant palmBOT
#

WeakAuras doesn't show anything by default, it's just the framework that lets you import or create "Auras" to display things. If you're having an issue with an Aura, and/or want opinions on it, then you need to share the specific Aura. The best way to do this is to link it through https://wago.io/.

If you only imported the aura, you may right click the aura in-game and select Copy URL and paste it here. If you have modified the aura or created your own, you may instead select Export to string... and upload the string to https://wago.io/. This does not require an account.
You can now paste the import string directly into Discord (with no other text, only the string) and a bot will import it for you and link the wago.

limber shard
#

You're doing local triggerId, unitTable, spellID = ... but watched triggers don't send spellID as a parameter.

#

!watched

limber shard
#

If you want the spellID you need to get it from the state table this is passed in parameters. You're calling it unitTable

#

!vdt use the devtool to help inspect the table data

buoyant palmBOT
zenith barn
#

kk ill give it a shot, i thought of wago'ing it but i forgot 😦 had some trouble so had to leave

zenith barn
#

Alright, found what i got. gonna share a finished one the days in #1019675719334383696

#

tyvm ❤️

#

Just wondering how i update my information from the options - i unpack them in actions:

function PrephUI_InitializeSpellOptions()
    local customOptions = aura_env.config.PrephUIUpcomingSpells
    aura_env.spellOptions = {}
    print("Initializing spell options... Spell count:", #customOptions)
    
    for _, spell in ipairs(customOptions) do
        local spellID = tonumber(spell.PrephUIUpcomingSpellsSpellID)
        
        -- Check if the spell is active before adding it to spellOptions
        if spellID and spell.PrephUIUpcomingSpellsSpellIDActive then
            print("Adding active spellID:", spellID, "to spellOptions.")
            
            aura_env.spellOptions[spellID] = {
                active = spell.PrephUIUpcomingSpellsSpellIDActive,
                stunnable = spell.PrephUIUpcomingSpellsSpellIDStunnable,
                selfCast = spell.PrephUIUpcomingSpellsSpellIDSelf,
                colors = {
                    interruptable = spell.PrephUIUpcomingSpellsSpellIDColorInt,
                    stunnable = spell.PrephUIUpcomingSpellsSpellIDColorStun,
                    uninterruptable = spell.PrephUIUpcomingSpellsSpellIDColorUnint,
                },
                glow = {
                    enabled = spell.PrephUIUpcomingSpellsSpellIDGlow,
                    glowColor = spell.PrephUIUpcomingSpellsSpellIDGlowColor,
                    glowOnSelf = spell.PrephUIUpcomingSpellsSpellIDGlowOnSelf,
                    glowOnSelfColor = spell.PrephUIUpcomingSpellsSpellIDGlowOnSelfColor,
                },
                sound = {
                    enabled = spell.PrephUIUpcomingSpellsSpellIDSound,
                    soundChoice = spell.PrephUIUpcomingSpellsSpellIDSoundChoice,
                }
            }
            
            print("Added active spell options for spellID:", spellID)
        else
            print("Skipping inactive or invalid spellID:", spellID)
        end
    end
end

PrephUI_InitializeSpellOptions()```
#

i alrdy have set it up as function, how would i listen to options-changed?

#

I also have trouble setting the correct colors, maybe im not checking correctly for interruptable or not in the game data.

#

But atleast it now creates bars already for a given spell entryed in the custom options, so half way 😄

zenith barn
#
if event == "STATUS" then
        PrephUI_InitializeSpellOptions()
        return false -- Do not update states on STATUS, just refresh options
    end
``` just did this. worked ^^