• 0

    posted a message on Anchoring to certain interface elements not possible?
    Thanks for that suggestion Dridzt, it certainly looks more elegant than my sleepyly coded attempt.
    I still wonder why anchoring doesn't work right, but whatever, it wasn't that important anyway.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Anchoring to certain interface elements not possible?
    Yeah, as I mentioned in my reply, I wouldn't know why anchoring like that would be a problem.
    And, as I said as well, the global name isn't used by anything else. Though I probably will prefix it with something unique.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Anchoring to certain interface elements not possible?
    @Farmbuyer:
    Thanks for your post and yeah, I should have mentioned that the button doesn't even show up if I try to anchor it to the save or cancel button. Must have slipped my mind, I was kinda sleepy already at the time of posting...
    In response to the other points:
    (1) The name MacroRunButton isn't used by anything else, neither default interface nor addon, and as it's for private use only atm I didn't bother with a unique name for it. Perhaps I really should change it...
    (2) The relative positioning for the save button is the same as it's by default except for a few more pixels distance. That's why I used the cancel button as an anchor. I'll try and see if chaining them would help, though it would surprise me... Why wouldn't you be able to anchor two interface elements to one and the same anchor?

    As for your suggestion, certainly not a bad idea. I'l probably do that later.

    @Graveeater:
    a) It really doesn't matter if you use the reference or name, it didn't matter for my problem.
    b) As I don't want to use it in Combat it didn't matter until now, I'll have to test if that's a problem later.
    c) Left click only ;-)
    d) Yeah, the code above was just a really fast writeup, so stuff like that wasn't really of high priority. But I'll certainly change it.
    e) High is the same framestrata as the other buttons use afaik, though for future proofing the change certainly wouldn't be bad.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Anchoring to certain interface elements not possible?
    Hey guys.

    I wrote a little addon for myself that adds a button to the macro UI that allows you to run the selected macro, without putting it on your bars or having a keybind for it. With certain macros that I'm using that feature just seemed handy.

    Anyway, while doing that I encountered a little problem:
    I wanted to position the Run button between the Save and Cancel buttons, so I moved them a few more pixels apart and tried to anchor the new button to one of the two. As you can guess from the title it didn't work.
    For now, I'm positioning the button where I want it by using the whole MacroFrame as point of reference.

    Here's my code for you to review and perhaps you can tell me why anchoring the button didn't work:
    local f = CreateFrame("Frame")
    local function CreateRunButton()
    		MacroCancelButton:ClearAllPoints()
    		MacroCancelButton:SetPoint("BOTTOMRIGHT", "MacroFrameScrollFrame", "TOPRIGHT", 25, 6)
    		MacroSaveButton:ClearAllPoints()
    		MacroSaveButton:SetPoint("BOTTOM", "MacroCancelButton", "TOP", 0, 23)
    		local btn = CreateFrame("Button", "MacroRunButton", MacroFrame, "UIPanelButtonTemplate, SecureActionButtonTemplate")
    		btn:SetText("Run")
    		btn:SetSize(80, 22)
    		--btn:SetPoint("BOTTOM", "MacroCancelButton", "TOP", 0, 2) --TODO: find out why this doesn't work
    		btn:SetPoint("RIGHT", "MacroFrame", "RIGHT", -11, -43)
    		btn:SetFrameStrata("HIGH")
    		btn:SetAttribute("type1", "macro")
    		btn:SetAttribute("macro", -1)
    		for i = 1, 36 do
    			_G["MacroButton"..i]:HookScript("OnClick", function(self) btn:SetAttribute("macro",MacroFrame.selectedMacro) end)
    		end
    		f:UnregisterEvent("ADDON_LOADED")
    end
    if not IsAddOnLoaded("Blizzard_MacroUI") then
    	f:RegisterEvent("ADDON_LOADED")
    	f:SetScript("OnEvent", function(self, event, addon)
    		if addon == "Blizzard_MacroUI" then
    			CreateRunButton()
    		end
    	end)
    else
    	CreateRunButton()
    end


    Thanks in advance!
    Posted in: Lua Code Discussion
  • 0

    posted a message on LearningAid: table.sort called with invalid parameters
    Thanks for clearing that up Xinhuan, Dridzt comment
    Quote from Dridzt
    Because it is an invalid sort function.

    had me confused, because the sort function itself seemed fine. Nevertheless, I think we can leave this thread for good, everything should be cleared up by now. :D
    Posted in: AddOn HELP!
  • 0

    posted a message on LearningAid: table.sort called with invalid parameters
    Ok, following the definition, let's try this example in Lua:
    > t = {{key="Divine Guardian",value="Divine Guardian Spelllink"},{key="Blessing of Might",value="BoM Spelllink"},{key="Blessing of Kings",value="BoK Spelllink"}}
    No output
    > for k,v in ipairs(t) do print(k..": key="..v.key..", value="..v.value) end
    1: key=Divine Guardian, value=Divine Guardian Spelllink
    2: key=Blessing of Might, value=BoM Spelllink
    3: key=Blessing of Kings, value=BoK Spelllink
    > comp = function(a,b) return a.key < b.key end
    No output
    > table.sort(t,comp)
    No output
    > for k,v in ipairs(t) do print(k..": key="..v.key..", value="..v.value) end
    1: key=Blessing of Kings, value=BoK Spelllink
    2: key=Blessing of Might, value=BoM Spelllink
    3: key=Divine Guardian, value=Divine Guardian Spelllink
    > print(not comp(t[2],t[1]))
    true


    According to the definition, a valid sort function is one that "sorts table elements in a given order, /in-place/, from |table[1]| to |table[n]|, where |n| is the length of the table. If |comp| is given, then it must be a function that receives two table elements, and returns true when the first is less than the second (so that |not comp(a[i+1],a[i])| will be true after the sort)."
    Which is exactly what's happening in the above example. So why is the sort function from this line
    table.sort(t, function(a, b) return a.key < b.key end)

    not valid?
    Posted in: AddOn HELP!
  • 0

    posted a message on LearningAid: table.sort called with invalid parameters
    Thank you very much, however there's still one little question I have.
    Was it really the sort function that was invalid, or rather that the table supplied and the used function weren't compatible?
    If so, what exactly is wrong with the sort function? It's returning true if the key-value, the name of the spell, is less than the second one, as it's supposed to do, right? But I'm eager to learn, so feel free to tell me.
    Posted in: AddOn HELP!
  • 0

    posted a message on LearningAid: table.sort called with invalid parameters
    Hey guys.
    Although I already posted a ticket on this matter over at the projects site, I'd still like to ask the whole community if anyone knows how to solve this.

    What's happening is the following:
    when I change my spec on certain characters (my Pally and Rouge, however not on my warry or my DK) using standard settings on a completely clean interface with only LearningAid installed and no preexisting SVs, I receive the following error:
    1x LearningAid-40000\LearningAid.lua:637 attempt to index local 'b' (a nil value)
    <in C code>: in function `sort'
    LearningAid-40000\LearningAid.lua:637 in function <LearningAid\LearningAid.lua:635
    LearningAid-40000\LearningAid.lua:895 in function `?'
    LearningAid-40000\LearningAid.lua:565 in function `?'
    CallbackHandler-1.0-6 (Ace3):147: in function <...Ons\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:147
    <string>:"safecall Dispatcher[6]":4: in function <[string "safecall Dispatcher[6]"]:4>
    <in C code>: ?
    <string>:"safecall Dispatcher[6]":13: in function `?'
    CallbackHandler-1.0-6 (Ace3):92: in function `Fire'
    AceEvent-3.0-3 (Ace3):120: in function <Ace3\AceEvent-3.0\AceEvent-3.0.lua:119


    These are the corresponding code lines:
    --[[ FormatSpells(t)
      t = {
        { key = "spell used as sort key", value = <spell link or spell name and rank, doesn't matter> },
        { more of the same},
        { etc}
      }
    --]]
    local function formatSpells(t)
      if #t > 0 then
        table.sort(t, function(a, b) return a.key < b.key end)
        local str = ""
        for i = 1, #t - 1 do 
          str = str..t[i].value
          str = str..", "
        end
        str = str..t[#t].value
        return str
      end
    end
    


    The function itself seems to be perfectly in order, the table aswell, and trying the above piece of code ingame with a sample table works perfectly.
    Additionally, how could the sort function possibly be called, if there aren't enough elements inside the table, resulting in trying to index a non existant value?

    Thanks in advance and if you want to know anything else just let me know.
    Posted in: AddOn HELP!
  • 0

    posted a message on UlduarAutoPilot
    It's nice of you to release this Addon with some localizations, but if you set every single one of them to be the default language, then only the first one loaded (according to the .toc-file, in this case enUS) will be used ingame, regardless of the real locale.

    To fix this, just change
    local L = LibStub('AceLocale-3.0'):NewLocale('UlduarAutoPilot', 'xxXX', true)

    to
    local L = LibStub('AceLocale-3.0'):NewLocale('UlduarAutoPilot', 'xxXX', false)
    if not L then return end

    in every locale file except the enUS one.
    Thus the really needed locale will be used and if no translation is available for that locale, enUS will be used.

    Greetz Asteague
    Posted in: General AddOns
  • To post a comment, please or register a new account.