WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Noob question on DK rune changes (https://www.wowinterface.com/forums/showthread.php?t=54085)

Xaerran 07-31-16 11:10 PM

Noob question on DK rune changes
 
I have an addon I am trying to update that would pull the rune count, by type and make spell suggestions based on what it found. I am trying to update this, to simply return the count for all of the runes (as the rune system changed). Would anyone mind helping me here? I took a crack at it, but it doesn't seem to be working :( Thanks for helping - I am fairly new to this.

New (not working):
Code:

local runes_c = {
    [1] = 0,
    [2] = 0,
    [3] = 0,
    [4] = 0,
    [5] = 0,
    [6] = 0
}

Goof.condition.register("runes.count", function(target, rune)
    local rune = string.lower(rune)
    runes_c[1], runes_c[2], runes_c[3], runes_c[4], runes_c[5], runes_c[6] = 0,0,0,0,0,0
    for i=1, 6 do
        local _, _, c = GetRuneCooldown(i)
        if c then
          runes_c[i] = runes_c[i] + 1
        end
    end
    return runes_c[1] + runes_c[2] + runes_c[3] + runes_c[4] + runes_c[5] + runes_c[6]
end)

Original:
Code:

local runes_t = {
    [1] = 0,
    [2] = 0,
    [3] = 0,
    [4] = 0
}
local runes_c = {
    [1] = 0,
    [2] = 0,
    [3] = 0,
    [4] = 0
}

Goof.condition.register("runes.count", function(target, rune)
    local rune = string.lower(rune)
    runes_t[1], runes_t[2], runes_t[3], runes_t[4], runes_c[1], runes_c[2], runes_c[3], runes_c[4] = 0,0,0,0,0,0,0,0
    for i=1, 6 do
        local _, _, c = GetRuneCooldown(i)
        local t = GetRuneType(i)
        runes_t[t] = runes_t[t] + 1
        if c then
            runes_c[t] = runes_c[t] + 1
        end
    end
    if rune == 'frost' then
        return runes_c[3] + runes_c[4]
    elseif rune == 'blood' then
        return runes_c[1] + runes_c[4]
    elseif rune == 'unholy' then
        return runes_c[2] + runes_c[4]
    elseif rune == 'death' then
        return runes_c[4]
    end
    return 0
end)


Fizzlemizz 07-31-16 11:25 PM

For the total active runes you should be able to:

Lua Code:
  1. local runeCount = 0
  2. for i=1, 6 do
  3.     local _, _, runeReady = GetRuneCooldown(i)
  4.     if runeReady then
  5.         runeCount = runeCount+1
  6.     end
  7. end
  8. return runeCount

Xaerran 07-31-16 11:55 PM

Thanks so much! I had just found the GetRuneCount function but was missing the definition on runeReady.

there is a minor camel case capitalization error in your snippet, but this was perfect!

Thanks again

Fizzlemizz 08-01-16 12:11 AM

Quote:

Originally Posted by Xaerran (Post 317268)
there is a minor camel case capitalization error in your snippet, but this was perfect!

Thanks again

Fixed in the original :o.


All times are GMT -6. The time now is 06:27 AM.

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