1. #1

    Weak Aura Custom Text Embed Error

    Hello,

    I created an auto-clone WeakAura where I want to display custom text.

    Code:
    function (expirationTime, _, _, _, name, _, _)
        local destName = name or "nil"
        local subIndex = string.find(destName, "-")
        local printName = "nil"
        local expirationTime = expirationTime
        local distanceSquared = select(1,UnitDistanceSquared(destName))
        local distance = distanceSquared^(0.5)
        local dmgTaken = 43740 + (183338*(40-distance)/40)
        
        if (subIndex) then        
            printName = string.sub(destName, 1, subIndex-1)
        else
            printName = destName
        end
        
        if(distance > 40.00) then
            return printName.."\n"..math.floor(expirationTime-GetTime()).."\n|cFF00FF00> "..format("%.1f",distance).." <|r"..format("\n%.f k", dmgTaken/1000)
        else
            
            return printName.."\n"..math.floor(expirationTime-GetTime()).."\n|cFFFF0000> "..format("%.1f",distance).." <|r"..format("\n%.f k", dmgTaken/1000)
        end  
    end
    The result is working okay, but every time the aura is applied I'm getting
    Code:
    [string "return function() function()..."]:1: '<name>' expected near '(
    as error. Removing the function() as well as and doesn't let me access the parameters customTextFunc is passed.

  2. #2
    Deleted
    I'm not able to test this myself right now but try to remove the function wrapper and put
    Code:
    local expirationTime, _, _, _, name = ...
    in the first line. WeakAuras should compile the chunk to a vararg function.
    Last edited by mmoc7723fe36c9; 2015-07-07 at 11:04 AM.

  3. #3
    Doesn't help much :/

    Changed the code to:

    Code:
        local expirationTime, _, _, _, name = ...
        
        local destName = name or "nil"
        local subIndex = string.find(destName, "-")
        local printName = "nil"
        
        local distanceSquared = select(1,UnitDistanceSquared(destName))   -- Get distance of unit the aura triggered from
        local distance = distanceSquared^(0.5)                                                       -- Converting to yards
        local dmgTaken = 43740 + (183338*(40-distance)/40)                      -- Calculating the dmg taken by the explosion
        
        local expTime = expirationTime or 0
        expTime = (expTime-GetTime())                                                                    --Calculating the remaining duration in seconds
        
        if (subIndex) then        
            printName = string.sub(destName, 1, subIndex-1)                               --Truncating "-" as well as Realm-Name
        else
            printName = destName
        end
        
        if(distance > 40.00) then                                                                                  --Unit is more than 40y away -> green text
            return printName.."\n"..string.format("%.1f",expTime).."\n|cFF00FF00> "..format("%.1f",distance).." <|r"..format("\n%.f k", dmgTaken/1000)
        else                                                                                                                        --Unit is less than 40y away - red text        
            return printName.."\n"..string.format("%.1f",expTime).."\n|cFFFF0000> "..format("%.1f",distance).." <|r"..format("\n%.f k", dmgTaken/1000)
        end
    gets me following error as soon as I close the WA menu
    Code:
    [string "return ..."]:2: unexpected symbol near 'local'
    The aura doesn't work with this code.

    Changing the code to
    Code:
    function(...)
        local expirationTime, _, _, _, name = ...
        
        local destName = name or "nil"
        local subIndex = string.find(destName, "-")
        local printName = "nil"
        
        local distanceSquared = select(1,UnitDistanceSquared(destName))   -- Get distance of unit the aura triggered from
        local distance = distanceSquared^(0.5)                                                       -- Converting to yards
        local dmgTaken = 43740 + (183338*(40-distance)/40)                      -- Calculating the dmg taken by the explosion
        
        local expTime = expirationTime or 0
        expTime = (expTime-GetTime())                                                                    --Calculating the remaining duration in seconds
        
        if (subIndex) then        
            printName = string.sub(destName, 1, subIndex-1)                               --Truncating "-" as well as Realm-Name
        else
            printName = destName
        end
        
        if(distance > 40.00) then                                                                                  --Unit is more than 40y away -> green text
            return printName.."\n"..string.format("%.1f",expTime).."\n|cFF00FF00> "..format("%.1f",distance).." <|r"..format("\n%.f k", dmgTaken/1000)
        else                                                                                                                        --Unit is less than 40y away - red text        
            return printName.."\n"..string.format("%.1f",expTime).."\n|cFFFF0000> "..format("%.1f",distance).." <|r"..format("\n%.f k", dmgTaken/1000)
        end  
    end
    results in
    Code:
    [string "return function() function()..."]:1: '<name>' expected near '('
    [string "return function() function()..."]:1: '<name>' expected near '('
    every time the aura is triggered, but remainder of the code works.

  4. #4
    Deleted
    Your last code snippet works for me without error when slapping it on a WeakAura checking Power Word: Fortitude. In fact the one in your very first post works as well. Can we get an import of the whole WeakAura?

    Also "name" in the parameters refers to the aura's name, from WeakAura's text.lua (line 98):
    Code:
    local custom = customTextFunc(region.expirationTime, region.duration, values.progress, values.duration, values.name, values.icon, values.stacks)
    Last edited by mmoc7723fe36c9; 2015-07-07 at 07:12 PM.

  5. #5
    Name does display the name of the WeakAura while it's not triggered, but as it is triggered it shows the name of the target.

    Here the full aura:
    Code:
    d0uroaGiI0LeegfQItHuzvskv9kuLuMfvIBrb7ss(LGOggQQJrHwMG0ZqknnjQRrs12Ku13qvQXrL05Ki16qvs18iuH7jPY(iuvhKqvwOGipKKutKKexuIqBKK4JifAKOkXjLuSsI4LskvMPerDtjLYoPs9tcWqrkyPeQ0tP0uf4QsKSvuLK(kHkAUKu2RO)sGgmCyHwmb5XuXKrYLrSzj8zcz0ivDAQ61ifnBI62Ky3K63sz4cQJlrWYrLNlvthLRtrBxsjFNaA8ekNNGA9sez(KK09rvsSF1PXmiT90gALXk(vQNwL0sLwQmiTI4AcmTLCjQsqAftaffDclvXq9U6Q6Q7k)sZBAvN2stBOLZcdLlNwHfqrrNWsv4TRgdTC5YQZ7sxFPdvD1PnlmuUCA5iI8nDGWHjPLsyDuX7iIRzgoT9Wrhs6UE(PvOghfHtaffDclDBSCA7e5cAO51S0kU1qJ8sqA9uPvviczwu0tRa9um6tvQNwAP1ORUYVCP5nTgv31YzHHYLtR2ujGZlseHRNUnMw6jEr0Zs3UYpTYTivgKwZorqh5yVNcLwUOdjdsRIPmZNbjlzPLYxu4DmLzcNbPvXuM5ZGKLS0YIYenldsRIPmZNbjlzPLRjtYG0QykZ8zqYswYslrSWrnfHkfkzP1jds3gZG06y2znLaIyS0wyQDy(MMNQQk6wYymgYnNO8GiwypxK5B6aVcXLHGUme0LHGUm0rfYOUrvv1sgJXyjJXyi3CIYdksN5oQqg1n0rfYOXnKQ9YsxYymgYnNO8OBkunAkIyJ6gDgNxlQQWRP4HI0zUJkexgsniLULmgJHCZjkpcZ51m3rfYOUHuTxw6sgJXyjJXyi3CIYdkFNf1oeBjyg5iuJ6gDImXHXJrxkL2ZufFNf1oeBjyg5iu8qr6m3rfcD0ngddgg0iHnO8Dwu7qgTIHP2Zgm6jJOjxCW48Ier4iuJcUMYsgJXqU5eLhu(olQDiJ6gu(olQDi2sWmYrOMxHh(vQt3ymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXWGHHQB6Ar4yETObRneoYr1xYymgYnNO8GsruqKMe9OUrzA5Dz(dETbpgDLwAP11AppL5BGY3zrTdHUqUmF6gJXymgJXymgJXymgJXWGHHQJYoMYrMxlAWONmOuenyrAs0dHeEWONmiIfwU19n9sgJXyjJXyi3CIYdIyHd8kKrDdIyH9CrMVPd8kKrJBWFjJXyqelCGxHmQBWdrSWbEfIbAKWc8keEOJUXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXWGbvhLDmLJmVw0GrpzWruIETxlAqzYfz(ME41JoXPPP6lzmgJLmgJHVyWt3uOA0ueXOBWONOhJXymgJLmgJXymgH58AM7Oczu3OZ48ArvDtH4HI0zUJkexggDz0nfQgnfrmdgPBmgJXymgJXymgJXymgJXymgJXyyWqaNP2jY8ArdPgKoI9HajYYJyFiUKOSIb3rfYsgJXGi3jlzmgJXymcZ51m3rfYOUbfPZChvilzmgdIMAjJXySKXym8f8q57SO2Hme)rz(v85t3GrprpgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJHbdLs7zdFFO04idg9r9OmFHhrbgfEyq8hI4ie9GreJTKXymgJXGJWm50JWCEnZDuHuvjvnT0QQoJZRfvv04uImEKgIkJfsDHiw4aVcHUQkPQPvvhvuHpFvuHpFXFiTQQOXPez8inevglK6cLVZIAhcDvvshIdvLtAvvrJtjY4rQA6quvmOPuxgukIcI0KOdzJ85ZNULmgJbrUtgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymgJXymmyOuApB47dzsVpy0h1JY8fEefyu4HHbhHAWiIXgJXymgJLmgJXymgCeMjNEeMZRzUJkKQkPQPLwv1zCETOQIgNsKXJ0quzSqQleXch4vi0vvjvnTQ6OIkQOcF(85l(dPvvfnoLiJhPHOYyHuxO8Dwu7qORQs6qCOQCsRQkACkrgpsvthIQIbnL6YGsruqKMeDiBKpF(0TKXymiAQXyjen1swYswYswsAJomFt3ZG02zrowgKwhZoRPK2ctTdZ308q3sgJXyjenvA7ntnvARrZiCfrhIAIhfLa0D1eNKinfptUyxTAJq5JQzBMAQUAINNJxAC6QMirPLQjOJzN1uYqkTunb7ntnvkuYsBHx770NbPT3m1uP12m1uQzdtKL7Qz9knnngvicYR67MrzbdPifnWr69kbgRvAPAc2BMAQuOKLS0w00mvKJI6PnGxQr11obuQGsUg3LyAzCErIiCzqA7HjYY1qLUv31sNwhZoRPiit4WK0sQfrZsRJzN1ueKEpfjTmVcHkTuMCrMVPtRr(P1u7zPvXuM5tRJzN1usBAj1IOz90MwDuHKwl9rQMahIZghfV(GgIEDAPiczwueiCysA5fXtCRnvkvjNS0gMRjIJ070ahXX39nD6MFAPN4frplD7k)0k3IuzqAn7eb1KAr4sHsBj10K0Ylez5cphzOAplsrKtlr70m1mcNNkTg5TR0MwZorqI2PzQzeopvkuAP8ffEhtzMWzqAvmLz(mizjlTCrhsgKwftzMpdswYslxtMKbPvXuM5ZGKLS0YIYenldsRIPmZNbjlzP1SteSKAAskuYsBrtZS(sIKUdTCAP89WYrHTSOdn7PneoPLJiY30bchMKwVttNwV2Ze0PPewMWiuPBJP1P1KPAcuNcL2ol6qZUQBAw0RviAwAfqPcS1OkLyAJuuEMVPJYcY48Ier46zqYsRNkT0yJJu4jAQHHrqZ0H(rRyOkTMYqCJArK0kqpfJ(0TR8tR2ujGZlseHRNUnMwHfqrrNWs3gkZpTu(Ey5OW1400PTgnJWveDiQvJtt3vlkKx2ZewqHA9UOghPWt0ucYAMo03kOAnL02zrhA2PHMxZsBijGGabuBPLreJP6MCJlds3HMQupVnAm0Y1RoFAvN2qvNVXSWG60MUPnvP(qnwpVPL265tBO8o0qnwFwyq96twYswARv62y5qnMSmba
    The range naturally only works when testing with player-targets or pets; NPCs won't give you a value for the distance. But target-name as well as the countdown work as desired.

  6. #6
    Deleted
    Your error is in the custom code under "Actions" - "On Show".

    Edit: And you're right, the name field seems to give the unit's name when using a multi-target trigger, that's really good to know.
    Last edited by mmoc7723fe36c9; 2015-07-08 at 03:36 PM.

  7. #7
    Quote Originally Posted by lleaf View Post
    Your error is in the custom code under "Actions" - "On Show".
    Holy crap, how could I miss that. Thank you .

Posting Permissions

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