• 0

    posted a message on ace style event handler question
    Yea thats true, im just trying to learn how it works ;) thanks
    Posted in: Lua Code Discussion
  • 0

    posted a message on ace style event handler question
    myAddon = {}
    local addon = myAddon
    local f = CreateFrame("Frame")
    
    f:SetScript("OnEvent", function(self, event, ...) 
          if addon[event] then 
             return addon[event](addon, event, ...) 
          end 
    end)
    f:RegisterEvent("PLAYER_TARGET_CHANGED")
    f:RegisterEvent("UNIT_AURA")
    function addon:PLAYER_TARGET_CHANGED(event, arg1, arg2)
       doStuff()
    end
    function addon:UNIT_AURA(event, arg1, arg2)
       doStuff()
    end
    


    What if I wanted to do the same function doStuff() on both UNIT_AURA and PLAYER_TARGET_CHANGED, do I have to create 2 separate functions for each event and add the same line of code to them both? ???
    LIke with a "normal" event handler you could do:
    local function eventHandler(self, event, ...)
       if event == "UNIT_AURA" or event == "PLAYER_TARGET_CHANGED" then
          doStuff()
       end
    end
    
    Posted in: Lua Code Discussion
  • 0

    posted a message on problems with addon_loaded
    Ah, thanks guys it works perfectly ;)
    Posted in: Lua Code Discussion
  • 0

    posted a message on problems with addon_loaded
    Hi guys i'm having some problems with my addon. It removes all minimap buttons when loaded (addon_loaded) the problem is when addons load after mine the buttons don't get registered..
    this is what happends:

    1. my addon loaded
    2. record all Minimap:GetChildren()
    3. Hide them
    4. another addon loads and adds a new button
    5. the new button is not recorded and will not be hidden

    I tried using variables_loaded instead but it only recorded 1 of the other addon and still didn't hide it..
    Posted in: Lua Code Discussion
  • 0

    posted a message on small problem with partyframes
    well the problem is that i don't always know the name of PartyMemberFrame1, sometimes it's PartyMemberFrame2 etc and then I have to add .."HealthBar" to it, but thanks for your code it worked the way I wanted :D
    Posted in: Lua Code Discussion
  • 0

    posted a message on small problem with partyframes
    Quote from Seerah
    You're trying to call GetScale() on a string instead of on the frame reference itself.


    so how to do it then? :confused:
    Posted in: Lua Code Discussion
  • 0

    posted a message on small problem with partyframes
    ok thanks;)
    Now I got another problem :D why doesn't this work?

    print((PartyMemberFrame1:GetName().."HealthBar"):GetScale())
    

    i get an error: attempt to call method 'GetScale' (a nil value)

    HOwever this works:
    print(PartyMemberFrame1HealthBar:GetScale())
    

    I double checked the name.., i dont get it? it probably something really silly :p
    Posted in: Lua Code Discussion
  • 0

    posted a message on small problem with partyframes
    hello again, I'm trying to make a background to the party frame(s) (1 for each person) so far I got this:
    local name = CreateFrame("Frame")
    name:SetFrameStrata("BACKGROUND")
    name:SetHeight(PartyMemberFrame1:GetHeight())
    name:SetWidth(PartyMemberFrame1:GetWidth())
    name:SetPoint("CENTER", PartyMemberFrame1, "CENTER", 0, 0)
    name:SetBackdrop( {
          bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
    })
    name:SetBackdropColor(1, 0, 0, 0.8)
    

    Ok, this create a nice background on partymember 1, but the problem is: if he has a pet the frame has to be updated ( changed size to include pet)

    My question: how do I know when a pet is present and how do I update my background frame to include it? :)
    Posted in: Lua Code Discussion
  • 0

    posted a message on changing battleground instance
    yes thats what I meant :P sorry english is not my first language! but I'm guessing by the lack of responses that this is impossible to do :D
    Posted in: Lua Code Discussion
  • 0

    posted a message on changing battleground instance
    yea JoinBattlefield(0) joins the first available instance for the one you have selected (AV) and if you use JoinBattlefield(1) it joins the 1st instance of the battlefield, etc etc
    Posted in: Lua Code Discussion
  • 0

    posted a message on changing battleground instance
    So im making an addon that queues different battlegrounds from my own interface. Im using JoinBattlefield() atm but it only joins me for AV? How can i change it to join other battlegrounds? I also tried SetSelectedBattlefield(index) before calling JoinBattlefield but it didnt work.. :confused:
    Posted in: Lua Code Discussion
  • 0

    posted a message on getting color
    thank you very very much! :)
    Posted in: Lua Code Discussion
  • 0

    posted a message on getting color
    How do I get the color in RGB from the guild uh.. guild color? I mean can I get the exact color code in any way? I need the color code for the green guild color and also the whisper color, damn i hope that made sense :p
    Posted in: Lua Code Discussion
  • 0

    posted a message on How to get frame name from onClick?
    well I'm gonna have a couple of more buttons so isn't it better to create 1 function to hold them all instead of say 5-6 separate functions?


    you don't need to name the buttons to identify them -- you can id them by their actual frame, assuming you have the variable still in scope. since CreateFrame makes globals, they'll always be in scope but the variables "button1" and "button2" are locals defined after the Click function so they are unknown to it so "self == button1" would not work.


    i dont understand what you mean by this :p
    how can I use "self == Button1" unless i name the frame?
    Posted in: Lua Code Discussion
  • 0

    posted a message on How to get frame name from onClick?
    ah.. thanks everyone it works now! i probably should have posted the full code to show what I'm trying to achieve:

    local f = CreateFrame("Frame")
    f:SetHeight(150)
    f:SetWidth(250)
    f:SetPoint("BOTTOM", UIParent, "CENTER", 0, -10)
    f:SetBackdrop( {
          bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
          edgeFile = [[Interface\Tooltips\UI-Tooltip-Border]],
          tile = true, tileSize = 16, edgeSize = 16,
          insets = { left = 5, right = 5, top = 5, bottom = 5 }
    })
    f:SetBackdropColor(0, 0, 0, 0.8)
    f:SetBackdropBorderColor(1, 1, 1, 1)
    
    local function Clicked(self)
       ChatFrame1:AddMessage("click came from: " .. self:GetName())
       if self:GetName() == "Button1" then
          ChatFrame1:AddMessage("start!")
       elseif self:GetName() == "Button2" then
          ChatFrame1:AddMessage("stop!")
       end
    end
    
    
    local button1 = CreateFrame("Button", "Button1", f, "UIPanelButtonTemplate")
    button1:SetPoint("BOTTOM", f, "CENTER", -50, 0)
    button1:SetWidth(50)
    button1:SetHeight(30)
    button1:SetText("Start")
    button1:SetScript("onClick", Clicked)
    
    local button2 = CreateFrame("Button", "Button2", f, "UIPanelButtonTemplate")
    button2:SetPoint("BOTTOM", f, "CENTER", 50, 0)
    button2:SetWidth(50)
    button2:SetHeight(30)
    button2:SetText("Stop")
    button2:SetScript("onClick", Clicked)
    


    I don't know if this is the best way to do it but it works :D
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.