Thread Tools Display Modes
11-05-11, 01:31 PM   #1
zoktar
A Cliff Giant
AddOn Compiler - Click to view compilations
Join Date: Dec 2006
Posts: 72
some mentoring (lua noob)

Hi, so im looking to make use of

GetPrimaryTalentTree(false,false)

it will output 1 2 or 3.

once i get the output from it i have something to use based off it.

if cfg.playername == "Windblossom" and cfg.playerclass == "DRUID" and cfg.talentree == "3" then
cfg.animhealth = 0
end


cfg.talentree doesnt exist yet, its just a placeholder, where do i make GetPrimaryTalentTree(false,false) to run to give the cfg.talentree variable its output?.

First off i just want it to load when you log in or enter world since thats what everything else does atm so that seems most doable. And later if i learn anything from this get it to recheck changed talent trees using another api thingy.

this is from charspecific.lua from rothui.

if you think i should read up on something specific please tell me. I have a very basic understanding atm. Thanks.
  Reply With Quote
11-05-11, 02:25 PM   #2
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Googled and found this @ http://www.wowinterface.com/forums/s...ad.php?t=38204

Originally Posted by Ailae View Post
If all you are interested in is determining which spec a player is, you can use GetPrimaryTalentTree in conjunction with GetTalentTabInfo.

Code:
local tab = GetPrimaryTalentTree()
local name = select(2, GetTalentTabInfo(tab))
print(name)
This prints Survival for example, on a hunter who has chosen Survival as their main tree.

http://wowprogramming.com/docs/api/GetPrimaryTalentTree
http://wowprogramming.com/docs/api/GetTalentTabInfo
So I'd guess that it'd be something like:

Code:
local cfg.talenttree = GetPrimaryTalentTree()
if cfg.playername == "Windblossom" and cfg.playerclass == "DRUID" and cfg.talentree == 3 then
	cfg.animhealth = 0;
end
Learning LUA myself, but I believe(?) that would be correct?
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **

Last edited by unlimit : 11-08-11 at 01:10 AM.
  Reply With Quote
11-05-11, 03:46 PM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
As to when you can utilise these functions the following page shows that both Player_Entering_World and Player_Alive events has access to the talents.

http://www.wowpedia.org/Events_that_...oading_Process
__________________
  Reply With Quote
11-05-11, 03:58 PM   #4
zoktar
A Cliff Giant
AddOn Compiler - Click to view compilations
Join Date: Dec 2006
Posts: 72
Originally Posted by Xrystal View Post
As to when you can utilise these functions the following page shows that both Player_Entering_World and Player_Alive events has access to the talents.

http://www.wowpedia.org/Events_that_...oading_Process
cool thanks thats what i was gonna checkout! cheers.

edit: so charspecific.lua was commented out of the .toc
thats why it didnt work .

Last edited by zoktar : 11-05-11 at 06:24 PM. Reason: solved
  Reply With Quote
11-05-11, 03:57 PM   #5
zoktar
A Cliff Giant
AddOn Compiler - Click to view compilations
Join Date: Dec 2006
Posts: 72
thanks, after an hour of trying to figure out what im doing wrong, i found that the variable doesn't even get used at that time, which i thought i had checked before... sigh. Awell ill get there eventually =).
  Reply With Quote
11-07-11, 07:36 PM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Also, the return value of GetPrimaryTalentTree is a number, not a string, so that part of your check will fail:

Code:
if cfg.playername == "Windblossom" and cfg.playerclass == "DRUID" and cfg.talentree == "3" then
Remove the quotes from around the 3.
  Reply With Quote
11-08-11, 03:59 PM   #7
zoktar
A Cliff Giant
AddOn Compiler - Click to view compilations
Join Date: Dec 2006
Posts: 72
yepp thanks that worked.
  Reply With Quote
12-19-11, 05:57 AM   #8
zoktar
A Cliff Giant
AddOn Compiler - Click to view compilations
Join Date: Dec 2006
Posts: 72
onload

--BLOOD
if cfg.playerclass == "DEATHKNIGHT" and GetPrimaryTalentTree(false,false) == 1 then
cfg.animClassOverride = {
["DEATHKNIGHT"] = { enable = true, animhealth = 7, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = true, manadecreasealpha = true, },
}
end
--FROST 11 or 19 is good for health
if cfg.playerclass == "DEATHKNIGHT" and GetPrimaryTalentTree(false,false) == 2 then
cfg.animClassOverride = {
["DEATHKNIGHT"] = { enable = true, animhealth = 27, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = true, manadecreasealpha = true, },
}
end
--UNHOLY
if cfg.playerclass == "DEATHKNIGHT" and GetPrimaryTalentTree(false,false) == 3 then
cfg.animClassOverride = {
["DEATHKNIGHT"] = { enable = true, animhealth = 28, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = false, manadecreasealpha = true, },
}
end


---------------------------------------------------
So it works but i need to do an extra reload each time. When entering world, and after switching spec.


on an off-topic matter, about ace3 profiles, im trying to tie various addons profiles to change with weakauras, the command is easy to issue in weakauras, i just take a random specspecific frame and add it in the actions tab onshow. But not all addons have specific profile switching commands, sofar
i only have this one from ForteXorcist , FW:UseProfile(2); (tho that one isnt ace3, but the rest are). Some of them have the "dual spec" option, but that wont work for me since im making spec specific ties, 3 or more. I guess what im asking for is how do i change profiles via script on an ac3 addon that has profiles but doesnt have a /addon profile name, type switch. From what i read on acedb thingy, it should be some sort of short for the addon followed by :UseProfile("name?") or (number). tried other things likke :Profile(), SetProfile(), and others. no success.

i know reflux can do this, but im heavily invested in weakauras already, so id rather have it there.

on another random topic while im in the noob section , say i want to make slight modifications to some addon, like i donno scale, setpoints etc. Is it possible to add another lua or xml to like load after the original, if so what is possible and what isnt?. My learning process is slow :| feel free to rtfm me with directions ;P

Last edited by zoktar : 12-19-11 at 07:58 AM.
  Reply With Quote
12-19-11, 08:50 AM   #9
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
You can put the code that updates the talent information to run each time the events fire for entering world and talent changes: "PLAYER_ENTERING_WORLD" and "ACTIVE_TALENT_GROUP_CHANGED".

Note that the PLAYER_ENTERING_WORLD event will fire each time you get a loading screen, if you only need it to run once at login then you can use "PLAYER_LOGIN" instead but it's up to you, if the update function is so small it's not a performance impact at all I'd put it to run at entering world like suggested.

Just an example, haven't actually tried it:
Code:
local class, primary, anim -- you can then use these anywhere in the file, think of them like "global variables" only for the file itself
local f = CreateFrame("Frame"):
f:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(f, event, ...)
  _, class = UnitClass("player")
  primary = GetPrimaryTalentTree(false, false)
  if class == "DEATHKNIGHT" then
    if primary == 1 then
      anim = {enable = true, animhealth = 7, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = true, manadecreasealpha = true}
    elseif primary == 2 then
      anim = {enable = true, animhealth = 27, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = true, manadecreasealpha = true}
    else
      anim = {enable = true, animhealth = 28, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = false, manadecreasealpha = true}
    end
  end
end)
  Reply With Quote
12-23-11, 05:55 AM   #10
zoktar
A Cliff Giant
AddOn Compiler - Click to view compilations
Join Date: Dec 2006
Posts: 72
Originally Posted by Vladinator View Post
You can put the code that updates the talent information to run each time the events fire for entering world and talent changes: "PLAYER_ENTERING_WORLD" and "ACTIVE_TALENT_GROUP_CHANGED".

Note that the PLAYER_ENTERING_WORLD event will fire each time you get a loading screen, if you only need it to run once at login then you can use "PLAYER_LOGIN" instead but it's up to you, if the update function is so small it's not a performance impact at all I'd put it to run at entering world like suggested.

Just an example, haven't actually tried it:
Code:
local class, primary, anim -- you can then use these anywhere in the file, think of them like "global variables" only for the file itself
local f = CreateFrame("Frame"):
f:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:SetScript("OnEvent", function(f, event, ...)
  _, class = UnitClass("player")
  primary = GetPrimaryTalentTree(false, false)
  if class == "DEATHKNIGHT" then
    if primary == 1 then
      anim = {enable = true, animhealth = 7, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = true, manadecreasealpha = true}
    elseif primary == 2 then
      anim = {enable = true, animhealth = 27, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = true, manadecreasealpha = true}
    else
      anim = {enable = true, animhealth = 28, animmana = 9, classcolored = false, powertypecolored = false, healthmultiplier = 0.5, manamultiplier = 1, healthdecreasealpha = false, manadecreasealpha = true}
    end
  end
end)

thanks im gonna start tinkering!.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » some mentoring (lua noob)

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