• 0

    posted a message on Hooking MultilineEditBox to ForAllIndentsAndPurposes
    From editor-core

    IndentationLib:enable(sequencebox.editBox, SyntaxColors, TAB_WIDTH) <-- is exactly how WeakAuras hook this function.

    function GSSE:drawstandardwindow(container)
      local sequencebox = AceGUI:Create("MultiLineEditBox")
      sequencebox:SetLabel("Sequence")
      sequencebox:SetNumLines(20)
      sequencebox:DisableButton(true)
      sequencebox:SetFullWidth(true)
      sequencebox:SetText(sequenceboxtext:GetText())
    --  sequencebox.editBox:SetMaxBytes(0)
    --  sequencebox.editBox:SetMaxLetters(0)
      --[B]IndentationLib:enable(sequencebox.editBox, SyntaxColors, TAB_WIDTH)[/B]
      container:AddChild(sequencebox)
    
      local updbutton = AceGUI:Create("Button")
      updbutton:SetText("Create / Edit")
      updbutton:SetWidth(200)
      updbutton:SetCallback("OnClick", function() GSSE:updateSequence(currentSequence) end)
      container:AddChild(updbutton)
      sequenceboxtext = sequencebox
    end



    Enable function on FAIAP
        function lib.enable(editbox, colorTable, tabWidth)
            if not editboxSetText then
                editboxSetText = editbox.SetText
                editboxGetText = editbox.GetText
            end
    
            local modified
            if editbox.faiap_colorTable ~= colorTable then
                editbox.faiap_colorTable = colorTable
                modified = true
            end
            if editbox.faiap_tabWidth ~= tabWidth then
                editbox.faiap_tabWidth = tabWidth
                modified = true
            end
    
            if enabled[editbox] then
                if modified then
                    lib.indentEditbox(editbox)
                end
                return
            end
    
            -- Editbox is possibly hooked, but disabled
            enabled[editbox] = true
    
            editbox.oldMaxBytes = editbox:GetMaxBytes() -- Fails with a nil here on GetMaxBytes()
            editbox.oldMaxLetters = editbox:GetMaxLetters() -- Fails with a nil here on GetMaxLetters()
            editbox:SetMaxBytes(0) -- Fails with a nil here on SetMaxBytes()
            editbox:SetMaxLetters(0) -- Fails with a nil here on SetMaxLetters()
    
            editbox.GetText = newGetText
            editbox.SetText = newSetText
    
            hookHandler(editbox, "OnTextChanged", textChangedHook) -- These hook lines also fail with enclosed methods being nil
            hookHandler(editbox, "OnTabPressed", tabPressedHook)
            hookHandler(editbox, "OnUpdate", onUpdateHook)
    
            lib.indentEditbox(editbox)
        end


    Now this works for every other application and example I can find. WeakAuras 2 uses this in their ACEGUI addon. I and they are running the same Ace Versions and FAIAP versions.
    Posted in: Ace3
  • 0

    posted a message on Hooking MultilineEditBox to ForAllIndentsAndPurposes
    Hi All,

    I have been trying to link an Ace multilineeditbox to ForAllIndentsAndPurposes.
    That Link is done by passing the editbox into FAIAP and then FAIAP adds itself to some of the text boxes methods. WeakAuras has done this so I know it can be done.

    WeakAuras loads FAIAP after the WOWACE libs and then calls
    IndentationLib:enable(premacrobox.editBox, nil, 2)

    I'm trying the same thing and I get the below stack trace.

    If I call premacrobox.editBox:GetMaxBytes() I get a value back. I can also call SetMaxBytes but once the object is passed for FAIAP all the methods become nil.

    Message: ...quenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:1171: attempt to call method 'GetMaxBytes' (a nil value)
    Time: 08/09/16 17:24:38
    Count: 1
    Stack: ...quenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:1171: in function `enable'
    Interface\AddOns\GS-SequenceEditor\editor-core.lua:209: in main chunk
    
    Locals: editbox = <table> {
     colorCodeEditbox = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:999
     stripWowColors = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:895
     encode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:960
     faiap_tabWidth = <table> {
     }
     tokenIndentation = <table> {
     }
     tokens = <table> {
     }
     indentCode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:662
     decode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:952
     enable = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:1145
     linebreakCharacters = <table> {
     }
     revision = 19
     padWithLinebreaks = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:977
     stripWowColorsWithPos = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:967
     addSmartCode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:1145
     keywords = <table> {
     }
     faiap_colorTable = MultiLineEditBox4Edit {
     }
     colorCodeCode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:556
     stringdelete = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:60
     stringinsert = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:55
     indentEditbox = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:1043
     specialCharacters = <table> {
     }
     whitespaceCharacters = <table> {
     }
     defaultColorTable = <table> {
     }
     bytes = <table> {
     }
     disable = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:1189
    }
    colorTable = MultiLineEditBox4Edit {
     0 = <userdata>
     obj = <table> {
     }
    }
    tabWidth = <table> {
     1 = ""
     0 = ""
     string = ""
     tostring = ""
     print = ""
     8 = ""
     10 = ""
     unpack = ""
     gsub = ""
     format = ""
     20 = ""
     24 = ""
     strconcat = ""
     32 = ""
     pairs = ""
     next = ""
     max = ""
     assert = ""
     tonumber = ""
     tostringall = ""
     33 = ""
     wipe = ""
     strtrim = ""
     21 = ""
     tinsert = ""
     sort = ""
     coroutine = ""
     tremove = ""
     strmatch = ""
     strsub = ""
     strsplit = ""
     strrev = ""
     strrep = ""
     strlower = ""
     9 = ""
     11 = ""
     strchar = ""
     math = ""
     strjoin = ""
     pcall = ""
     abs = ""
     strbyte = ""
     type = ""
     strupper = ""
     floor = ""
     select = ""
     ceil = ""
     strfind = ""
     table = ""
     min = ""
     5 = ""
     bit = ""
     22 = ""
     23 = ""
     12 = ""
     error = ""
     ipairs = ""
    }
    modified = true
    (*temporary) = nil
    (*temporary) = <table> {
     colorCodeEditbox = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:999
     stripWowColors = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:895
     encode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:960
     faiap_tabWidth = <table> {
     }
     tokenIndentation = <table> {
     }
     tokens = <table> {
     }
     indentCode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:662
     decode = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\ForAllIndentsAndPurposes\indent.lua:952
     enable = <function> defined @Interface\AddOns\GS-SequenceEditor\lib\Fo
    Posted in: Ace3
  • 0

    posted a message on ACEConfig - Color Picker
    I did a /dump GSGetColour(GSMasterOptions.TitleColour) Its returning three values not a hex value.

    Dump: value=GSGetColour(GSMasterOptions.TitleColour)
    [1]=255,
    [2]=21,
    [3]=115


    Edit: Thanks Phanx and Nevcairiel. I didnt realise i needed to divide the number by 255.

    return tonumber("0x".. string.sub(option,5,6))/255, tonumber("0x"..string.sub(option,7,8))/255, tonumber("0x"..string.sub(option,9,10))/255
    Posted in: Ace3
  • 0

    posted a message on ACEConfig - Color Picker
    Hi All,

    I am using the color picker with AceConfig. While it changes the picker changes to white after setting a color.



    The purply GS-Core is the Title Colour after changing from Red.

    TitleColour is store like "|cFF112233"

    function GSGetColour(option)
      hex = string.gsub(option, "#","")
      return tonumber("0x".. string.sub(hex,5,6)), tonumber("0x"..string.sub(hex,7,8)), tonumber("0x"..string.sub(hex,9,10))
    end
    
            titleColour = {
        			type = "color",
        			name = "Title Colour",
        			desc = "Picks a Custom Colour for the Mod Names.",
              order = 101,
        			hasAlpha = false,
        			get = function(info) return GSGetColour(GSMasterOptions.TitleColour) end,
        			set = function(info, r, g, b, a)
                GSMasterOptions.TitleColour = string.format("|c%02x%02x%02x%02x", 255 , r*255, g * 255, b*255)
              end,
        		},
    Posted in: Ace3
  • 0

    posted a message on ACEGUI Tabs
    I am missing something fundamental. I apologise in advance for asking what has already been asked but my question is how can I reference a widget within a Tab Control when I have to keep recreating the widget every time I swap tabs.

    This is a chunk of my code. I have two frames that swap between edit mode and view mode. In the editor I tried to add a tab control so that i can have tab one for current language and tab 2 for a second language.

    The problem for me is in GSSE:SelectGroup(container, event, group). If I define the widgets outside functions then I can call them and adjust them (Widget:SetText()) but when I add them to a tab control unless I release (After which I cant access them locally) them I got tab windows stacking vertically down the page. For example from the below I can access nameeditbox:SetText("Stuff") from the callback from changing the drop down list.

    Can I reference the tabs widgets via something like Container.Widget:SetText()?

    Again apologies if this is something that I should just know or get. I'm trying to work backwards and figure things out.

    --------------------

    local sequenceboxtext = AceGUI:Create("MultiLineEditBox")
    local remotesequenceboxtext = AceGUI:Create("MultiLineEditBox")
    
    function GSSE:drawstandardwindow(container)
      local sequencebox = AceGUI:Create("MultiLineEditBox")
      sequencebox:SetLabel("Sequence")
      sequencebox:SetNumLines(20)
      sequencebox:DisableButton(true)
      sequencebox:SetFullWidth(true)
      sequencebox:SetText(sequenceboxtext:GetText())
      container:AddChild(sequencebox)
    
      local updbutton = AceGUI:Create("Button")
      updbutton:SetText("Edit")
      updbutton:SetWidth(200)
      updbutton:SetCallback("OnClick", function() GSSE:updateSequence(currentSequence) end)
      container:AddChild(updbutton)
      sequenceboxtext = sequencebox
    end
    
    function GSSE:drawsecondarywindow(container)
      local languages = GSTRListCachedLanguages()
      local listbox = AceGUI:Create("Dropdown")
      listbox:SetLabel("Choose Language")
      listbox:SetWidth(250)
      listbox:SetList(languages)
      listbox:SetCallback("OnValueChanged", function (obj,event,key) GSSE:loadTranslatedSequence(GSTRListCachedLanguages()[key]) end)
      container:AddChild(listbox)
    
      local remotesequencebox = AceGUI:Create("MultiLineEditBox")
      remotesequencebox:SetLabel("Translated Sequence")
      remotesequencebox:SetText(remotesequenceboxtext:GetText())
      remotesequencebox:SetNumLines(20)
      remotesequencebox:DisableButton(true)
      remotesequencebox:SetFullWidth(true)
      container:AddChild(remotesequencebox)
      remotesequenceboxtext = remotesequencebox
    
    end
    
    -- Callback function for OnGroupSelected
    function GSSE:SelectGroup(container, event, group)
       local tremote = remotesequenceboxtext:GetText()
       local tlocal = sequenceboxtext:GetText()
       container:ReleaseChildren()
       GSPrintDebugMessage("Selecting tab: " .. group, GNOME)
       if group == "localtab" then
          GSSE:drawstandardwindow(container)
       elseif group == "remotetab" then
          GSSE:drawsecondarywindow(container)
       end
       remotesequenceboxtext:SetText(tremote)
       sequenceboxtext:SetText(tlocal)
    end
    -- function that draws the widgets for the first tab
    
    
    local frame = AceGUI:Create("Frame")
    local curentSequence
    frame:SetTitle("Sequence Viewer")
    frame:SetStatusText("Gnome Sequencer: Sequence Viewer")
    frame:SetCallback("OnClose", function(widget) frame:Hide() end)
    frame:SetLayout("List")
    
    local names = GSSE:getSequenceNames()
    local listbox = AceGUI:Create("Dropdown")
    listbox:SetLabel("Load Sequence")
    listbox:SetWidth(250)
    listbox:SetList(names)
    listbox:SetCallback("OnValueChanged", function (obj,event,key) GSSE:loadSequence(key) currentSequence = key end)
    frame:AddChild(listbox)
    
    
    
    if GSTranslatorAvailable and GSMasterOptions.useTranslator then
      local tab =  AceGUI:Create("TabGroup")
      tab:SetLayout("Flow")
      -- Setup which tabs to show
      tab:SetTabs({{text=GetLocale(), value="localtab"}, {text="Translate to", value="remotetab"}})
      -- Register callback
      tab:SetCallback("OnGroupSelected",  function (container, event, group) GSSE:SelectGroup(container, event, group) end)
      -- Set initial Tab (this will fire the OnGroupSelected callback)
      tab:SelectTab("localtab")
      tab:SetFullWidth(true)
      -- add to the frame container
      frame:AddChild(tab)
    else
      GSSE:drawstandardwindow(frame)
    end
    
    -------------end viewer-------------
    -------------begin editor--------------------
    local editframe = AceGUI:Create("Frame")
    local stepvalue
    
    local headerGroup = AceGUI:Create("SimpleGroup")
    headerGroup:SetFullWidth(true)
    headerGroup:SetLayout("Flow")
    
    local firstheadercolumn = AceGUI:Create("SimpleGroup")
    --firstheadercolumn:SetFullWidth(true)
    firstheadercolumn:SetLayout("List")
    
    editframe:SetTitle("Sequence Editor")
    editframe:SetStatusText("Gnome Sequencer: Sequence Editor. Press the Close button to Save -->")
    editframe:SetCallback("OnClose", function() GSSE:eupdateSequence(currentSequence, GSSequenceEditorLoaded) end)
    editframe:SetLayout("List")
    
    local nameeditbox = AceGUI:Create("EditBox")
    nameeditbox:SetLabel("Sequence Name")
    nameeditbox:SetWidth(250)
    firstheadercolumn:AddChild(nameeditbox)
    
    local stepdropdown = AceGUI:Create("Dropdown")
    stepdropdown:SetLabel("Step Function")
    stepdropdown:SetWidth(250)
    stepdropdown:SetList({
      ["1"] = "Sequential (1 2 3 4)",
      ["2"] = "Priority List (1 12 123 1234)",
    
    })
    
    stepdropdown:SetCallback("OnValueChanged", function (obj,event,key) stepvalue = key end)
    firstheadercolumn:AddChild(stepdropdown)
    
    local specClassGroup = AceGUI:Create("SimpleGroup")
    specClassGroup:SetFullWidth(true)
    specClassGroup:SetLayout("Flow")
    
    local specradio = AceGUI:Create("CheckBox")
    specradio:SetType("radio")
    specradio:SetLabel("Specialization Specific Macro")
    specradio:SetValue(true)
    specradio:SetWidth(250)
    specradio:SetCallback("OnValueChanged", function (obj,event,key) GSSE:toggleClasses("spec")  end)
    
    local classradio = AceGUI:Create("CheckBox")
    classradio:SetType("radio")
    classradio:SetLabel("Classwide Macro")
    classradio:SetValue(false)
    classradio:SetWidth(250)
    classradio:SetCallback("OnValueChanged", function (obj,event,key) GSSE:toggleClasses("class")  end)
    
    
    specClassGroup:AddChild(specradio)
    specClassGroup:AddChild(classradio)
    
    
    headerGroup:AddChild(firstheadercolumn)
    
    local iconpicker = AceGUI:Create("Icon")
    iconpicker:SetLabel("Macro Icon")
    
    headerGroup:AddChild(iconpicker)
    editframe:AddChild(headerGroup)
    editframe:AddChild(specClassGroup)
    
    local premacrobox = AceGUI:Create("MultiLineEditBox")
    premacrobox:SetLabel("PreMacro")
    premacrobox:SetNumLines(3)
    premacrobox:DisableButton(true)
    premacrobox:SetFullWidth(true)
    editframe:AddChild(premacrobox)
    
    
    local spellbox = AceGUI:Create("MultiLineEditBox")
    spellbox:SetLabel("Sequence")
    spellbox:SetNumLines(9)
    spellbox:DisableButton(true)
    spellbox:SetFullWidth(true)
    editframe:AddChild(spellbox)
    
    local postmacrobox = AceGUI:Create("MultiLineEditBox")
    postmacrobox:SetLabel("PostMacro")
    postmacrobox:SetNumLines(3)
    postmacrobox:DisableButton(true)
    postmacrobox:SetFullWidth(true)
    editframe:AddChild(postmacrobox)
    Posted in: Ace3
  • 0

    posted a message on GetMacroInfo and AceGui Icon's widgets
    Apologies - found my mistake my code was prefixing "Interface\\Icons\\" to the ID.

    Any luck on number 2?
    Posted in: Ace3
  • 0

    posted a message on GetMacroInfo and AceGui Icon's widgets
    I have two questions that relate to ACEGUI Icon widgets

    Question 1:
    Consider:
    a,b,c = GetMacroInfo(id)


    The b in the above line used to return a path to an icon like "INTERFACE\\ICONS\\INV_MISC_QUESTIONMARK"

    b now returns an ID. Is there a way I can set the AceGui Icon control to accept the id? If i pass it where i used to pass the string I get a green square.

    Question 2:
    Is there a way of calling the ingame Icon browser when i click on an Icon widget?
    Posted in: Ace3
  • 0

    posted a message on LibBabble-Spell equivalent
    Big wall of text. -- Apologies

    Quote from myrroddin
    GetSpellInfo() takes a spellID, and its first return is the localized spell name.
    local consecration = GetSpellInfo(26573)
    print(consecration)
    -- enUS = Consecration
    -- frFR = Consagración

    In your macro or code, it would be something like
    local consecration = GetSpellInfo(26573)
    /cast consecration


    What you are describing is what I have already tried. The problem is that in this scenario,
    "/cast consecration"
    is converted by Blizzard's SecureButtonActionTemplate : CastSpellByName() to be
    CastSpellBytName("26573")


    To better describe what I need to do

    start with this:
    Macroset["MyMacro"] {
    '/cast [nochanneling] Cobra Shot',
    '/cast [nochanneling] !Kill Command',
    '/cast [nochanneling] Bestial Wrath',
    '/cast [nochanneling] !Dire Beast',
    '/cast [nochanneling] Barrage',
    }


    This is bound as a string to the Button. Button Parameters are type="macro". button.macro = Macroset["MyMacro"]

    On an English client this works are the input is Localized English. This is readable and understandable.

    If i take the same code and replace it with spell ID's lke this:

    Macroset["MyMacro"] {
    '/cast [nochanneling] 11723',
    '/cast [nochanneling] 11765',
    '/cast [nochanneling] 11876',
    '/cast [nochanneling] 11788',
    '/cast [nochanneling] 12566',
    }

    and attempt to put it onto the same button.macro = Macroset["MyMacro"]
    I get spell not found errors. I need to translate the SpellId's back to English. This is a limitation of the Macro Interface.

    To test this Grab any spell and make a macro with its spell ID eg (this example is Paladin Consecration
    /cast 26573


    When I was testing this earlier it did nothing.

    I then need to translate it back to English to put into the Button. That's also achievable and is not a performance hit or anything like that but the string is not sharable or transportable. The output is not understandable by people.

    I currently have people translating 100's of kbs of this kind of code. The downside is anytime I make a change they have to retranslate.

    -------------------------

    This the culprit code from FrameXML\ChatFrame.lua line 1104

    (https://github.com/tekkub/wow-ui-source/blob/live/FrameXML/ChatFrame.lua#L1104)

    -- We want to prefer spells for /cast and items for /use but we can use either
    SecureCmdList["CAST"] = function(msg)
        local action, target = SecureCmdOptionParse(msg);
        if ( action ) then
        	local spell = GetSpellInfo(action)
    		local name, bag, slot = SecureCmdItemParse(action);
    		if ( spell ) then
    			CastSpellByName(action, target);
    		elseif ( slot or GetItemInfo(name) ) then
    			SecureCmdUseItem(name, bag, slot, target);
    		end
        end
    end
    
    SecureCmdList["USE"] = function(msg)
        local action, target = SecureCmdOptionParse(msg);
        if ( action ) then
    		local name, bag, slot = SecureCmdItemParse(action);
    		if ( slot or GetItemInfo(name) ) then
    			SecureCmdUseItem(name, bag, slot, target);
    		else
    			CastSpellByName(action, target);
    		end
        end
    end


    The value of Action is the localized string of the spell name. Even though local spell = GetSpellInfo(action) will work with the passed in SpellID it is knocked out by CastSpellByName(action, target) which wont resolve a spellid back to a spell.

    This hasn't changed since Vanilla where SpellID at the time wasn't static but was relational to where it appeared in your spell book.

    Its almost like, short of a translation library, I need to create a structure that accepts the localized name but exports both and if it sees the spellid version processes that if it cant understand the localized one that looks something like:

    Macroset["MyMacro"] {
    '/cast [nochanneling] Cobra Shot',
    '/cast [nochanneling] !Kill Command',
    '/cast [nochanneling] Bestial Wrath',
    '/cast [nochanneling] !Dire Beast',
    '/cast [nochanneling] Barrage',
    unicode={
      '/cast [nochanneling] 11723',
      '/cast [nochanneling] 11765',
      '/cast [nochanneling] 11876',
      '/cast [nochanneling] 11788',
      '/cast [nochanneling] 12566',
    }
    }
    Posted in: Libraries
  • 0

    posted a message on LibBabble-Spell equivalent
    Unfortunately I cant rethink my approach as I am limited by what I can provide SecureButtonActionTemplate. It calls to CastSpellByName so the localised name is what I have to provide it. (This is Blizzard Code that I cant override)

    So my problem is I have a string that is "/cast Consecration". Now on an english client I can go GetSpellInfo("Consecration") and get a SpellID. So far so good. I can then take that SpellID and on a French client GetSpellInfo(SpellID) and get "Consagración". The problem is I need to give the French Client "Consecration" and get from there to "Consagración"

    Its all because Button Type = macro and /cast and /use call down to CastSpellByName and this ignores SpellID
    Posted in: Libraries
  • 0

    posted a message on LibBabble-Spell equivalent
    Hi All,

    I have a challenge where dealing with macros the calls go down to GetSpellByName(value) where it doesnt accept SPellID but rather localised spell name.

    I have had a look at GetSpellInfo but it doesnt give me a static value that I can call. For example GetClassInfo returns a localised value (Death Knight) and a static english version (DEATHKNIGHT).

    WHat i need to be able to do is pass in an English spell name and replace it with a French/Spanish/etc version of that same ability name. For example I want to be able to get from "Consecration" to "Consagración" and back again.

    LibBabble-Spell-3.0 hasn't been maintained since 2.4 and while resurrecting it is not a prospect I would like to take on might be my solution.

    Anyone have any ideas?

    Kind Regards,
    TimothyLuke
    Posted in: Libraries
  • 0

    posted a message on Sorting AceDB data
    My data looks like:

    ["global"] = {
    		["data"] = {
    			["Horde"] = {
    				["Silvermoon"] = {
    					["Gurohir"] = {
    						["class"] = "DEATHKNIGHT",
    					},
    					["Kerfinor"] = {
    						["class"] = "ROGUE",
    					},
    					["Redridinhoof"] = {
    						["class"] = "DRUID",
    					},
    
    Posted in: Ace3
  • 0

    posted a message on Sorting AceDB data
    Hi All,

    Kinda new to Lua and trying to sort aceDB tables with no success.

    I have the following table definition:

        default_options = {
    	global = {
    		data = {
    			-- Faction
    			['*'] = {
    				-- Realm
    				['*'] = {
    					-- Name
    					['*'] = {
    						class                      = "",   
    					}
    				}
    			}
    		},
    	},
    }
     


    and am trying to do this:
    function resortDB()
        print ("Starting Sort Action")
        local sfaction
        for faction, faction_table in pairs (self.db.global.data) do
    	sfaction = faction
            for realm, realm_table in pairs (faction_table) do
    		for pc in pairs (realm_table) do
    	             table.sort(self.db.global.data[sfaction][realm], function(a,b)         
                              if self.db.profile.options.sort_type == "alpha" then
    		              return a > b
    	                  elseif self.db.profile.options.sort_type == "rev-alpha" then
                                  return a < b 
    	                  elseif ....
    
    	                  end 
    	             end )
    		end
            end
        end
    end


    What I want to be able to do is sort the Characters. If i can get the alpha and reverse alpha to work i can then do a few other options.
    Posted in: Ace3
  • To post a comment, please or register a new account.