Thread Tools Display Modes
12-15-09, 07:47 AM   #1
coehl
A Fallenroot Satyr
 
coehl's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2009
Posts: 26
KgPanels question

Hi there, I have a couple questions.

I have a tabbing system in my UI, so you can select a "meters" tab to view your meters, and a "bars" tab to view extra action bars, etc. Let's look at a sample code:
SkadaBarWindowthreat:Show()
SkadaBarWindowSkada:Show()
BT4BarBagBar:Hide()
BT4BarStanceBar:Hide()
BT4Bar5:Hide()
BT4Bar6:Hide()
BT4Bar7:Hide()

This will work so long as the two specific windows in Skada exist and the specific bars in bartender are enabled (and both addons are available). My system's a lot more complicated than this, so there are a lot of elements, all of which NEED to exist (be turned on/installed) or the scripts lose their references and start giving me the brown lua crown.

I know I can resolve this with if statments that check for existence of the objects first. What kind of syntax do I use?

I tried something like this

if SkadaBarWindowThreat:Exists() then
SkadaBarWindowthreat:Show()
if SkadaBarWindowSkada:Exists() then
SkadaBarWindowthreat:Show()
end

--------------------------------------

Also, I have some buttons that I want to simply toggle some elements. I'm using the OnClick event I thought it would be straight forward, but what it does is it hides/shows the element for as long as the mouse button is held. Once released, it reverts back to what it was in the first place.

Here's the script I use to attempt it

if BT4Bar3:IsVisible() then
BT4Bar3:Hide()
else
BT4Bar3:Show()
end

-------------------------------------
Lastly, I cannot find anything that documents how to invoke a command or macro. Is this because of the whole "secure actions" issue?
I want a panel that I can click that invokes the
/grid standby
command. Otherwise, if I just hide Grid, Grid will come back up eventually probably due to refreshing of itself.


Any help that I can get on any of these three issues is most appreciated.

Last edited by coehl : 12-15-09 at 07:49 AM.
  Reply With Quote
12-15-09, 07:56 AM   #2
zero-kill
A Firelord
 
zero-kill's Avatar
Join Date: Aug 2009
Posts: 497
In theory all those should work, as for binding of macro you might have to cheat a little and create an action button interface for that portion.
  Reply With Quote
12-15-09, 08:01 AM   #3
coehl
A Fallenroot Satyr
 
coehl's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2009
Posts: 26
Originally Posted by zero-kill View Post
In theory all those should work
When I get back to my WoW install, I'll work harder at the exist check script. It really seemed solid to me, so perhaps I have a syntax error.

But as far as the toggle code script, I've gone over that thing with a fine toothed comb. No matter what, it always causes the visibility to toggle only during mouse button press and reverts after release. I'm curious if

if BT4Bar3:IsShown() then
BT4Bar3:Hide()
else
BT4Bar3:Show()
end

Would work better. Will try that later, but something tells me it'll be a similar result. I'm thinking there's more to the OnClick mechanic that I'm not understanding.
  Reply With Quote
12-16-09, 07:27 AM   #4
coehl
A Fallenroot Satyr
 
coehl's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2009
Posts: 26
Well, tried again.
IsShown and IsVisible both yield the same result on my toggle script. On pressing, it toggles, on releasing it toggles back. I have no idea what to do here.

As far as the checking for existence, I know about the script for checking for the existence of units, I can do that, but not frames. I scrutinized and tried different caps patterns even, but I cannot get these things to work.
  Reply With Quote
12-16-09, 10:13 AM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
http://www.wowace.com/addons/kg-panels/

__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-16-09, 10:26 AM   #6
coehl
A Fallenroot Satyr
 
coehl's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2009
Posts: 26
I've seen that thread and used it for a lot of application of this UI. Now I may have missed some golden nuggets in there that will resolve my questions, in which case, I would love to be shown where that is. But I just checked all 11 pages again, and nothing.
Unless you mean the

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

segment.
I got the same result out of this code actually.
  Reply With Quote
12-16-09, 11:23 AM   #7
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
The reason why your code is executing at both press and release is because kgPanels reacts to both. You have to specify when you want the code run.

If you do not use if pressed then... or if released then... your code will be run on both.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-16-09, 11:28 AM   #8
coehl
A Fallenroot Satyr
 
coehl's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2009
Posts: 26
Originally Posted by Seerah View Post
The reason why your code is executing at both press and release is because kgPanels reacts to both. You have to specify when you want the code run.

If you do not use if pressed then... or if released then... your code will be run on both.
Right. And by that logic, I tried this code:

if pressed then

elsif released then
if SkadaBarWindowThreat:IsShown() then
SkadaBarWindowthreat:Hide()
else
SkadaBarWindowthreat:Show()
end
end

And it did not work. Is it because of the blank line? is there a statement I can use for "do nothing"?

I do want to thank you though. I wasn't sure if going down this road with the press and release mechanics was what I needed, so when I tried it before, I pretty much gave this code a cursory shot and then said "sod it". At least now I know I should be focusing here.

Last edited by coehl : 12-16-09 at 11:31 AM.
  Reply With Quote
12-16-09, 01:17 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Code:
if released then
     if SkadaBarWindowThreat:IsShown() then
          SkadaBarWindowThreat:Hide()
     else
          SkadaBarWindowThreat:Show()
     end
end
(Lua is case-sensitive, btw. SkadaBarWindowThreat ~= SkadaBarWindowthreat)
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-16-09, 01:20 PM   #10
coehl
A Fallenroot Satyr
 
coehl's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2009
Posts: 26
Originally Posted by Seerah View Post
Code:
if released then
     if SkadaBarWindowThreat:IsShown() then
          SkadaBarWindowThreat:Hide()
     else
          SkadaBarWindowThreat:Show()
     end
end
(Lua is case-sensitive, btw. SkadaBarWindowThreat ~= SkadaBarWindowthreat)
I named the window in Skada with a lower case t. I know this because I've used the lower case t in some other scripts and it works a treat. Otherwise, does that syntax look good? By that I mean, there's gotta be something else. Hoping a second set of eyes will spot it.
  Reply With Quote
12-16-09, 01:38 PM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Still, you need to make sure that it's all correct in your code. In what you posted above, one instance had a capital T.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
12-16-09, 01:45 PM   #12
coehl
A Fallenroot Satyr
 
coehl's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2009
Posts: 26
Originally Posted by Seerah View Post
Still, you need to make sure that it's all correct in your code. In what you posted above, one instance had a capital T.
if SkadaBarWindowThreat:Exists() then
SkadaBarWindowthreat:Show()
if SkadaBarWindowSkada:Exists() then
SkadaBarWindowthreat:Show()
end
Oh yeah. That was some code that I rewrote outside of WoW purely for example, so I forgot for that time I had a lower case T in the actual script that I wrote while in game. When I tested the "Exists()" function, the syntax was indeed correct and the error it shot back at me was in regard to that exact call, Exists(), not the frame name.

I can write a script that simply tells the element to hide with the lower case "t" and it hides it, plus in the /skada config, I can see that the word "threat" for the title's main window is lower case, and if I do a mouseover frame label printout, indeed, it is lower case.

The upper case T was a goof up when rewriting code for forum example.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KgPanels question


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