kgPanels

Create panels for customizing your UI, sucessor to eePanels

Wiki and FAQ

Sample Scripts

OnClick now provides a pressed and released variable you can check for.

if pressed then
  -- do mouse down actions
elseif released then
  -- do mouse up actions
end

This means your script will get called twice when someone clicks the panel.

Here is a youtube link to a video Tutorial

Ive created an Example Texture Pack.

This example pack is just a template. If you want to use it as a storage spot for your art, look at the read me file for directions on usage.

You must login to post a comment. Don't have an account? Register to get one!

  • Avatar of ImpalerCore ImpalerCore Nov 06, 2009 at 15:03 UTC - 0 likes

    Excellent! If those scripts work, then you should be able to do something based on whether you enter or exit a vehicle (arg1 == "player"), and ignore those events where someone else enters or exits a vehicle (arg1 == "partyN" or arg1 == "raidN" where N is a number representing a particular member of the party).

    Here is a slightly modified script to respond to those events by printing a simple chat message.

    <OnLoad>
    self:RegisterEvent("UNIT_ENTERED_VEHICLE");
    self:RegisterEvent("UNIT_ENTERING_VEHICLE");
    self:RegisterEvent("UNIT_EXITING_VEHICLE");
    self:RegisterEvent("UNIT_EXITED_VEHICLE");
    
    <OnEvent>
    DEFAULT_CHAT_FRAME:AddMessage(event)
    
    if (event == "UNIT_ENTERED_VEHICLE") then
        if ( arg1 == "player" ) then
            DEFAULT_CHAT_FRAME:AddMessage( UnitName("player") .. " is ready to rock-n-roll!" )
        else
            DEFAULT_CHAT_FRAME:AddMessage( "Does " .. UnitName( arg1 ) .. " know how to drive?" )
        end
    else if ( event == "UNIT_EXITED_VEHICLE" )
        if ( arg1 == "player" ) then
            DEFAULT_CHAT_FRAME:AddMessage( UnitName( arg1 ) .. " has left the vehicle." )
        else
            DEFAULT_CHAT_FRAME:AddMessage( UnitName( arg1 ) .. " didn't know how to drive." )
        end
    end
    

    http://lua-users.org/wiki/StringsTutorial is a good resource for manipulating strings in lua. I would recommend playing around with them. If you want to respond to a particular party member by name, class, level, etc, you can query their attributes by passing arg1 to those respective functions, UnitName, UnitClass, UnitLevel. You can use the SendChatMessage API to even communicate with other members based on these attributes.

    http://wowprogramming.com/docs/api/SendChatMessage

    <OnEvent>
    DEFAULT_CHAT_FRAME:AddMessage(event)
    
    if (event == "UNIT_ENTERED_VEHICLE") then
        if ( arg1 == "player" ) then
            SendChatMessage( UnitName( arg1 ) .. " is ready to rock 'n roll", "PARTY" )
        end
    end
    

    If this works, you should be able to replace the chat messages with sound effects if you wish. It should be something similar to the following.

    <OnLoad>
    self:RegisterEvent("UNIT_ENTERED_VEHICLE");
    self:RegisterEvent("UNIT_ENTERING_VEHICLE");
    self:RegisterEvent("UNIT_EXITING_VEHICLE");
    self:RegisterEvent("UNIT_EXITED_VEHICLE");
    
    <OnEvent>
    DEFAULT_CHAT_FRAME:AddMessage(event)
    
    if (event == "UNIT_ENTERED_VEHICLE") then
        if ( arg1 == "player" ) then
            PlaySoundFile("Sound\\Character\\Gnome\\GnomeMaleLaugh01.wav")
        end
    else if ( event == "UNIT_EXITED_VEHICLE" )
        if ( arg1 == "player" ) then
            PlaySoundFile("Sound\\Character\\Gnome\\GnomeMaleCry01.wav")
        end
    end
    

    You can find paths to the wow sounds here.

    http://www.wowwiki.com/API_PlaySoundFile http://www.wowwiki.com/Category:Macros\Sounds

    Give these scripts a try and see if they do what you expect. Then, if you can get these working, see if you can replace the appropriate lines with hiding and showing the frames you want.

  • Avatar of arturogatti arturogatti Nov 06, 2009 at 01:19 UTC - 0 likes

    All seems to be working okay.

    On the first test i do get the following messages on chat frame.

    UNIT_ENTERED_VEHICLE
    UNIT_ENTERING_VEHICLE

    when entering... and...

    UNIT_EXITED_VEHICLE
    UNIT_EXITING_VEHICLE

    when exiting.

    So that works fine.

    On the second test i get the same from above but i get a 3th line message "player" or "party#".

    example:

    UNIT_ENTERED_VEHICLE
    UNIT_ENTERING_VEHICLE
    player or party1

    Tell me more ;)

    Last edited Nov 06, 2009 by arturogatti
  • Avatar of ImpalerCore ImpalerCore Nov 05, 2009 at 14:54 UTC - 0 likes

    Alright, let's start simple. Registering all the events for getting in and out of a vehicle as far as I know.

    <OnLoad>
    self:RegisterEvent("UNIT_ENTERED_VEHICLE");
    self:RegisterEvent("UNIT_ENTERING_VEHICLE");
    self:RegisterEvent("UNIT_EXITING_VEHICLE");
    self:RegisterEvent("UNIT_EXITED_VEHICLE");
    
    <OnEvent>
    DEFAULT_CHAT_FRAME:AddMessage(event)
    

    The above panel should print the registered events when you enter and exit vehicles. See if you can get that working first.

    (The arg1 parameter is what is passed along with the event to the OnEvent handler. For example, the UNIT_HEALTH event has an arg1 that represents the unit id. This can be player, target, party1, etc. This is what I'm hoping is the arg1 of the vehicle events up above. Again, I'm unable to play with vehicles yet or otherwise I would be able to do the testing)

    http://www.wowwiki.com/Events/Unit_Info

    Then try to use this and see if it will print arg1 for the following events.

    <OnEvent>
    DEFAULT_CHAT_FRAME:AddMessage(event)
    
    if (event == "UNIT_ENTERED_VEHICLE" or event == "UNIT_EXITED_VEHICLE") then
        DEFAULT_CHAT_FRAME:AddMessage( arg1 )
    end
    

    It should print the unit id of the person entering or exiting the vehicle. For yourself, it should be "player". For other people, it may be party1, party2, etc...

    Let me know if this works at all for you.

    Last edited Nov 05, 2009 by ImpalerCore
  • Avatar of arturogatti arturogatti Nov 05, 2009 at 14:06 UTC - 0 likes

    Damn... this is starting to get a bit too much for me...

    I tried the <OnEvent> code but it didnt work... cause it gets "stuck" on the arg1 "parts".

    Can you explain better what you mean with that arg1 parameter is?

    ...and what you mean by these:

    Try to print arg1 if it exists Should work if UNIT_ENTERED_VEHICLE and UNIT_EXITED_VEHICLE events have an arg1 parameter that is a unit id.

    The best is to example me what to put on the arg1 part of the code.

    My english isn't the best... it blows my mind when i try to understand some parts of what you're saying.

    Thanks again ;)

  • Avatar of ImpalerCore ImpalerCore Nov 02, 2009 at 17:56 UTC - 0 likes

    Hmmm,

    With respect to the party vehicle problem, I can surmise that you are getting events for party members in addition to yourself. Unfortunately, the documentation for the event is not clear. I can guess that it has an arg1 parameter that is the unit id, but I can't verify it. The documentation for it on wow programming site doesn't document it.

    http://wowprogramming.com/docs/events/UNIT_ENTERED_VEHICLE

    However, many of the other UNIT_* events have the first parameter as the unit id, so assuming that arg1 is the unit should be a reasonable assumption.

    <OnLoad>
    self:RegisterEvent ("UNIT_ENTERED_VEHICLE")
    self:RegisterEvent ("UNIT_EXITED_VEHICLE")
    
    <OnEvent>
    -- Try to print arg1 if it exists
    DEFAULT_CHAT_FRAME:AddMessage( arg1 )
    
    -- Should work if UNIT_ENTERED_VEHICLE and UNIT_EXITED_VEHICLE events
    -- have an arg1 parameter that is a unit id.
    if arg1 ~= 'player' then
        return
    end
    
    if event == "UNIT_ENTERED_VEHICLE" then
        self:Hide()
    elseif event == "UNIT_EXITED_VEHICLE" then
        self:Show()
    end
    

    For the second question, I forgot to add a ClearAllPoints call. This resets all the anchor points. The SetPoint is all relative to the current anchor points, so changing anchors with SetPoint usually requires a previous ClearAllPoints.

    http://www.wowwiki.com/API_Region_ClearAllPoints

    <OnLoad>
    self:RegisterEvent ("UNIT_ENTERED_VEHICLE")
    self:RegisterEvent ("UNIT_EXITED_VEHICLE")
    
    <OnEvent>
    if event == "UNIT_ENTERED_VEHICLE" then
        Minimap:ClearAllPoints()
        Minimap:SetPoint( "CENTER", "UIParent", "CENTER", 0, 0 )
    elseif event == "UNIT_EXITED_VEHICLE" then
        Minimap:ClearAllPoints()
        Minimap:SetPoint( "CENTER", "UIParent", "CENTER", 100, 100 )
    end
    

    As far as moving the actual minimap frame instead of a decoration depends on whether you can find it with the frame finder. Some addons manipulate the actual Minimap from WoW, and from looking at the BasciMinimap code, that is what it does. So using Minimap is the proper frame. There is also a border frame that is used as well from this CreateFrame call.

    local border = CreateFrame("Frame", "BasicMinimapBorder", Minimap)

    The name of the border is "BasicMinimapBorder", and uses the Minimap frame as its parent. There is also a MinimapCluster frame that I think collects all the minimap children frames. This means that you still use the Minimap (or maybe MinimapCluster) frame to alter its coordinates. In other minimap mods, they create an entirely new minimap frame and hide the original like Minimap:Hide().

    To render the code fragments, it consists of either highlighting a section of text and clicking the gear icon on the toolbar's far right, using lua as the default argument, or you can use '<<' and '>>' brackets with 'code lua' and '/code' (which is what the gear icon does for you).

    Looking forward to hear if this works for ya.

    Last edited Nov 02, 2009 by ImpalerCore
  • Avatar of arturogatti arturogatti Nov 02, 2009 at 14:06 UTC - 0 likes

    First, the following code does hide the frames when i enter any vehicle...

    <OnLoad> self:RegisterEvent ("UNIT_ENTERED_VEHICLE") self:RegisterEvent ("UNIT_EXITED_VEHICLE")

    <OnEvent> if event == "UNIT_ENTERED_VEHICLE" then self:Hide() elseif event == "UNIT_EXITED_VEHICLE" then self:Show() end

    But now I have another weird problem...

    Its also hides my frames when someone from my party enters a vehicle. What can be really annoying.

    Now about the minimap question... I parented/anchored a decorative frame i have to the Minimap and i tried to set the following code on it:

    <OnLoad> self:RegisterEvent ("UNIT_ENTERED_VEHICLE") self:RegisterEvent ("UNIT_EXITED_VEHICLE")

    <OnEvent> if event == "UNIT_ENTERED_VEHICLE" then Minimap:SetPoint( "CENTER", "UIParent", "CENTER", 0, 0 ) elseif event == "UNIT_EXITED_VEHICLE" then Minimap:SetPoint( "CENTER", "UIParent", "CENTER", 100, 100 ) end

    ...and it does move my minimap when i enter a vehicle. I also tried changing the coordenates of the code but it doesnt return to the starting coordenates when i exit a vehicle.

    I use an addon named BasicMinimap. Is there a way to use that code on the Minimap itself instead of on my decorative frame around it?

    Once again,

    Thank you very much ;)

    PS: sorry the way the code turned out in the post... dunno how to make it look like on your posts.

    Last edited Nov 02, 2009 by arturogatti
  • Avatar of ImpalerCore ImpalerCore Oct 27, 2009 at 15:42 UTC - 0 likes

    I've not done any vehicle based stuff, but I can make a guess.

    <OnLoad>
    self:RegisterEvent ("UNIT_ENTERED_VEHICLE")
    self:RegisterEvent ("UNIT_EXITED_VEHICLE")
    
    <OnEvent>
    if event == "UNIT_ENTERED_VEHICLE" then
        self:Hide()
    elseif event == "UNIT_EXITED_VEHICLE" then
        self:Show()
    end
    

    To hide all the unitframes, you would need to invoke Hide() on all the respective global references to those frames. For Pitbull3, this can be something akin to

    PitBullUnitFrame1:Hide()
    PitBullUnitFrame2:Hide()
    ...
    PitBullUnitFrame7:Hide()
    

    Use the frame finder to create a list of unit frames you want to hide and add them to the OnEvent of your kgpanel. If you have kgpanel decorations to those frames, they should hide as well if they are parented properly.

    For changing the minimap location, you need to again find its frame name, and you can move it using the SetPoint command.

    http://www.wowwiki.com/API_Region_SetPoint

    You can use UIParent as the relative frame and "CENTER" as the relative point to center it on screen, and use ofsx and ofsy to position it. You should be able to anchor it to any corner using some combination of "TOP", "LEFT", "BOTTOM", and "RIGHT".

    If you're using the regular blizzard minimap frame, I think its name is just Minimap, so you could do something like this.

    <OnLoad>
    self:RegisterEvent ("UNIT_ENTERED_VEHICLE")
    self:RegisterEvent ("UNIT_EXITED_VEHICLE")
    
    <OnEvent>
    if event == "UNIT_ENTERED_VEHICLE" then
        Minimap:SetPoint( "CENTER", "UIParent", "CENTER", 0, 0 )
    elseif event == "UNIT_EXITED_VEHICLE" then
        Minimap:SetPoint( "CENTER", "UIParent", "CENTER", 100, 100 )
    end
    

    If you use a minimap addon, you'll have to use a different name. Again use the frame finder.

    As far as individual vehicle frame names, I do not know. There is a UnitInVehicle API function to determine whether a unit is in a vehicle, like UnitInVehicle( 'player' ), but nothing specific to vehicle name that I could find after a 5 min google search. Getting the vehicle name could be implemented in an addon somewhere, but I currently don't know how to do it.

    http://wowprogramming.com/utils/xmlbrowser is a good resource to look up how to do things as well if you get stuck and you have time to browse for vehicle name. If you get something working, it would be nice to post back to further the kgpanel script kiddies.

    Good luck!

  • Avatar of arturogatti arturogatti Oct 27, 2009 at 05:23 UTC - 0 likes

    Is there a way to see the vehicles frame name?

    Do they all have the same frame name? or is there a specific name for each one of them? (i mean.. the diferent type of vehicles... wintergrasp cannons, argent tournament lance mounts, etc...)

    Anyway... How do I make all my UI Frames Hide when i enter a vehicle?

    and...

    Is there a script for changing my minimap place (x,y) in the screen when i enter a vehicle?

    Thanks in advance ;)

  • Avatar of arturogatti arturogatti Oct 26, 2009 at 15:32 UTC - 0 likes

    Finished trying it... works 100% :D

    It wasnt the case sensitive problem... I accidently had a <space> in the end of the Pitbull4_Frames_targettarget XD

    Anyway... once again..

    Ty very much! ;)

  • Avatar of ImpalerCore ImpalerCore Oct 26, 2009 at 14:01 UTC - 0 likes

    Are you still having issues arturo? You have to be careful that the case of the letters in the name is exact.

Facts

Date created
Sep 16, 2008
Category
Last update
Oct 24, 2014
Development stage
Release
Language
  • enUS
  • frFR
  • koKR
  • zhCN
License
All Rights Reserved
Curse link
kgPanels
Reverse relationships
1
Downloads
1,846,418
Recent files
  • R: 1.20 for 6.0.2 Oct 24, 2014
  • R: 1.19 for 6.0.2 Oct 17, 2014
  • A: r433 for 6.0.2 Oct 17, 2014
  • A: r432 for 6.0.2 Oct 17, 2014
  • R: 1.18 for 5.4.8 Oct 14, 2014

Authors