• 0

    posted a message on API UnitIsFriend
    Depending on what you wanted to do, you could use UnitCanAssist or UnitCanAttack. The former tells if the first unit could heal or buff the second one. The latter tells if the first unit can attack the second one. This allows to handle some corner cases, like really neutral NPCs or players of the other faction in sanctuaries, namely Dalaran, and Shattrath City.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Functions in a local table
    Basically, you should consider that this:

    local f = {}
    
    function f.Dot(name)
    	print(type(name))
    end
    
    function f:Colon()
    	print(self == nil)
    end
    
    f:Dot("Johnny") -- this prints "table"
    f.Colon() -- this prints "true"


    Is strictly complied as this by Lua :

    local f = {}
    
    f.Dot = function(name)
    	print(type(name))
    end
    
    f.Colon = function(self)
    	print(self == nil)
    end
    
    f.Dot(f, "Johnny") -- this prints "table"
    f.Colon() -- this prints "true"


    foo:bar(...) is just a syntactic sugar for foo.bar(foo, ...).
    Posted in: Lua Code Discussion
  • 0

    posted a message on Functions in a local table
    Look at the frame stack of the error.

    Even if the error actually happens in Slider.lua, line 103, it's probably because the code tries to pass a nil value to :SetValue. So where does that value comes from ?

    Moving up in the stack frame, we see that this value is returned by self:GetValue() at line 154 of Control.lua.

    function Portfolio.Control.Update(self)
        self:SetValue(self:GetValue(), false, true)
    end
    


    So, for some reason you have to find if you want to fix the error, this self:GetValue() returns nil.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using exclamation ! on .pkgmeta
    Quote from Phanx
    Another problem with hard-embedding addons (other than the many problems already described) is that this will confuse the Curse Client -- it will try to update the addon both as a standalone addon, and as a file included in your addon. This could lead to infinite loops (where the dependency is always marked as needing an update), the user getting wrong versions (for example, the user has chosen to receive alpha versions, but you're pulling in only release versions, or vice versa), and who knows what else.


    I second this. Hard-embedding another addon usually causes havoc when using the Curse client.
    Posted in: General Chat
  • 0

    posted a message on Using exclamation ! on .pkgmeta
    Ok, so as Phanx said, you should not embed another addon this way. You have to specify it has a required dependency, in .pkgmeta for the Curse client and in the TOC file for WoW itself. Moreover, WoW ensures the dependencies of an addon are loaded before the addon itself.

    And for the "!", try quote the whole string (this should work with base YAML, I don't know how the curse packager handles it) :

    externals:
        "Details/plugins/!NickTag":
            url: http://hg.curseforge.net/wow/nicktag/mainline
    move-folders:   
        "Details/plugins/!NickTag": "!NickTag"


    However, given how you describe it, !Nicktag looks more like a standalone addon with a public API, allowing other addon to use it, than a library. It is quite similar to addons like Masque or BigWigs.
    Posted in: General Chat
  • 0

    posted a message on Good way to catch endless loops lockups?
    Your OnEnter handler looks like this :

            OnEnter = function(self)
                -- snip
                local line
                for i = 1, #npcs do
                    -- Some code that should initialize line
                    -- snip
                end
    
                if not line then
                    self:GetScript("OnLeave")(self)
                    return self:GetScript("OnEnter")(self)
                end
                -- snip
            end


    What happens if your for loop never initializes line ?

    By the way, what are you trying to do by calling OnLeave/OnEnter again ?

    Wouldn't this be better ? http://www.wowace.com/paste/8389/

    No risk of infinite recursion.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Good way to catch endless loops lockups?
    Seriously, you should find a way to avoid self:GetScript('OnLeave')(self). That's just calling for troubles and possibly infinite recursion, given that you sometimes do this as a tail call.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Good way to catch endless loops lockups?
    Quote from Lombra
    Finally, I'm not entirely sure of the LDB specs, but I don't think that using GetScript on LDB objects is guaranteed to yield the expected result. It may very well be that all display addons happens to do it that way anyway, but something to keep in mind.


    IIRC the OnXXX handlers of LDB actually receive the display frame (created by the LDB display addon) as the first argument, not the LDB object itself. The first argument should be named "frame" instead of "self" for the sake of clarity.

    However, I'm not sure every LDB display handles these the same way, so they are chance this could fail with some of them.
    Posted in: Lua Code Discussion
  • 0

    posted a message on InterfaceOptionsFrame_OpenToCategory fix ?
    I forgot BlizzBugsSuck. Thanks for pointing it out. That's why I started this thread in the first place: I was wondering if anyone would have fixed this common issue.

    Edit: BlizzBugsSuck actually fixes InterfaceOptionsFrame_OpenToCategory. Thanks again.
    Posted in: Addon Ideas
  • 0

    posted a message on InterfaceOptionsFrame_OpenToCategory fix ?
    Yeah. That's more or less the solution I have found:

    http://www.wowace.com/paste/8364/

    (This can be shortened by ignoring any possible upgrades.)

    I'm thinking about releasing this snippet of code as an addon, that can also be embedded in another addon.
    Posted in: Addon Ideas
  • 0

    posted a message on InterfaceOptionsFrame_OpenToCategory fix ?
    Thanks.

    However it seems it fixed an old issue, which is different from the current one.
    Posted in: Addon Ideas
  • 0

    posted a message on InterfaceOptionsFrame_OpenToCategory fix ?
    Hello,

    I thought there once was an addon which fixed the InterfaceOptionsFrame_OpenToCategory issue (e.g. it doesn't open to the right panel the first time you call it, because of a bug in Blizzard code) but I could not find it. I have found this but the addon does not exist anymore.

    Does anyone have a copy of this addon ?
    Posted in: Addon Ideas
  • 0

    posted a message on Broker plugin for oQueue
    He's probably referring to LibDataBroker. Even if you have no data to display, you can create a launcher, as indicated there. Optionally, you can easily show this launcher as a minimap icon by using LibDBIcon for those that doesn't use any LDB display.
    Posted in: Addon Ideas
  • 0

    posted a message on UnitName with foreign names
    For additional fonts, take a look at LibSharedMedia-3.0. This library allows you to select a font amongst several ones. Some of them are shipped with the game client so they are always available. The library provides a list of available fonts, automatically listing russian and asian fonts whenever they are available. With AceGUI-3.0-SharedMediaWidgets, you can easily add a nice font selection widget to your AceConfig panels.

    For string formating, nothing more is necessary.

    If you plan to use pattern matching (strmatch, string.match, string.find, string.gsub, ...), be aware the following character classes only known "pure" ASCII letters : %a (all letters), %l (lowercase letters), %u (uppercase letters) and %w (alphanumeric characters).
    Posted in: Lua Code Discussion
  • 0

    posted a message on Progress bar
    LibCandyBar-3.0 doesn't anchor the bar for you. You have to use mybar:SetPoint() and possibly mybar:Show().
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.