• 0

    posted a message on Looking for a way to output raw text.
    Quote from Seerah
    Do you get a different result if you use print() instead of ChatFrame1:AddMessage()?]
    Well it still throws an error but at least with print() I do get some output... enough to get what I need done.

    Thank you and I'll still take any suggestions that people have.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Looking for a way to output raw text.
    I am looking for a way to directly print chat output. With all the links escaped so I can get an idea of what regex I need to setup. I have used the example on Wowwiki to print item strings with success but if I try t implement the same logic with the chat output I receive an "string length overflow" error being thrown by the gsub function.

    An example of what I have tried:
    local output = gsub(message, "\124", "\124\124");

    *message comes from an overwritten AddMessage function.

    How do I go about just printing the raw output from chat messages?

    Thank you for your help.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Bartender4 - Official Topic
    Is there an option to reduce the number of buttons per bar similar to what Dominos has. E.G. I want 6 buttons per bar without losing them to the void. I know I can change the slider to display the number of buttons per bar but they are just lost at that point. So if I was to change it to 6 buttons per bar I would have 20 bars. This is just an example but is this possible with BT4?
    Posted in: General AddOns
  • 0

    posted a message on UIDropDownMenu snippet question.
    Well with jerry's help I was able to get it going. TY you gave me all that I needed. Here is my test script. It is just a frame with a single button that will popup a dropdown list and output it to the chat frame. I changed a lot to suit my coding style. Coming from a strict Java OOP background you will find that everything is contained inside methods (I mean... umm... functions). I still say there is a real lack of a snippet code out there and I am one of those people who learn by tearing up other code and seeing what works for me. Wowwiki and WowProgramming along with WowCompares are great resources but they are strictly user submitted commenting and thus depending on who submitted the info you may or may not get useful information. Along with the amount of information you may get a piece of code but never in context. This type of information is coming from someone whom already completely understands the function and does not write to the unfamiliar programmer. Hence you end up with a reference but with no context you may of may not be able to get it going.

    Anyhoo... Ill post my code here and I'm sure that I have done some things wrong. I am open to all criticism but I am primarily posting this here for all those others like me who just want to see something simple and to the point running.

    I removed all my comments to save space and for clarity. I am a firm believer in commenting all your code. I also have a minimap ping event handler in there just to play with different things.

    local MyFrameTest = {};
    here to help debug and let me know what is going on when and where.
    local function Println(line)
    	if(line) then DEFAULT_CHAT_FRAME:AddMessage("|cffFF0000DEBUG:|r " .. line); end
    function MyFrameTest:Load()
    	Println('Loaded');--Debug: remove after testing
    function MyFrameTest:BuildParentFrame()
    	--Create our parent frame
    	MyFrameTest.frame = CreateFrame("Frame", "MyFrameTest", UIParent);
    	--frame visual appearance
    	MyFrameTest.frame:SetBackdrop({ bgFile = "Interface/Tooltips/UI-Tooltip-Background",
    										 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
    										 tile = true, tileSize = 16, edgeSize = 16,
    										 insets = { left = 4, right = 4, top = 4, bottom = 4 } });
    	--frame positioning
    	MyFrameTest.frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
    	--events and handlers
    	MyFrameTest.frame:SetScript('OnEvent', function(self, event, arg1) MyFrameTest:OnEvent(self, event, arg1) end);
    function MyFrameTest:OnEvent(self, event, arg1)
    	if(event == 'MINIMAP_PING') then
    		local name = (UnitName(arg1) or "Unknown");
    		Println(name .. " pinged the minimap");
    function MyFrameTest:BuildButton()
    	MyFrameTest.button = CreateFrame("Button", "MyButton", MyFrameTest.frame, "UIPanelButtonTemplate")
    	MyFrameTest.button:SetText("Click Me!")
    	MyFrameTest.button:SetScript("OnClick", function(self) MyFrameTest:OnButtonClick(self) end)
    function MyFrameTest:OnButtonClick(self)
    	ToggleDropDownMenu(1, nil, MyFrameTest.dropdown, "MyFrameTest", 0, 0)
    the dropdown mystery solved (^_^)
    local menuTable = {
    function MyFrameTest:MyDropDownTest_Initialize()
      for i, title in ipairs(menuTable) do
        local info = UIDropDownMenu_CreateInfo();
        info.text = title;
        info.value = i;
        info.owner = MyFrameTest.dropdown;
        info.func = function(self) MyFrameTest:OnMenuClick(self) end;
    function MyFrameTest:OnMenuClick(self)
    	UIDropDownMenu_SetSelectedValue(self.owner, self.value);
    	local menuText = UIDropDownMenu_GetText(MyFrameTest.dropdown);
    	Println("[" .. self.value .. "] : " .. menuText);
    function MyFrameTest:BuildDropDown()
    	UIDropDownMenu_Initialize(MyDropDownTest, function(self) MyFrameTest:MyDropDownTest_Initialize(self) end, "MENU");
    	UIDropDownMenu_SetSelectedID(MyDropDownTest, 1);
    	UIDropDownMenu_SetWidth(MyFrameTest.dropdown, 90);
    function MyFrameTest:CreateDropDownFrame()
    	MyFrameTest.dropdown = CreateFrame("Frame", "MyDropDownTest", nil, "UIDropDownMenuTemplate");
    	MyFrameTest.dropdown.point = "TOPLEFT";
    	MyFrameTest.dropdown.relativePoint = "TOPRIGHT";
    	MyFrameTest.dropdown.displayMode = "MENU";
    	MyFrameTest.dropdown.relativeTo = MyFrameTest.frame;
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropDownMenu snippet question.
    Quote from egingell
    There's really not much difference between pure Lua and hybrid XML/Lua.
    For <Anchors>, use :SetPoint(). For <Scripts>, use :SetScript(). If you're not inheriting an existing Blizzard template (UIDropDownMenuTemplates.xml), it will get far more complicated.

    I appreciate the response but I still have yet to figure it out. I know how to take an XML / Lua script and convert it over and have done so on a few occasions but this still escapes me. Every addon that I have come across that contains a dropdown seems to do it in weird ways and all in their own ways. So there is never a was for me to compare and eliminate non relative code. I only ask for pure Lua because I like to keep things clear and in one place (file).

    It's the lack of documentation in regards to Lua and WoW that baffles me.
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropDownMenu snippet question.
    I am looking for a working UIDropDownMenu example that is in pure Lua. I have searched and searched and searched ..... for just a simple frame with one dropdown. I feel really stupid since I have downloaded tons of addons that have a dropdown to try and tear them apart to see how they are doing it but no joy.

    What I would really love is an example that just has one frame in the center of the screen with one dropdown that has three menu items "One", "Two", and "Three" that once clicked just sent a message to the chat frame with their titles. This would be enough for me to see how it is done and get that "aha" moment that I know you all have.

    I feel really stupid because I have written quite a few small addons just for myself that change the UI to suit my needs but this is really throwing me. I think the biggest point is that there is no real good examples of Lua for WoW out there that can be referenced. There are great reference sites for the API and the UI (wowcompares) but Lua lacks those sites like you can find for Java, PHP, C#, etc.. where you can get a snippet of code to get you on your way.

    If you can either direct me to a site with a complete working example or just a quick snippet here other than what WowWiki has I would be grateful. I usually can just figure this stuff out on my own and I have tried and tried just with no luck. I know I am just missing something so simple.
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.