• 0

    posted a message on X-Perl Thread
    Error occured in: Global
    Count: 1
    Message: ...terface\AddOns\XPerl_RaidHelper\XPerl_RaidHelper.lua line 438:
    attempt to index upvalue 'conf' (a nil value)
    Debug:
    (tail call): ?
    [C]: ?
    ...terface\AddOns\XPerl_RaidHelper\XPerl_RaidHelper.lua:438: XPerl_MTRosterChanged()
    ...terface\AddOns\XPerl_RaidHelper\XPerl_RaidHelper.lua:724: XPerl_EnableDisable()
    ...terface\AddOns\XPerl_RaidHelper\XPerl_RaidHelper.lua:687:
    ...terface\AddOns\XPerl_RaidHelper\XPerl_RaidHelper.lua:685

    Get this almost constantly with r365. Same problem with the current released version. Sometimes a /reloadui fixes it sometimes not.
    Posted in: Unit Frames
  • 0

    posted a message on PTR FrameXML source?
    Thanks for the speedy reply, but forgive the next obvious question: where does wowcompares.com get it? The current code broke only a few hours ago so I am guessing something has changed and I'd like to know how I can get at the FrameXML code at any time for any new version, not wait for another site.
    Posted in: Lua Code Discussion
  • 0

    posted a message on PTR FrameXML source?
    Where do I find the PTR FrameXML source code? I am experiencing a new error in UIPanelTemplates.lua:20: PanelTemplates_UpdateTabs() that I wasn't before today's build and I want to check things out. Thanks in advance.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Event recorder?
    Thank you very much indeed.
    Posted in: AddOn HELP!
  • 0

    posted a message on Event recorder?
    Is there any way I can record all events fired? Obviously the ideal way would be if the game client had a command line option that did this but I think thats wishful thinking. Alternatively, does anyone know a mod that I can use where I can start/stop event recording? Any help at all greatly appreciated.
    Posted in: AddOn HELP!
  • 0

    posted a message on Variable arguments: what am I doing wrong?
    Quote from Tekkub

    Wasted function call. `local first = ...`

    ...

    Also you might want to un-nest the color table extract, in case you want to pass colors but not a frame.

    ...

    To be frank, while this is all fun and great, I would just make functions for each case you need. Or just use the existing print() already, it works quite well. I have a single, simple print I use in my addons, tailored for the specific addon's name:

    local function Print(...) print("|cFF33FF99Addon Name|r:", ...) end

    I've never needed anything more.


    Actually I don't need to un-nest the color table extract, it will work as is, albeit with one wasted select(). And as for using a simpler version or making 3 functions, I guess I could do that. I'm still learning Lua and WoW though and writing utility functions like this is a pretty good way (for me) to learn things. Maybe I'm at the top of my exponential decay graph of learning and will settle towards the median soon enough, but for now I'm having fun :)
    Posted in: Lua Code Discussion
  • 0

    posted a message on Variable arguments: what am I doing wrong?
    Even without an actual shift() function, given some of the replies I am having a hard time seeing why my original example didn't work. Although the solution originally posted by Tekkub works fine if I just take a frame as an optional first argument, I wanted to extend it to take two optional first arguments, a frame and a table of colors. So I ultimately wanted to have something along the lines of:

    function printf(...)
      local first = select(1, ...)
      local frame = DEFAULT_CHAT_FRAME
      local i = 1
      local r,g,b = nil, nil, nil
    
      if type(first) == "table" then
        if first.AddMessage then
          frame = first
          i = i + 1
        end
    
        local c = select(i, ...)
        if type(c) == "table" and c.r and c.g and c.b then
          r,g,b = c.r, c.g, c.b
          i = i + 1
        end
      end
    
      frame.AddMessage(string.format(select(i, ...)), r, g, b)
    end


    And lo and behold, it actually worked. The original example I gave would have worked too except I had made a dumb mistake. That function was actually part of a library, and I had declared it as:
    function K:printf(...)


    and then in my addon I had
    local printf = K.printf
    and was then just calling printf(whatever) in my addon. I got caught by that damned : versus . thingy. When I changed the function declaration to be
    function K.printf(...)
    all of a sudden everything worked. I'm really gonna have to watch that whole : thingy.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Variable arguments: what am I doing wrong?
    That's elegant enough, thanks :) I do have a generalized form of the question though. Is there any elegant way in Lua to do the equivalent of shell script's "shift" function? That is, remove just the first element from the argument list (or n elements if an argument is given, as in shift 5)?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Variable arguments: what am I doing wrong?
    function printf(...)
      local frame = select(1, ...)
      local i
    
      if (type(frame) == "table" and frame.AddMessage) then
        i = 2
      else
        i = 1
        frame = DEFAULT_CHAT_FRAME
      end
    
      frame:AddMessage(string.format(select(i, ...)))
    end


    The intent should be obvious, but its not working. What am I doing wrong? The Lua manual says:
    select (index, ···)

    If index is a number, returns all arguments after argument number index. Otherwise, index must be the string "#", and select returns the total number of extra arguments it received.

    Does that mean the argument to select should really be i-1?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Possible AceDB-3.0 error?
    Thanks ... as I said in the original post I suspected it was something odd to do with self. Its kind of a neat feature. Glad its not a bug :)
    Posted in: Ace3
  • 0

    posted a message on Possible AceDB-3.0 error?
    I've been pouring over all things Ace recently to see how you guys do things and I've come across something in AceDB I do not understand.

    There is a function:
    function DBObjectLib:DeleteProfile(name, silent)

    The function is recursive, in that it calls itself but when it does so it calls it as:
    DBObjectLib.DeleteProfile(db, name, true)


    Note the extra first parameter. I know Lua has some weirdness going on with the first argument to a function, but I thought that had to do with "self" - that you could explicitly reference self as a parameter, or not. Something like that. Perhaps this works as intended but it sure looks wrong to me.

    The same thing exists for DBObjectLib:CopyProfile.

    Next, the function:
    function DBObjectLib:ResetProfile(noChildren)

    looks like its expecting to take a boolean argument that indicated it has no children. Certainly, the value noChildren is used in the function body that way. But in teh function body it also calls itself with:
    for _, db in pairs(self.children) do
      DBObjectLib.ResetProfile(db)
    end


    Thus it looks like this function should be taking a db as its first arg, and the boolean as its second.

    If I am missing some trickery I appologise for wasting your time.
    Posted in: Ace3
  • 0

    posted a message on New dev tool - Addon Studio for World of Warcraft
    Quote from jokeyrhyme
    This is interesting, but not all of us use VisualStudio. I tend to use Eclipse (with a few plugins) just because it has SVN, syntax highlighting and doesn't look too ugly, and it's cheap.


    FWIW, VisualStudio has SVN too, and syntax highlighting (in fact, as much as I hate to admit it, M$ was one of the first people to offer chroma-coding in their IDE), and IIRC WoW addon studio comes with either the free visual studio express version, or can use it.

    Having said all that I am not a fan of WoW addon studio at all. ViM all the way for me. Does all the syntax coloring you can shake a stick at, auto-indenting, and there's plenty of macros for SVN support, although I don't use any of them and just drive the svn command line client myself.
    Posted in: Frameworks
  • 0

    posted a message on Why not integer events?
    Thanks for all the responses. I had a funny feeling LUA would turn out to surprise me. Every time I've thought "wouldn't it be better if ...." it turns out lua already does it, or does it better. In another life I am working on a process-control system that requires "recipes" for knowing when to turn things on and off. I think I may just have to look at embedding LUA as the recipe language :)
    Posted in: Lua Code Discussion
  • 0

    posted a message on Why not integer events?
    I've been writing my own UI mod over the last few months, and there's something that's been sticking in the back of my mind for a while. I didn't fully realize what it was till this evening, so I figured I'd ask the question before it slipped my mind again. My appologies in advance if this is a dumb question.

    It occurred to me when I was writing an OnEvent handler that had to check 3 or 4 events. The problem is the event names are all strings. That means every time an event fires, and there is a handler to catch it, at some point, there is going to be the moral equivalent of a strcmp(). Back when I worked for your favourite search engine company, I remember some research that was done to measure, across a large data center and several large applications, what the CPU spent most of its time doing. Very high up on that list (outside of obvious tight loops) were strcmp() and memcpy(). The former for all the obvious reasons, and the second because of how structure copies are implemented by the compiler. strcmp() is a pretty expensive operation (for a number of reasons).

    Almost every other event driven system I've ever used (ok, its only 3) used enumerated integers for the event names. This is particularly useful when in C, for example, you have a large case statement checking for a given event. The compiler can convert that into an efficient jump table if there are sufficient case clauses to warrant it. Even if not, its a simple sequence if integral compares. It occurs to me that WoW would benefit from a measurable speedup if it was to do the same. A sequence of:

      if (event == EVT_PLAYER_ENTERED_WORLD) then
        ..
      elseif (event == EVT_PLAYER_LOGIN) then
       ...
      elseif (event == EVT_SOME_OTHER_THING) then
        ...
      end
    


    would be drastically more efficient than:
      if (event == "PLAYER_ENTERED_WORLD") then
        ..
      elseif (event == "PLAYER_LOGIN") then
       ...
      elseif (event == "SOME_OTHER_THING") then
        ...
      end
    


    The only way using strings could even be somewhat mitigated was if the LUA interpreter was somehow clever enough to figure what was going on, use some form of secure hash on the incoming event string, and internally convert all those other string constants to a numeric value which it then compares. Maybe LUA is that clever, and if so I am sure some of the LUA-heads will be happy to point out that it is.

    If not, however, it would be worth suggesting to Blizzard that they consider converting event names to integers. This would, I realize, be a huge change, and thus make them leary of doing so, but for people on slower computers, believe me, eliminating a bunch of strcmp() equivalents a couple of times a second really adds up.

    They could easy publish a list of event names to integer mappings, and modules could then do something like:

      local PLAYER_ENTERING_WORLD = 1234
      local PLAYER_LOGIN = 1235
    
      if (event == PLAYER_ENTERING_WORLD) then
       ...
      end
    


    and so on and so forth.

    Just a thought. Thanks for your time.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Possible AceComm3.0 error?
    Right I meant block not loop, I can see its just a do..end :) Force of habit.
    Posted in: Ace3
  • To post a comment, please or register a new account.