WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   Spec swap script (https://www.wowinterface.com/forums/showthread.php?t=40686)

Kendian 07-01-11 11:20 AM

Spec swap script
 
Hiyas, all :) I'm looking for a script for KG panels, that will change when I swap specs. I use sStats for all my data feeds, and can't bring myself to install fortress, or chocolate bar, etc, for just one feed. So a script (for KG Panels) that will change my spec. I THINK I'll be able to muddle my way thru to mimicing (sp?) a data feed if I could get this core script for OnClick to let me swap specs.
Mebbe I should try to insert a /runscript macro into an OnClick script for KG Panels. Gah, the sheer amount of things I do not know, is horrifying :(
My thanks, in advance, for any/all help, this community is incredible :D

Verttex 07-01-11 11:27 AM

/run if( GetActiveTalentGroup() == 1 ) then DEFAULT_CHAT_FRAME:AddMessage("Spec1...");SetActiveTalentGroup(2) else DEFAULT_CHAT_FRAME:AddMessage("Spec2...");SetActiveTalentGroup(1) end
/in 6 /equipset [spec:2]Eq1;Eq2

SDPhantom 07-01-11 06:35 PM

I use this macro to swap specs. The /usetalents command is provided in the default UI.
Code:

/usetalents [spec:1] 2;1

Kendian 07-01-11 07:03 PM

Quote:

Originally Posted by SDPhantom (Post 240579)
I use this macro to swap specs. The /usetalents command is provided in the default UI.
Code:

/usetalents [spec:1] 2;1

So how would I turn this into a kgpanels OnClick script? Aaah, nvm, thanks much for your help. :D:D Will try to see if I can work this.

SDPhantom 07-01-11 08:00 PM

I've never used kgPanels, and looking through the code, it looks like it takes in Lua code to run a script. I can provide code to feed into the addon, but I wouldn't know where to go to put it in. This is made to run in version 1.5.4.4 if it makes any difference. There's an added check because kgPanels appears to register CLICK events as 2 handler functions. Without checking a local variable it injects into the user script, it'll run the code twice in one click.

Code:

if released then SetActiveTalentGroup(GetActiveTalentGroup()%2+1); end
Note: released appears to be a local defined inside kgPanels to determine that it's running from the OnMouseUp handler.

Kendian 07-03-11 01:56 PM

Quote:

Originally Posted by SDPhantom (Post 240585)
Code:

if released then SetActiveTalentGroup(GetActiveTalentGroup()%2+1); end
Note: released appears to be a local defined inside kgPanels to determine that it's running from the OnMouseUp handler.

This worked PERFECTLY. My thanks!

Kendian 07-03-11 01:57 PM

Now I'd like to know if anyone knows a script that would call a panel based on what spec I'm currently in? :D

Seerah 07-07-11 01:20 PM

Quote:

Originally Posted by Kendian (Post 240673)
call a panel

What do you mean by this?

SDPhantom 07-07-11 01:42 PM

I'm assuming to show another frame configured in kgPanels. You'd have to know the frame's name to access it. I would suggest trying to find it using /framestack. I'm not sure what API calls are provided by kgPanels if any at all.

Kendian 07-07-11 02:51 PM

Exactly, I'm looking for a script for KG Panels, that would would show/call a panel that I've made when I switch specs. From tank to heals, and vice versa. The basic idea is making two panels, one that shows when I'm bear, while the other one hides, and one that shows when I'm in heals spec, while the first one hides.

Taryble 07-07-11 03:33 PM

kgPanels includes a way to get the actual frame name of a panel as long as you know the name you use to configure it - /framestack isn't needed.

I believe the command is
kgPanels:FetchFrame("framenameinconfigmenu")
as kgPanels doesn't name the actual frames that it generates.

Kendian 07-07-11 03:44 PM

Mebbe I explained it wrong, lol, sometimes I confuse myself. I 'm looking for a script that will show a panel based on what spec my toon is in. I switch spec, the panel switches.

Seerah 07-07-11 04:27 PM

Yeah, you need the name of the frame to do this. ;)

Code:

local f = kgPanel:Fetch("myframenameforspec2")  --or whatever this line should be
local spec = GetActiveTalentGroup(false,false)

if spec == 1 then
    self:Show()
    f:Hide()
elseif spec == 2 then
    self:Hide()
    f:Show()
end

Put the above in the OnEvent section of your spec1 panel. In OnLoad, you'll need to register for ACTIVE_TALENT_GROUP_CHANGED
Code:

self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")

Kendian 07-07-11 07:36 PM

This worked perfectly, Seerah, with very few tweaks. You rock, lady, as always, my thanks! This is what I ended up with.
OnLoad:
Code:

self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
self.text:SetFont("Fonts\\Home.ttf", 10, "OUTLINEMONOCHROME")

self.text:SetShadowOffset(1, -1)

OnClick:
Code:

if released then SetActiveTalentGroup(GetActiveTalentGroup()%2+1); end
OnEvent:
Code:

local f = kgPanels:FetchFrame("BM") 
local spec = GetActiveTalentGroup(false,false)

if spec == 1 then
    self:Show()
    f:Hide()
elseif spec == 2 then
    self:Hide()
    f:Show()
end


Kendian 07-08-11 06:10 PM

And here's a new noobish wrinkle....when I reload, or zone, they both show up, ao I have to change specs, to get one to hide. Any ideas how I would change the show/hide parameters? It works flawlessly, except for this one small thing, lol. My thanks, in advance, for any/all help~

Nibelheim 07-08-11 06:14 PM

Quote:

Originally Posted by Kendian (Post 241136)
And here's a new noobish wrinkle....when I reload, or zone, they both show up, ao I have to change specs, to get one to hide. Any ideas how I would change the show/hide parameters? It works flawlessly, except for this one small thing, lol. My thanks, in advance, for any/all help~

Register PLAYER_ENTERING_WORLD

Kendian 07-08-11 07:15 PM

Quote:

Originally Posted by Nibelheim (Post 241137)
Register PLAYER_ENTERING_WORLD

Man, Nibelheim, once again you have provided the cure to my OCD ills. Much gratitude~

:banana: :banana: :banana: :banana:

zoktar 09-30-11 02:36 PM

cfg for all 3 trees?
 
Kinda looking for the same thing, im about to create art for each spec for a few classes with the release of my ui edit, would there be a way to have it detect what tree im into rather than what spec im into?. Like for dks

Blood - Frost - Unholy
1 2 3


the art is based around the spec so id like it to switch accordingly! thanks.
edit, also class would be preferable!

brotherhobbes 09-30-11 03:35 PM

Could probably use
http://wowprogramming.com/docs/api/GetPrimaryTalentTree
tabIndex = GetPrimaryTalentTree(isInspect, isPet, talentGroup)

so like

local spec = GetPrimaryTalentTree(false, false)

if spec == 1
blood
else if spec == 2
frost
etc
etc

zoktar 10-01-11 12:25 PM

Quote:

Originally Posted by brotherhobbes (Post 245182)
Could probably use
http://wowprogramming.com/docs/api/GetPrimaryTalentTree
tabIndex = GetPrimaryTalentTree(isInspect, isPet, talentGroup)

so like

local spec = GetPrimaryTalentTree(false, false)

if spec == 1
blood
else if spec == 2
frost
etc
etc

thanks need to learn some basics at some point, could someone translate that into a working kgpanels script?


All times are GMT -6. The time now is 09:25 PM.

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