• 0

    posted a message on Adding to Pitbull frames
    I'm trying to add some extra text in a custon fonstring to PitBull unitframes but for some reason I can't seem to get the text to overlap the unitframes.

    local f = PitBull4_Frames_target:CreateFontString(nil, "OVERLAY")
    f:SetPoint("CENTER", PitBull4_Frames_target, "CENTER")
    f:SetFontObject(GameFontNormalLarge)
    f:SetText("Test")


    This works but my fonstring ends up behind the unitframes, if I try to create it on a frame "higher" up like this
    local f = PitBull4_Frames_target.Portrait:CreateFontString()

    I get an error that it doesnt exists

    if I just put the frame in wowlua it prints
    PitBull4_Frames_target.Portrait
    > nil

    but if I target something and then clear my target it shows
    PitBull4_Frames_target.Portrait
    > table: xxxxxxx

    So I can't use the portrait frame until it's created, and it only appears to be created when you target something. Not like Blizzards TargetFramePortrait, So what should I do? register to PLAYER_TARGET_CHANGED and then create my font when it fires? Is that the only way or what
    Posted in: Lua Code Discussion
  • 0

    posted a message on Paperdoll Flyout Frame
    Wow it works great, and that mod operator.. that's so smart and simple, thanks alot!
    Posted in: Lua Code Discussion
  • 0

    posted a message on Paperdoll Flyout Frame
    In case my question wasn't clear enough, this is the kinda wrapping I'm looking for.

    But I have no idea how to do it, any help would be appreciated
    Posted in: Lua Code Discussion
  • 0

    posted a message on Paperdoll Flyout Frame

    So I'm making an addon that is gonna create a button on your screen with your currently equipped weapon and if you mouseover it you will get a menu displaying all your weapons in your bag for easy swapping. As I was working on it I realized that blizzard already has this functionality if you hold down ALT while mouseovering your character frame slots, aka PaperdollFrame.
    So my question is how can I use this function on my frames? Or should I just write my own?


    edit: nvm I decided to make my own function, I got most of it working except 1 part, the positioning or docking of the button menu.

     
    function addon.CreatePopupButton(idx, itemID)
       local buttonName = "PopupButton"..idx
       local button = _G[buttonName]
       if not button then
          button = CreateFrame("Button", buttonName, UIParent, "ActionButtonTemplate")
          button:SetScript("OnClick",function(self) 
                EquipItemByName(self.ID, 16)
                addon.Button_OnLeave()
          end)
          print("created: " .. button:GetName())
       end
       _G[buttonName.."Icon"]:SetTexture(select(10, GetItemInfo(itemID)))
       button.ID = itemID
       button:ClearAllPoints()
       button:Show()
     
       if idx == 1 then
          button:SetPoint("LEFT", addon.weaponIcon, "RIGHT")
       else
          button:SetPoint("LEFT", _G["PopupButton"..(idx - 1)], "RIGHT")   
       end
    end


    That last part is the best I can do, the buttons are alligned one after another in a long row, I would like the menu to have perhaps 2 rows instead but how?? ???
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using SavedVariablesPerCharacter
    Alright, even though I dislike using other peoples codes I guess some things can only be done 1 way. But yea thanks!
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using SavedVariablesPerCharacter
    Ok wait I'm a bit confused, I need 3 tables? 2 local (defaults, addon.db) and 1 global (NameOfAddonDBPC) ? or is addon.db just pointing to the global table? I got it working but I made a slightly different version since the code posted above was a bit hard to understand for me.
    Does this look alright?
    function addon.InitializeDB()
       if not FriendFrames_DB then 
          print("found no db, creating one..")
          FriendFrames_DB = {}
       end
     
       addon.db = {}
       for k, v in pairs(defaults) do 
           print("checking for: " .. k .. " in db")
           if FriendFrames_DB[k] ~= nil then
               print("found: " .. k .. " in db")
           else
               print("cant find: " .. k .. " in db, copying from defaults")
               FriendFrames_DB[k] = v
           end
       end
       addon.db = FriendFrames_DB
    end
    Posted in: Lua Code Discussion
  • 0

    posted a message on Using SavedVariablesPerCharacter
    I added a table with all my settings for my addon in by using SavedVariablesPerCharacter in my toc file. After I loaded up my addon I checked in the savedvariables folder for the addon file and found it with all the settings in it, ok so far so good.
    But later I made some changes to my addon and added a few more settings to the table but when I try to load up my addon it still uses the old table info and as such gives an error about not finding specific table entries.

    So my only option is to manually delete the file in savedvariables folder everytime I want to make a change to the addon that involves adding new entries to my settings table. Is this how it's supposed to be? Why wont my settings overwrite the old lua file?

    ## SavedVariablesPerCharacter: new_db

     
    new_db = {
       locked = true,
       posX = 28,
       posY = -28,
    }
    --
       if event == "ADDON_LOADED" then
    --
          addon.f:SetPoint("CENTER", addon.eFrame, "CENTER", new_db.posX, new_db.posY)
    --


    In my saved variables file I only have "locked" until I delete it and relog and then it updates.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Newbie tip for OnUpdate performance
    Speaking of OnUpdate, is there any difference between these 2 codes
    addon:SetScript("OnUpdate", function(self, elapsed)
       do.stuff
    end)

    local function onUpdate(self, elapsed)
       do.stuff
    end
    addon:SetScript("OnUpdate", onUpdate)


    ?
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropdown menu code review
    Quote from Lombra
    I got it working with custom fonts, and it didn't set that font on the entire menu. You just have to create a font object for each font, unless one already exists. May be another way; didn't really try.


    Hmm that's actually a pretty good idea, thanks!
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropdown menu code review
    Aw crap, ok thanks anyway.
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropdown menu code review
    Quote from Lombra
    Should be able to work with that.


    But that don't work for custom fonts and it makes the entire list in that fontonject. The effect im looking for is this

    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropdown menu code review
    Just another question, I made a list with a couple of fonts. How can I make the dropdown list show the font name written in it's own font? I can't find anywhere to change the font of the list.
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropdown menu code review
    Good points, thanks for the tips ;)
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropdown menu code review
    I'm about to create my first addon using drop down menus, I've been reading a few guides and tutorials and managed to put together a working piece of code. But before I go ahead and add it to my main addon I would like to know what you experienced coders think about this way of adding menus.

    --not included: addon is a table, addon.panel is the interface options frame
    
    -- create the dropdown frame
    addon.dropdown1 = CreateFrame("Frame", addonName.."dropdown1", addon.panel, "UIDropDownMenuTemplate")
    addon.dropdown1:SetPoint("TOPLEFT", addon.checkbox1, "BOTTOMLEFT", -15, -20)
    addon.dropdown1:SetWidth(50)
    
    _G[addon.dropdown1:GetName().."Button"]:SetScript("OnClick", function(self, button, down)
        print("clicked")
        ToggleDropDownMenu(1, nil, addon.dropdown1, self:GetName(), -100 ,0)
    end)
    -- some tables to store data in
    local currentItem -- will be inside an options DB later
    local info = {}
    local itemsTbl = {
        "Item 1", 
        "Item 2",
        "Item 3",
        "Item 4",
    }
    
    -- function to create the menus
    function addon.dropdown1.initialize(self, level)
        if not level then return end
        wipe(info)
        if level == 1 then
            addon.CreateMenu(info)
        end
    end
    
    -- looped function for creating lots of menus, will be adding more than 4
    function addon.CreateMenu(info)
        for i = 1, 4 do
            info.text = "Menu " .. itemsTbl[i]
            info.isTitle = nil
            info.notCheckable = nil
            info.checked = addon.isCurrent(i)
            info.func = function()
                print("seleced " ..itemsTbl[i])
                currentItem = i
                _G[addon.dropdown1:GetName().."Text"]:SetText("Menu " .. itemsTbl[i])
            end
            UIDropDownMenu_AddButton(info)
        end
    end    
    
    -- function to check if current menu item is the selected one
    function addon.isCurrent(num)
        if currentItem == num then
            return true
        else
            return false
        end
    end
    Posted in: Lua Code Discussion
  • 0

    posted a message on templates for interface options?
    Ah ok, I also noticed that some addons split the interface options config code to another lua file. Is this just personal preference or?
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.