1. #1
    Deleted

    Weak Aura string returning LUA errors

    Hi guys

    So i just finished my wa string for warning me when my current spellcast drops me below a certain mana percentage, but after I completed it im often getting the warning about a lot of errors and the option to turn of my addons.

    So I wanted to hear if there is anything in my lua code the issue or if anyone can pinpoint the root of my problems
    Code:
    function()
        
        local name, rank, icon, count  =   UnitDebuff("Player", "Arcane charge", nil, "PLAYER");
        
        local basecost = 3200;
        local cost = basecost * count;
        local spell = UnitCastingInfo("Player")
        local maxpower = UnitPowerMax("Player" , Mana);
        local mana = UnitMana("Player");
        
        local next = (mana-cost) / maxpower *100;
        local ap = UnitAura("player", "Arcane Power")
        
        
        if  next < 92 and spell == "Arcane Blast" and count >= 3 and ap~= "Arcane Power" then
            return true
            
        else
            return false
        end
        
        
        
    end

  2. #2
    Blademaster Odylle's Avatar
    7+ Year Old Account
    Join Date
    Mar 2015
    Location
    Netherlands
    Posts
    33
    Any chance you can share the error as well?

    Either way.. easiest way to troubleshoot errors is by removing line to line and print the output of the variables you set, to see if they are alright.
    You have to systematically check, this way you learn the caveats and nuances in coding.
    Have fun..

    Copying it in my editor: I think the variable next is a reserved function
    Last edited by Odylle; 2015-03-10 at 01:03 PM. Reason: Checking

  3. #3
    Quote Originally Posted by Nordahl View Post
    Code:
    function()
        
        local name, rank, icon, count  =   UnitDebuff("Player", "Arcane charge", nil, "PLAYER");
        
        local basecost = 3200;
        local cost = basecost * count;
        local spell = UnitCastingInfo("Player")
        local maxpower = UnitPowerMax("Player" , Mana);
        local mana = UnitMana("Player");
        
        local next = (mana-cost) / maxpower *100;
        local ap = UnitAura("player", "Arcane Power")
        
        
        if  next < 92 and spell == "Arcane Blast" and count >= 3 and ap~= "Arcane Power" then
            return true
            
        else
            return false
        end
        
        
        
    end
    Highlighted the problematic parts I see: If player does not have the debuff "Arcane Charge" your variable count will be nil, so no multiplication or numerical comparison is possible. Check for nil (if count then ...) to avoid.

    Also, your call UnitPowerMax("Player" , Mana) should be UnitPowerMax("Player", SPELL_POWER_MANA).

    Quote Originally Posted by Odylle View Post
    Copying it in my editor: I think the variable next is a reserved function
    There is indeed a lua function called next, but this does not prevent you to name any local (or global for that matter) variable the same.

Posting Permissions

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