1. #1

    Weakaura: attempt to compare nil with number

    I am using this bit of code for certain weakauras to shift down when on CD. Yet i keep running into the "attempt to compare nil with number"error in this bit of code.

    Any idea what could cause this ?

    Code:
    function(progress, startX, startY, deltaX, deltaY)
        local  ycoord,xcoord
        --Choosing what animation to show and determig start time of animation
        if aura_env.currState == "cd" then
            if aura_env.prevState == "active" then
                aura_env.animstart = GetTime()
                aura_env.animtype = "hide"
            end
            aura_env.prevState = "cd"
        elseif aura_env.currState == "ready" then
            if aura_env.prevState == "cd" then
                aura_env.animstart = GetTime()
                aura_env.animtype ="show"
            end
            aura_env.prevState = "ready"
        elseif aura_env.currState =="active"  then 
            aura_env.prevState = "active" 
        end
        
        if aura_env.animstart and GetTime()-aura_env.animstart>aura_env.animDuration then
            aura_env.animstart = nil
            aura_env.animtype = nil
        end
        
        if aura_env.animstart then         
            local animprogress = (GetTime()-aura_env.animstart)/aura_env.animDuration
            if aura_env.animtype== "hide" then
                ycoord = animprogress*aura_env.deltaY
                xcoord = animprogress*aura_env.deltaX
                WeakAuras.regions[aura_env.id].region.stacks:SetPoint("CENTER", WeakAuras.regions[aura_env.id].region.icon,"CENTER",-xcoord,-ycoord) --Moving text relative to icon so that is stays in place
                return startX+xcoord, startY+ycoord
            elseif aura_env.animtype== "show" then     
                ycoord =(1-animprogress)*aura_env.deltaY 
                xcoord =(1-animprogress)*aura_env.deltaX
                WeakAuras.regions[aura_env.id].region.stacks:SetPoint("CENTER", WeakAuras.regions[aura_env.id].region.icon,"CENTER",-xcoord,-ycoord) --Moving text relative to icon so that is stays in place
                return startX+xcoord, startY+ycoord
            end
        end
        
        if aura_env.currState == "cd"  then
            WeakAuras.regions[aura_env.id].region.stacks:SetPoint("CENTER", WeakAuras.regions[aura_env.id].region.icon,"CENTER",-aura_env.deltaX,-aura_env.deltaY)
            return startX+aura_env.deltaX, startY+aura_env.deltaY
        else 
            WeakAuras.regions[aura_env.id].region.stacks:SetPoint("CENTER", WeakAuras.regions[aura_env.id].region.icon,"CENTER",0,0)
            return startX, startY        
        end
    end
    EDIT:

    This is the error message Bugsack shows me

    79518x [string "return function(progress, startX, startY, d..."]:20: attempt to compare nil with number
    [string "return function(progress, startX, startY, d..."]:20: in function `translateFunc'
    WeakAuras\WeakAuras-2.2.1.9-3-gcaf1148.lua:2298: in function <WeakAuras\WeakAuras.lua:2242>
    Last edited by Louarn; 2016-11-06 at 04:14 PM.

  2. #2
    Line 20. aura_env.animDuration is probably nil.

  3. #3
    Quote Originally Posted by Urtgard View Post
    Line 20. aura_env.animDuration is probably nil.
    Cheers for helping ! Sorry i failed to do that. Also here is a link to the full WA: pastebin.com/uv7mhbHp



    aura_env.animDuration is declared in oninit and is 0.3.
    Code:
    aura_env.spellid=157153 --The id of totem spell
    aura_env.short=3 --time in seconds to be considered short
    aura_env.activeHEXcolor="FFFFFFFF" --AARRGGBB AA for opacity RR,GG,BB for colors in hexademical for active time left
    aura_env.cdHEXcolor="FFFFFF00" --for cd time left
    aura_env.shortCdHEXcolor="FFFF8800" --for short cd time left
    aura_env.deltaY=-20 --DeltaY when on cooldown
    aura_env.deltaX=0 -- DeltaX when on cooldown
    aura_env.currentState=""
    aura_env.animDuration =0.3
    local spellid=aura_env.spellid
    function MouseoverTooltip(region, owner,spellid)
        currentTooltipRegion = region;
        currentTooltipOwner = owner;
        
        GameTooltip:SetOwner(owner, "ANCHOR_NONE");
        GameTooltip:SetPoint("LEFT", owner, "RIGHT");
        GameTooltip:ClearLines();
        GameTooltip:SetSpellByID(spellid);
        GameTooltip:Show();
    end
    local id=aura_env.id
    
    --Creating toolip on mouseover
    WeakAuras.regions[id].region:EnableMouse(true)
    WeakAuras.regions[id].region:SetScript("OnEnter", function() MouseoverTooltip(WeakAuras.regions[id].region,WeakAuras.regions[id].region,spellid);end)
    WeakAuras.regions[id].region:SetScript("OnLeave", WeakAuras.HideTooltip);
    - - - Updated - - -

    Can be closed. Fixed it
    Last edited by Louarn; 2016-11-07 at 08:07 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •