Thread Tools Display Modes
11-27-10, 10:00 AM   #1
.SkyBreaker
A Murloc Raider
 
.SkyBreaker's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 5
Help with Scripting - kgPanels

Hey all out there,

I think I need some help with scripting for the addon kgPanels...

For my interface I want to set up kgPanels for in and out vehicle use.
I want to show up a specific Panel if you're not in a vehicle, and another panel if you're in one.

For now, the script I use... work... sometimes. That suck... Looks like this now:

OnLoad (Panel 1 and 2):
self:RegisterEvent ("UNIT_ENTERED_VEHICLE")
self:RegisterEvent ("UNIT_EXITED_VEHICLE")


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


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


Sometimes it's just inversed... Or just switch in mid fight in Battlegrounds (when someone else uses a vehicle?)
I was thinking about something about "in" or "not in" vehilce instead of "entered" or "exited" or something that only counts for my self... Don't know, but I don't find anything related to that.

Maybe you know something about that...
  Reply With Quote
11-27-10, 10:34 AM   #2
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Try this out:

Code:
--OnEvent (Panel 1):
if event == "UNIT_ENTERED_VEHICLE" then
	if (CanExitVehicle()==1) then
		self:Hide()
	end
elseif event == "UNIT_EXITED_VEHICLE" then
	if (CanExitVehicle()==nil) then
		self:Show()
	end
end

--OnEvent (Panel 2):
if event == "UNIT_ENTERED_VEHICLE" then
    if (CanExitVehicle()==1) then
		self:Show()
	end
elseif event == "UNIT_EXITED_VEHICLE" then
    if (CanExitVehicle()==nil) then
		self:Hide()
	end
end
To my understanding it's exactly what you said would be wrong, that event listens for anyone to enter/leave a vehicle so it'd be going crazy on and off without you.

Lemme know if this works!
  Reply With Quote
11-27-10, 11:27 AM   #3
.SkyBreaker
A Murloc Raider
 
.SkyBreaker's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 5
Hey Waky...

I have tried that out what you've posted but doesn't work. Now it shows me up both panels when in and when out of vehicle :/

Edit: Ok works how it should! My fault, just forgot to add the OnLoad Script >.<

Thanks

/cheer

Last edited by .SkyBreaker : 11-27-10 at 11:31 AM.
  Reply With Quote
11-27-10, 12:49 PM   #4
Waky
A Cobalt Mageweaver
 
Waky's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 200
Originally Posted by .SkyBreaker View Post
Hey Waky...

I have tried that out what you've posted but doesn't work. Now it shows me up both panels when in and when out of vehicle :/

Edit: Ok works how it should! My fault, just forgot to add the OnLoad Script >.<

Thanks

/cheer
Lol sorry about not posting that, I didn't make a change to it so I assumed I didn't have to post it :P

I'm glad it worked!
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Help with Scripting - kgPanels

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off