• 0

    posted a message on Wish List addon
    So on my delete button i was just wondering if it actually got rid of my of my additem frame or just hid them.

    Here are my plans i made a dummy frame that holds all other frames and when the delete button is pressed it removes that item from my items table. then i need to run a foreach item in items table but the only code i can find for something like that is
    for i,v in ipairs(items) do function() additem() end
    What is the i, v and is that how i would call the function or would i need to make a new function

    items = {}
    local frameheight = 50
    local enteraddup = 0 
    local labelloc = -20
    count = 0
    local maxcount = 0
    local f = CreateFrame("Frame", "Wish List", UIParent)
    f:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
    f:SetWidth(400)
    f:SetHeight(50)
    f:EnableMouse(true)
    f:EnableKeyboard(true)
    f:Show()
    
    f:SetBackdrop(GameTooltip:GetBackdrop())
    f:SetBackdropColor(0, 0, 0, 0.8)
    f:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
    
    f:SetMovable(true)
    f:EnableMouse(true)
    f:RegisterForDrag("LeftButton")
    f:SetScript("OnDragStart", f.StartMoving)
    f:SetScript("OnDragStop", f.StopMovingOrSizing)
    f:SetScript("OnHide", f.StopMovingOrSizing)
    f:RegisterEvent("PLAYER_ENTERING_WORLD");
    
    f.enter = CreateFrame("EditBox",nil,f)
    f.enter:SetWidth(160)
    f.enter:SetHeight(24)
    f.enter:SetFontObject(GameFontNormal)
    f.enter:SetBackdrop(GameTooltip:GetBackdrop())
    f.enter:SetBackdropColor(0, 0, 0, 0.8)
    f.enter:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
    f.enter:SetPoint("TOP",f,0,0)
    f.enter:ClearFocus(self)
    f.enter:SetAutoFocus(false)
    f.enter:Insert("Link an Item")
    f.enter:SetScript( "OnEditFocusGained", function(self)
        f.enter:SetText("")
        end )
    f.enter:SetScript( "OnEnterPressed", function() 
    additem()
    self:ClearFocus()
    
    end)
    
    f.enter:SetScript( "OnEscapePressed", function( self )
    	f.enter:SetText("Link an Item")
    	self:ClearFocus()
    end )
    
    f.enter:SetScript("OnReceiveDrag", function(self)
    	local type, id, info = GetCursorInfo()
    	if type == "item" then
    		self:SetText(info)
    		self:GetScript("OnEnterPressed")(self)
    		ClearCursor()
    	end
    end)
    
    f.add = CreateFrame("Button",nil,f,"OptionsButtonTemplate")
    f.add:Enable(true)
    f.add:SetWidth(30)
    f.add:SetHeight(30)
    f.add:SetText("ADD")
    f.add:SetPoint("TOP",f,95,0)
    f.add:SetScript("OnClick",function() additem() 
    f.enter:SetText("")
    end)
    local function adddummyframe(self, event, ...)
    dummy = CreateFrame("Frame", "dummyframe", f)
    dummy:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
    dummy:SetWidth(10)
    dummy:SetHeight(500)
    dummy:Show()
    
    dummy:SetBackdrop(GameTooltip:GetBackdrop())
    dummy:SetBackdropColor(0, 0, 0, 0.8)
    dummy:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
    end
    
    f:SetScript("OnEvent", function()
    	adddummyframe()
    end)
    
    
    hooksecurefunc("ChatEdit_InsertLink", function(link)
    		if f.enter:IsVisible() and f.enter:HasFocus() then
    			f.enter:Insert(link)
    			return true
    		end
    end)
    testing = 0
    
    function additem()
        maxcount = maxcount + 1
    	count = count + 1
        enteraddup = enteraddup + 5
        frameheight = frameheight + 40
        local text = f.enter:GetText()
        f.enter:SetText("")
    	local id = text:match("^(%d+)$") or text:match("item:(%d+)")
    	if id then
    		-- text was either an item ID or an item link
    		local name, link = GetItemInfo(id)
    		if link then
            link = string.match(text, "item[%-?%d:]+")
    			-- do whatever here
        f:SetHeight(frameheight)
        f.enter:SetPoint("CENTER",f,"CENTER",0,enteraddup)
        f.add:SetPoint("CENTER",f,"CENTER",95,enteraddup)
        
        table.insert(items, link)
    
        
    local addeditem = CreateFrame("Frame", "itemsaddframe" ..maxcount, dummy)
    addeditem:SetPoint("TOP", f, 0, (labelloc - 5))
    addeditem:SetWidth(400)
    addeditem:SetHeight(30)
    addeditem:EnableMouse(true)
    addeditem:EnableKeyboard(true)
    addeditem:Show()
    addeditem:SetID(maxcount)
    addeditem:SetBackdrop(GameTooltip:GetBackdrop())
    addeditem:SetBackdropColor(0, 0, 0, 0.8)
    addeditem:SetBackdropBorderColor(0, 0, 0, 1)
    addeditem:SetScript("OnEnter", function(self)
         GameTooltip:SetOwner( self, "ANCHOR_RIGHT" )
         GameTooltip:SetHyperlink(link)
         GameTooltip:Show()
    end)
    addeditem:SetScript( "OnLeave", function( self )
         GameTooltip:Hide()
    end )
    
        addeditem.label = addeditem:CreateFontString(nil, "ARTWORK", addeditem)
        addeditem.label:SetPoint("TOP", "itemsaddframe" ..maxcount , 0, 0)
        addeditem.label:SetFont("Fonts\\FRIZQT__.TTF", 30)
        addeditem.label:SetText(text)
        addeditem.label:SetJustifyH("LEFT")
        labelloc = labelloc - 40
        
        addeditem.deleteitems = CreateFrame("Button",nil, addeditem,"OptionsButtonTemplate")
        addeditem.deleteitems:SetPoint("TOP", "itemsaddframe" ..maxcount , 200, 0)
        addeditem.deleteitems:Enable(true)
        addeditem.deleteitems:SetWidth(30)
        addeditem.deleteitems:SetHeight(30)
        addeditem.deleteitems:SetText("X")
        addeditem.deleteitems:SetID(maxcount)
        addeditem.deleteitems:SetScript("OnClick", function(self, ...)
            count = addeditem.deleteitems:GetID()
            thislabel = addeditem:GetParent()
            thislabel:SetParent(nil)
            thislabel:Hide()
            table.remove(items, count)
            adddummyframe()
            --for i,v in ipairs(items) do (function() additem() end)
        -- iterate over the labels, set all of their .id's to nil, and blank all of their font strings
        -- iterate over savedVariable and repopulate the labels
    end)   
        
        f.enter:ClearFocus()
    		end
    		return
    	else
    	f.enter:SetText("Please link an item")
        f.enter:ClearFocus ()
    	end
        f.enter:SetText("Link an Item")
    end
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    I was working with the tooltips some more and when i put an item that has multiple random stats it only shows the armor and sell value but does not show any stats and how i remove the frames that is there
    Posted in: Lua Code Discussion
  • 0

    posted a message on Hide frames in combat?
    The only reason why i dont indent with a tab is because dont like scrolling left to right just to read my code and the only think you should need to indent is stuff in a function and when the function is dont so is the indention. I dont care if the code is not indented at all it still runs as if it was indented and is still easy to read.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Hide frames in combat?
    Quote from Phanx
    wwwDot, your code formatting is still awful. Please stop mixing tabs and spaces. Even if they look the same in your editor, they don't look the same on the forum. You can set your editor to display tabs as the width of, say, 3 spaces, but web browsers don't have that option, and every web browser displays tabs at different widths. Ideally you should always indent with tabs, not with spaces, but if you really want to use spaces for some reason, please be consistent with them.


    Please stop commenting about the way people format there code. They format the way they like it and his code is formated just fine the way it is.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Starting UI Development - A table
    I have never worked with xml but here is my best shot
    I believe that the reason why the onshow is nil is because there values for

    local scrollFrame = SimpleILevelScoresContainer;
    local offset = HybridScrollFrame_GetOffset(scrollFrame);
    local buttons = scrollFrame.buttons;
    


    and if you wanted to print and test my theory on the print line put this
    print(SimpleILevelScoresContainer, HybridScrollFrame_GetOffset(scrollFrame), scrollFrame.buttons);
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    i guess what i am having trouble with how to tell which frame to delete when the delete button is pressed
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    I am having a little trouble understanding how to remove the a certain frame with my delete button
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    So here is my code so far

    when i look at the frames table it has the index, deleted items, and label. Did i do that right then

    items = {}
    frames = { }
    local frameheight = 50
    local enteraddup = 0 
    local labelloc = -20
    local count = 0
    local f = CreateFrame("Frame", "Wish List", UIParent)
    f:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
    f:SetWidth(400)
    f:SetHeight(50)
    f:EnableMouse(true)
    f:EnableKeyboard(true)
    f:Show()
    
    f:SetBackdrop(GameTooltip:GetBackdrop())
    f:SetBackdropColor(0, 0, 0, 0.8)
    f:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
    
    f:SetMovable(true)
    f:EnableMouse(true)
    f:RegisterForDrag("LeftButton")
    f:SetScript("OnDragStart", f.StartMoving)
    f:SetScript("OnDragStop", f.StopMovingOrSizing)
    f:SetScript("OnHide", f.StopMovingOrSizing)
    
    f.enter = CreateFrame("EditBox",nil,f)
    f.enter:SetWidth(160)
    f.enter:SetHeight(24)
    f.enter:SetFontObject(GameFontNormal)
    f.enter:SetBackdrop(GameTooltip:GetBackdrop())
    f.enter:SetBackdropColor(0, 0, 0, 0.8)
    f.enter:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
    f.enter:SetPoint("TOP",f,0,0)
    f.enter:ClearFocus(self)
    f.enter:SetAutoFocus(false)
    f.enter:Insert("Enter Item")
    f.enter:SetScript( "OnEditFocusGained", function(self)
        f.enter:SetText("")
        end )
    f.enter:SetScript( "OnEnterPressed", function() additem() 
    self:ClearFocus()
    
    end)
    
    f.enter:SetScript( "OnEscapePressed", function( self )
    	-- Do any cancel stuff here.
    
    	self:ClearFocus()
    end )
    
    f.enter:SetScript("OnReceiveDrag", function(self)
    	local type, id, info = GetCursorInfo()
    	if type == "item" then
    		self:SetText(info)
    		self:GetScript("OnEnterPressed")(self)
    		ClearCursor()
    	end
    end)
    
    f.add = CreateFrame("Button",nil,f,"OptionsButtonTemplate")
    f.add:Enable(true)
    f.add:SetWidth(30)
    f.add:SetHeight(30)
    f.add:SetText("ADD")
    f.add:SetPoint("TOP",f,95,0)
    f.add:SetScript("OnClick",function() additem() end)
    
    hooksecurefunc("ChatEdit_InsertLink", function(link)
    		if f.enter:IsVisible() and f.enter:HasFocus() then
    			f.enter:Insert(link)
    			return true
    		end
    end)
    testing = 0
    
    function additem()
    	count = count + 1
        enteraddup = enteraddup + 5
        frameheight = frameheight + 40
        local text = f.enter:GetText()
    	local id = text:match("^(%d+)$") or text:match("item:(%d+)")
    	if id then
    		-- text was either an item ID or an item link
    		local name, link = GetItemInfo(id)
    		if link then
    			-- do whatever here
        f:SetHeight(frameheight)
        f.enter:SetPoint("CENTER",f,"CENTER",0,enteraddup)
        f.add:SetPoint("CENTER",f,"CENTER",95,enteraddup)
        
        table.insert(items,text)
        f.enter:SetText("Enter Item")
        
    local addeditem = CreateFrame("Frame", "itemsaddframe" ..count, f)
    addeditem:SetPoint("TOP", f, 0, (labelloc - 5))
    addeditem:SetWidth(400)
    addeditem:SetHeight(30)
    addeditem:EnableMouse(true)
    addeditem:EnableKeyboard(true)
    addeditem:Show()
    addeditem:SetBackdrop(GameTooltip:GetBackdrop())
    addeditem:SetBackdropColor(0, 0, 0, 0.8)
    addeditem:SetBackdropBorderColor(0, 0, 0, 1)
    addeditem:SetScript("OnEnter", function(self)
         GameTooltip:SetOwner( self, "ANCHOR_RIGHT" )
         GameTooltip:SetHyperlink(text)
         GameTooltip:Show()
    end)
    addeditem:SetScript( "OnHide", function( self )
         GameTooltip:Hide()
    end )
    
        addeditem.label = addeditem:CreateFontString(nil, "ARTWORK")
        addeditem.label:SetPoint("TOP", "itemsaddframe" ..count , 0, 0)
        addeditem.label:SetFont("Fonts\\FRIZQT__.TTF", 30)
        addeditem.label:SetText(items[count])
        addeditem.label:SetJustifyH("LEFT")
        labelloc = labelloc - 40
        
        addeditem.deleteitems = CreateFrame("Button",nil, addeditem,"OptionsButtonTemplate")
        addeditem.deleteitems:SetPoint("TOP", "itemsaddframe" ..count , 200, 0)
        addeditem.deleteitems:Enable(true)
        addeditem.deleteitems:SetWidth(30)
        addeditem.deleteitems:SetHeight(30)
        addeditem.deleteitems:SetText("X")
        
        addeditem.deleteitems:SetScript("OnClick", function(self, ...)
        local thisLabel = self:GetParent()
        savedVariable[thisLabel.id] = nil
        -- iterate over the labels, set all of their .id's to nil, and blank all of their font strings
        -- iterate over savedVariable and repopulate the labels
    end)
       
        addeditem.index = count
        frames[count] = addeditem
        f.enter:ClearFocus()
    		end
    		return
    	else
    	f.enter:SetText("Please link an item")
        f.enter:ClearFocus ()
    	end
        
    end
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    what i ment from premade are frame i made how would this work if i was making frames on button clicks
    the only problem i have with the tooltip is the first one wont hide when i leave the frame i beleave that this is caused by another addon that also uses tooltips and is there a way to use the default game tooltip locations
    How do i make a frame be on top of another frame
    local addeditem = CreateFrame("Frame", "itemsaddframe" ..count, UIParent)
    addeditem:SetPoint("TOP", f, 0, (labelloc - 5))
    addeditem:SetWidth(400)
    addeditem:SetHeight(30)
    addeditem:EnableMouse(true)
    addeditem:EnableKeyboard(true)
    addeditem:Show()
    addeditem:SetBackdrop(GameTooltip:GetBackdrop())
    addeditem:SetBackdropColor(0, 0, 0, 0.8)
    addeditem:SetBackdropBorderColor(0, 0, 0, 1)
    addeditem:SetScript("OnEnter", function(self)
         GameTooltip:SetOwner( self, "ANCHOR_RIGHT" )
         GameTooltip:SetHyperlink(items[count])
         GameTooltip:Show()
         testing = testing + 1
    end)
    addeditem:SetScript( "OnHide", function( self )
         GameTooltip:Hide()
    end )
    
        addeditem.label = addeditem:CreateFontString(nil, "ARTWORK")
        addeditem.label:SetPoint("TOP", "itemsaddframe" ..count , 0, 0)
        addeditem.label:SetFont("Fonts\\FRIZQT__.TTF", 30)
        addeditem.label:SetText(table.concat(items, ", ", count))
        addeditem.label:SetJustifyH("LEFT")
        labelloc = labelloc - 40
        
        f.enter:ClearFocus()
    		end
    		return
    	else
    	f.enter:SetText("Please link an item")
        f.enter:ClearFocus ()
    	end
        
    end
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    that is all good for a premade frame but what about frames that arnt premade and for a frame name could i do something like

    frame = "frame" .. i
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    How would i put a frame into a table?
    The same way i put my link into a table

    but this all still does not explain why my frame does not work or is not showing up
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    Quote from Phanx

    You should probably also assign an index to each item frame, so you're not creating new functions repeatedly, and put the frames in a table (or at least give them unique names) so you can actually access ones other than the last one created.

    How would i put a frame in a table or what i wanted to do is use my count variable to tack on a number to the frames name and labels


    Quote from Phanx

    If by "debugger" you mean your error handler, that's incorrect. Error messages have exactly the same information regardless of whether any variables in the problem code were global or local. If you mean something else, I have no idea what you're talking about.


    I use wow debuger to debug to see if a function runs or not and to check my tables that is why it is global and why it is a generic name.
    I will change all generic names when i get further along and release to guildies for the reason you listed
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    Quote from Phanx

    2. The GameTooltip can only show one item at a time, and the SetHyperlink method ONLY accepts a single hyperlink. You can't pass it a random string full of multiple item links and expect it to do anything.

    I do not pass a random string through it. It pass one link that is in my table to the tool tip
    Quote from Phanx

    3. Creating a new frame every time you call "additem" that overwrites the frame you created last time (same global name) is a horrible idea.

    I have said this many times before the only reason why i have global stuff is so that i can debug it in WOW other wise the debugger wont pick it up

    and did change it to the way you have it egingell and i still get not tool tip and no frame shows up
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    for some reason my frame that i make does not show up but it does create the font string
    items = {}
    local frameheight = 50
    local enteraddup = 0 
    local labelloc = -20
    local count = 0
    local f = CreateFrame("Frame", "Wish List", UIParent)
    f:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
    f:SetWidth(400)
    f:SetHeight(50)
    f:EnableMouse(true)
    f:EnableKeyboard(true)
    f:Show()
    
    f:SetBackdrop(GameTooltip:GetBackdrop())
    f:SetBackdropColor(0, 0, 0, 0.8)
    f:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
    
    f:SetMovable(true)
    f:EnableMouse(true)
    f:RegisterForDrag("LeftButton")
    f:SetScript("OnDragStart", f.StartMoving)
    f:SetScript("OnDragStop", f.StopMovingOrSizing)
    f:SetScript("OnHide", f.StopMovingOrSizing)
    
    f.enter = CreateFrame("EditBox",nil,f)
    f.enter:SetWidth(160)
    f.enter:SetHeight(24)
    f.enter:SetFontObject(GameFontNormal)
    f.enter:SetBackdrop(GameTooltip:GetBackdrop())
    f.enter:SetBackdropColor(0, 0, 0, 0.8)
    f.enter:SetBackdropBorderColor(0.6, 0.6, 0.6, 1)
    f.enter:SetPoint("TOP",f,0,0)
    f.enter:ClearFocus(self)
    f.enter:SetAutoFocus(false)
    f.enter:Insert("Enter Item")
    f.enter:SetScript( "OnEditFocusGained", function(self)
        f.enter:SetText("")
        end )
    f.enter:SetScript( "OnEnterPressed", function() additem() 
    self:ClearFocus()
    
    end)
    
    f.enter:SetScript( "OnEscapePressed", function( self )
    	-- Do any cancel stuff here.
    
    	self:ClearFocus()
    end )
    
    f.enter:SetScript("OnReceiveDrag", function(self)
    	local type, id, info = GetCursorInfo()
    	if type == "item" then
    		self:SetText(info)
    		self:GetScript("OnEnterPressed")(self)
    		ClearCursor()
    	end
    end)
    
    f.add = CreateFrame("Button",nil,f,"OptionsButtonTemplate")
    f.add:Enable(true)
    f.add:SetWidth(30)
    f.add:SetHeight(30)
    f.add:SetText("ADD")
    f.add:SetPoint("TOP",f,95,0)
    f.add:SetScript("OnClick",function() additem() end)
    
    hooksecurefunc("ChatEdit_InsertLink", function(link)
    		if f.enter:IsVisible() and f.enter:HasFocus() then
    			f.enter:Insert(link)
    			return true
    		end
    end)
    testing = 0
    
    function additem()
    	count = count + 1
        enteraddup = enteraddup + 5
        frameheight = frameheight + 40
        local text = f.enter:GetText()
    	local id = text:match("^(%d+)$") or text:match("item:(%d+)")
    	if id then
    		-- text was either an item ID or an item link
    		local name, link = GetItemInfo(id)
    		if link then
    			-- do whatever here
        f:SetHeight(frameheight)
        f.enter:SetPoint("CENTER",f,"CENTER",0,enteraddup)
        f.add:SetPoint("CENTER",f,"CENTER",95,enteraddup)
        
        table.insert(items,text)
        f.enter:SetText("Enter Item")
    local addf = CreateFrame("Frame", "Wish List", UIParent)
    addf:SetPoint("TOP", f, 0, (labelloc - 5))
    addf:SetWidth(160)
    addf:SetHeight(10)
    addf:EnableMouse(true)
    addf:EnableKeyboard(true)
    addf:Show()
    addf:EnableMouse(true)
    addf:SetBackdropColor(0, 0, 0, 0.8)
    addf:SetBackdropBorderColor(1, 1, 1, 1)
    addf:SetScript("OnEnter", function(self)
         GameTooltip:SetDefaultAnchor( GameTooltip, UIParent )
         GameTooltip:SetHyperlink(table.concat(items, ", ", count))
         GameTooltip:Show()
         testing = testing + 1
    end)
    addf:SetScript( "OnLeave", function( self )
         GameTooltip:Hide()
    end )
    
        addf.label = addf:CreateFontString(nil, "ARTWORK")
        addf.label:SetPoint("TOP", addf, 0, 0)
        addf.label:SetFont("Fonts\\FRIZQT__.TTF", 30)
        addf.label:SetText(table.concat(items, ", ", count))
        addf.label:SetJustifyH("LEFT")
        labelloc = labelloc - 40
        
        f.enter:ClearFocus()
    		end
    		return
    	else
    	f.enter:SetText("Please link an item")
        f.enter:ClearFocus ()
    	end
        
    end
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on Wish List addon
    i got that much i was wondering how do i make it the items tool tip
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.