• 0

    posted a message on Fubar-CustomMenuFU Questions
    Quote from echobravo »

    Has anyone ever been able to get sorting to work?

    With the disclaimer that I knew nothing about Lua two days ago (but really wanted a fix for this bug), try this. The iterator to properly sort a table based on the key (which in this case is the name of the entry), is lifted directly from "Programming in Lua," page 173. I just stuck it at the bottom of CustomMenuFu.lua:

    function kpairs (t, f)
    	local a = {}
    	for n in pairs(t)
    		do a[#a + 1] = n
    	table.sort(a, f)
    	local i = 0
    	return function ()
    		i = i + 1
    		return a[i], t[a[i]]

    Then, all you need to do is replace "pairs" with "kpairs" in the same file--once in the CustomMenuFu:OnTooltipUpdate() function and once in the CustomMenuFu:List() function.

    Note that with this fix, both Autosort and Sort can be completely removed from the code, as the tooltip and listing will always be alpha sorted. This is almost certainly what you want since otherwise the order of the entries will always be arbitrary.

    I use this neat mod for Fubar access to all non-Fubar mods that have a UI (and some rarely used Fubar mods as well). I found the easiest way to create the entries was by editing the FuBar_CustomMenuFu.lua file directly.
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.