WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Slash Command Opening Frame (https://www.wowinterface.com/forums/showthread.php?t=56524)

candrid 08-11-18 09:47 PM

Slash Command Opening Frame
 
Hi Guys,

I am trying to learn by hand and research but I am a little stuck and have to take steps in very small amounts do to an injury.

I am trying to make a slash command, that toggles a frame on and off. The command like "/paw" would open up a normal frame, created by lua. I have a feeling it has something to do with EventRegister?

I can't seem to fit it together in my head.
Any tips?

Ammako 08-11-18 10:05 PM

Wowpedia has a good example on that.

https://wow.gamepedia.com/Creating_a_slash_command

Depending on which frame it is you're looking to toggle on and off, it should be as simple as adding if not frame:IsShown() then frame:Show() else frame:Hide() end in your handler function (replacing "frame" with the frame in question, of course.)

Not sure if :IsVisible() or :IsShown() would be preferable, you might have to experiment. Or someone probably knows. But since you'd be calling :Show() and :Hide() on that very same frame, :IsShown() should work fine.

Kanegasi 08-11-18 10:16 PM

The IsShown method checks whether the frame would be shown, such as its parent is shown. IsVisible is a direct check on whether the frame is actually visible. If IsVisible is true, IsShown is always true, but IsVisible can be false while IsShown is true.

Neither account for 0 alpha or frame position being off screen.

candrid 08-11-18 11:09 PM

Thanks guys Ill take a good look at this.

candrid 08-11-18 11:21 PM

Lua Code:
  1. local BottomPane = CreateFrame("Frame", "BottomPane", nil, UIParent) -- creates a frame named BottomPane. Note, we also set a variable called bottompane.
  2. BottomPane:SetFrameStrata("LOW");
  3. ScreenW = GetScreenWidth();
  4. ScreenH = GetScreenHeight();
  5. BottomPane:SetWidth(ScreenW);
  6.  
  7. local BPTex = BottomPane:CreateTexture(nil, "BACKGROUND");
  8. BPTex:SetTexture("Interface\\Addons\\PawsUI\\Art\\splash.tga");
  9. BPTex:SetAllPoints(BottomPane);
  10. BottomPane.texture = BPTex
  11. BottomPane:SetPoint("BOTTOM",0,0)
  12. BottomPane:Show();
  13.  
  14. SLASH_PANE1 = "/pane"
  15. SlashCmdList.PANE = function(arg)
  16.     if not BottomPane:IsShown() then
  17.       BottomPane:Show()
  18.     else BottomPane:Hide()
  19.     end
  20. end


Ok fixed the lua errors. Nothing happens but I think it is the tga.

Fizzlemizz 08-11-18 11:30 PM

The frame didn't have any height and a few other errors

Code:

local BottomPane = CreateFrame("Frame", "BottomPane", nil, UIParent) -- creates a frame named BottomPane. Note, we also set a variable called bottompane.
ScreenW = GetScreenWidth();
ScreenH = GetScreenHeight();
BottomPane:SetWidth(ScreenW);
BottomPane:SetHeight(50)

local BPTex = BottomPane:CreateTexture(nil, "BACKGROUND");
BPTex:SetTexture("Interface/BUTTONS/WHITE8X8");
BPTex:SetAllPoints(BottomPane);
BottomPane.texture = BPTex
BottomPane:SetPoint("BOTTOM",0,0)

SLASH_PANE1 = "/pane"
SlashCmdList.PANE = function(arg)
    BottomPane:SetShown(not BottomPane:IsShown())
end

OVERLAY is not a Strata

candrid 08-11-18 11:50 PM

Quote:

Originally Posted by Fizzlemizz (Post 329478)
SLASH_PANE1 = "/pane"
SlashCmdList.PANE = function(arg)
BottomPane:SetShown(not BottomPane:IsShown())
end

Sorry for my ignorance. How would I make it not show by default? I managed to replicate the toggle.

Fizzlemizz 08-11-18 11:53 PM

Lua Code:
  1. local BottomPane = CreateFrame("Frame", "BottomPane", UIParent)
  2. BottomPane:Hide()
  3. ...

The nil in your CreateFrame statement was incorrect, the third parameter is the parent.

candrid 08-12-18 12:01 AM

Quote:

Originally Posted by Fizzlemizz (Post 329480)
Lua Code:
  1. local BottomPane = CreateFrame("Frame", "BottomPane", UIParent)
  2. BottomPane:Hide()
  3. ...

The nil in your CreateFrame statement was incorrect, the third parameter is the parent.

Wow. First off, you are a Legend, I used to use your UI when it was new. It was revolutionary. Second, thank you so much for the help, I think I understand this switch now. Third, I even learned how to color my code on the forums! Thanks!

Fizzlemizz 08-12-18 12:06 AM

Quote:

Originally Posted by candrid (Post 329481)
Wow. First off, you are a Legend, I used to use your UI when it was new.

You're probably thinking of the original, mine is just a pale imitation so, not so legendary :). Have fun.

JDoubleU00 08-12-18 10:17 AM

Quote:

Originally Posted by Fizzlemizz (Post 329482)
You're probably thinking of the original, mine is just a pale imitation so, not so legendary :). Have fun.

Maybe not legendary, but Epic (purple)? :)

Fizzlemizz 08-12-18 10:32 AM

Mostly green with occaisional leaps into the blue... this can't end anywhere good :eek:.

Ammako 08-12-18 11:00 AM

But Epics are the new Greens :D


All times are GMT -6. The time now is 10:23 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI