Thread Tools Display Modes
10-17-14, 02:02 PM   #1
Arragoth
A Defias Bandit
AddOn Compiler - Click to view compilations
Join Date: Oct 2014
Posts: 2
KGPanels Button - run slash command

I am trying to create a button that on click will run "/reflux switch MyProfile" then disappear from view after the command has been run.

I want the button to only show the first time the character is loaded.
  Reply With Quote
10-17-14, 07:30 PM   #2
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
This is a bit hacky as it directly modifies kgPanels' DB, but it should work.

Just add this to the OnClick script of the panel:
lua Code:
  1. SlashCmdList.REFLUX("switch MyProfile")
  2. self:Hide()
  3.  
  4. local layout = kgPanels.db.global.layouts[kgPanels.active] -- Fetch the current layout
  5. for name, data in pairs(layout) do -- Search for the name/data of this frame
  6.     if kgPanels:FetchFrame(name) == self then -- We've found this frame
  7.         data.scripts.LOAD = "self:Hide()" -- Replace the OnLoad script
  8.         data.scripts.CLICK = "" -- Replace the OnClick script
  9.     end
  10. end

Change MyProfile on the first line to the name of the Reflux profile you want to switch to.

This may not work if your characters use the same kgPanels layout.

If the Reflux profile switches to a kgPanels layout without this button, you should be able to get rid of everything past the first two lines.

Last edited by Choonstertwo : 10-17-14 at 07:36 PM.
  Reply With Quote
10-21-14, 02:28 PM   #3
Arragoth
A Defias Bandit
AddOn Compiler - Click to view compilations
Join Date: Oct 2014
Posts: 2
Thx for trying, that only succeeded in hiding the panel the script was tied to though.
  Reply With Quote
10-21-14, 05:07 PM   #4
Choonstertwo
A Chromatic Dragonspawn
 
Choonstertwo's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 194
Originally Posted by Arragoth View Post
Thx for trying, that only succeeded in hiding the panel the script was tied to though.
Hiding the panel is what you wanted, right?

Does it switch Reflux profiles? Does it give you any Lua errors (make sure you have them enabled) or slash command usage text in your chat frame?
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » KGPanels Button - run slash command


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