• 0

    posted a message on Getting the Nth element out of a table
    I have a table, full with characters, and descriptions, like this:
    BL_DB = {
    ["Name1"] = "something",
    ["Name2"] = "something else",
    ["Name3"] = "even more"
    }

    And I'm trying to show these in a list, but because the number will be increased, I have to implement a scrollbar (Using the guide on wowwiki). Problem is that Scrollbars only work with changing texts (and hiding objects, but making 100 buttons to show only ~15 is not a good option), like buttons at the FriendsFrame, but I need only the elements from X to Y, depending on the scrollbar. The elements are linked, so I cannot use Table[1], and etc. How should/could I make this?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Modifying EasyMenu on the fly
    Thank you, it's now working :) I didn't even thought of that returning functions can make it work :D
    Posted in: Lua Code Discussion
  • 0

    posted a message on Modifying EasyMenu on the fly
    Well, I'd been trying to build a settings menu, with setting the tag checked = 1, but by not writing this into the table initializing function.
    local menu = {
        { text = "Active",keepShownOnClick = 1, func = function() 
    if (BL_IsActive == 1) then
    BL_IsActive = 0
    else
    BL_IsActive = 1
    end
     end },
        { text = "Alert settings", hasArrow = true,
            menuList = {
                { text = "Enabled",keepShownOnClick = 1, func = function() 
    if (BL_AlertEnabled == 1) then
    BL_AlertEnabled = 0
    else
    BL_AlertEnabled = 1
    end
     end }
            } 
        }
    }
    local menuFrame = CreateFrame("Frame", "BL_MenuFrame", UIParent, "UIDropDownMenuTemplate") 
    EasyMenu(menu, menuFrame, "cursor", 0 , 0);
    

    So, I want that the check of each option would depend of the option's variable. Ex.: If the IsActive is true, then there would be a check, but if I set checked = 1 into the init function, then there would be always a check, when the user opens the menu. The problem is, that I don't know the api to manually check the option. Any ideas?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Need help with the OnEvent function
    Thanks for your fast reply, I will check with Swatter, but I don't know it will help.

    Edit: Damnit, Swatter helped me, it was a missing 'end' and an unfinished string. It now works, it even sends the AddonMessage (tested by Spydon) but now I can't see any incoming chat.
    Edit2: Again an unfinished string was the culprit, now it works :) Thanks for your help
    Posted in: Need Help?
  • 0

    posted a message on Need help with the OnEvent function
    Hi everyone. I'm currently working on an addon, and I need a bit of help with this code, but I can't figure out what's the problem.
    When I add the _OnEvent function, the whole addon, the slashcommand-handler stops working. (Note: The names, and some things has been taken out for the main function of the addon remain secret, until I release it.)
    function MyAddon_Slash(cmd)
    if (cmd == "" or cmd == nil) then
    DEFAULT_CHAT_FRAME:AddMessage("This will show the proper use of the slash command")
    else -- If the command is Not nil of "" then send an AddonMessage with the command. (Like /ma something will send "Something" to the addon channel)
    	message = string.sub(cmd,0);
    	cmd = "GW",""..message.."", "GUILD";
    	SendAddonMessage(cmd);
    	end
    end
    
    SlashCmdList["MyAddon"] = MyAddon_Slash;
    SLASH_MyAddon1 = "/MA";
    SLASH_MyAddon2 = "/MyAddon";
    
    function MyAddon_OnEvent(self, event, ...)
    if (event == "CHAT_MSG_ADDON" and select(1, ...) == "GW" and select(3, ...) == "GUILD") then
    	Message = select(2, ...)
    	Sender = select(4, ...)
    	DEFAULT_CHAT_FRAME:AddMessage("["..Sender.."]: "..Message.."") -- If the prefix is GW and the addon channel is Guild, then get the message and the sender, and print it out.
    end
    
    function MyAddon_OnLoad()
    MyAddonFrame:RegisterEvent("CHAT_MSG_ADDON"); -- Simple: registers the addon message event
    end
    

    Where's the error? In-game it doesn't even gives any errors.
    The OnLoad and OnEvent has been put into the .xml file properly, so I don't have to show it there.

    (Sorry if my english is bad, isn't english my mothertounge :) )

    Thanks
    Posted in: Need Help?
  • To post a comment, please or register a new account.