1. #1
    Deleted

    WeakAuras2 multiple Talent Filter

    I'm in the proces of a little WeakAura atm. The problem is, I need to check if Ascendance is active and since WeakAuras doesn't support a multiple talent selector in it's Load-Options I can only think of 2 ways to check it:

    1. I duplicate my complete WeakAura and assign the different talent filters

    or

    2. I make a custom trigger that checks every time if Ascendence is active by using GetTalentInfo()

    My Question is wich of these two choices is more CPU friendly or is there an even more CPU friendly way to do this?

    Thanks in advance ^^

  2. #2
    We should be able to override WA functionality to support multi-talent checks. I'll see if I can figure make that into a plugin

  3. #3
    Deleted
    Quote Originally Posted by pnutbutter View Post
    We should be able to override WA functionality to support multi-talent checks. I'll see if I can figure make that into a plugin
    If it is to any help of you I made a ticket about this function at wowace.com.

  4. #4
    Quote Originally Posted by Triemer View Post
    If it is to any help of you I made a ticket about this function at wowace.com.
    Sorry, by "we" I meant me and you. I don't know any of the WA authors, lol

    If you want, see if this plugin works for you...

    http://www.mmo-champion.com/threads/...lve-easy-steps
    (Ignore the code for what should be in your .toc file)

    Interface\AddOns\WeakAuras_MultipleTalentLoad\WeakAuras_MultipleTalentLoad.toc:
    Code:
    ## Interface: 50400
    ## Title: WeakAuras MultipleTalentLoad
    ## Author: pnutbutter
    ## RequiredDeps: WeakAuras
    ## Description: Allows you to choose multiple talents that will cause a region to load
    WeakAuras_MultipleTalentLoad.lua
    Interface\AddOns\WeakAuras_MultipleTalentLoad\WeakAuras_MultipleTalentLoad.lua:
    Code:
    local tinsert,tconcat=table.insert,table.concat
    
    do
        local args=WeakAuras.load_prototype.args
        for i=1,#args do
            if args[i].name=="talent" then
                args[i].type="multiselect"
                break
            end
        end
    end
    
    WeakAuras.ConstructFunction = function(prototype, data, triggernum, subPrefix, subSuffix, field, inverse)
      local trigger;
      if(field == "load") then
        trigger = data.load;
      elseif(field == "untrigger") then
        if(triggernum == 0) then
          data.untrigger = data.untrigger or {};
          trigger = data.untrigger;
        else
          trigger = data.additional_triggers[triggernum].untrigger;
        end
      else
        if(triggernum == 0) then
          trigger = data.trigger;
        else
          trigger = data.additional_triggers[triggernum].trigger;
        end
      end
      local input = {"event"};
      local required = {};
      local tests = {};
      local init;
      if(prototype.init) then
        init = prototype.init(trigger);
      else
        init = "";
      end
      for index, arg in pairs(prototype.args) do
        local enable = true;
        if(type(arg.enable) == "function") then
          enable = arg.enable(trigger);
        end
        if(enable) then
          local name = arg.name;
          if not(arg.name or arg.hidden) then
            tinsert(input, "_");
          else
            if(arg.init == "arg") then
              tinsert(input, name);
            end
            if(arg.hidden or arg.type == "tristate" or arg.type == "toggle" or (arg.type == "multiselect" and trigger["use_"..name] ~= nil) or ((trigger["use_"..name] or arg.required) and trigger[name])) then
              if(arg.init and arg.init ~= "arg") then
                init = init.."local "..name.." = "..arg.init.."\n";
              end
              local number = tonumber(trigger[name]);
              local test;
              if(arg.type == "tristate") then
                if(trigger["use_"..name] == false) then
                  test = "(not "..name..")";
                elseif(trigger["use_"..name]) then
                  if(arg.test) then
                    test = "("..arg.test:format(trigger[name])..")";
                  else
                    test = name;
                  end
                end
              elseif(arg.type == "multiselect") then
                if(trigger["use_"..name] == false) then
                  test = "(";
                  local any = false;
                  for value, _ in pairs(trigger[name].multi) do
                    if not arg.test then
                      test = test..name.."=="..(tonumber(value) or "\""..value.."\"").." or ";
                    else
                      test = test..arg.test:format(tonumber(value) or "\""..value.."\"").." or ";
                    end
                    any = true;
                  end
                  if(any) then
                    test = test:sub(0, -5);
                  else
                    test = "(false";
                  end
                  test = test..")";
                elseif(trigger["use_"..name]) then
                  local value = trigger[name].single;
                  if not arg.test then
                    test = trigger[name].single and "("..name.."=="..(tonumber(value) or "\""..value.."\"")..")";
                  else
                    test = trigger[name].single and "("..arg.test:format(tonumber(value) or "\""..value.."\"")..")";
                  end
                end
              elseif(arg.type == "toggle") then
                if(trigger["use_"..name]) then
                  if(arg.test) then
                    test = "("..arg.test:format(trigger[name])..")";
                  else
                    test = name;
                  end
                end
              elseif(arg.test) then
                test = "("..arg.test:format(trigger[name])..")";
              elseif(arg.type == "longstring" and trigger[name.."_operator"]) then
                if(trigger[name.."_operator"] == "==") then
                  test = "("..name.."==\""..trigger[name].."\")";
                else
                  test = "("..name..":"..trigger[name.."_operator"]:format(trigger[name])..")";
                end
              else
                if(type(trigger[name]) == "table") then
                  trigger[name] = "error";
                end
                -- if arg.type == "number" and (trigger[name]) and not number then trigger[name] = 0 number = 0 end -- fix corrupt data, ticket #366
                test = "("..name..(trigger[name.."_operator"] or "==")..(number or "\""..(trigger[name] or "").."\"")..")";
              end
              if(arg.required) then
                tinsert(required, test);
              else
                tinsert(tests, test);
              end
            end
          end
        end
      end
      local ret = "return function("..tconcat(input, ", ")..")\n";
      ret = ret..(init or "");
      ret = ret.."if(";
      ret = ret..((#required > 0) and tconcat(required, " and ").." and " or "");
      if(inverse) then
        ret = ret.."not ("..(#tests > 0 and tconcat(tests, " and ") or "true")..")";
      else
        ret = ret..(#tests > 0 and tconcat(tests, " and ") or "true");
      end
      ret = ret..") then\nreturn true else return false end end";
      return ret;
    end
    Last edited by pnutbutter; 2014-03-11 at 10:31 PM.

  5. #5
    Deleted
    This...is...awesome! Thank you very very very VERY much.



    If you're alright with it, I'll send this to the WeakAuras2 authors.

  6. #6
    I mean the change is simple enough that they probably would've done it already if they wanted, but go ahead if you think it will encourage them

  7. #7
    Deleted
    Just noticed one small error.
    When you open the load options fo a weakaura that already has a talent filter you'll get a LUA error.
    But simply unchecking the talentfilter and reaplying solves this so nothing major.

    Edit:
    Here is the WeakAura you helped me to complete. So happy right now and want to show it off .
    http://www.mmo-champion.com/threads/...6#post25864126
    Last edited by mmocd849add1f5; 2014-03-12 at 12:42 AM.

  8. #8
    Quote Originally Posted by Triemer View Post
    Just noticed one small error.
    When you open the load options fo a weakaura that already has a talent filter you'll get a LUA error.
    But simply unchecking the talentfilter and reaplying solves this so nothing major.
    You mean ones that you made before you added the new code?

  9. #9
    Deleted
    Quote Originally Posted by pnutbutter View Post
    You mean ones that you made before you added the new code?
    Yeah, just those.

    Edit1:
    Found another bug when I logged in today.
    After I logged in I noticed that it cleared the selected talents in the weakaura.
    I think that's a problem with the way how weakauras saves.

    Edit2:
    In the process of fixing it I tought again about how my WeakAura was designed and I found a stupid mistake.
    I need to check if the Talent is unchecked not if the other two are selscted >.<
    Last edited by mmocd849add1f5; 2014-03-12 at 09:54 PM.

Posting Permissions

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