Thread Tools Display Modes
01-21-10, 10:07 PM   #1
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Noob in need ...

Hello there! I have been working on this for some time and was curious... if someone could maybe lend me a hand? I don't want anyone to tell me how to do it... Maybe just point me in the direction of how I could implement this...

This is what I want to do:



I want to make it to where I can click them and it sets my aura...

Now, again, I don't want anyone to 'tell' me, although you can if you want I want someone to point me in the right direction as to how I can go about this.

I set up a local spell in my lua, now I'm trying to figure out how to make it attatched to this list here.

If anyone can just point me in a direction I would be gladly appreciated.. Maybe an AddOn I can look at, or a site that shows what I can look at in regards to this, specifically some kind of API I can look at would be great

Thank you in advance, and I don't want to seem like I'm asking for too much. Thanks again.
  Reply With Quote
01-22-10, 12:30 AM   #2
Amenity
Guest
Posts: n/a
Ok, n00b helping the n00b here.

Basically, you would need to set up for each button in your list a script with an OnClick handler that does whatever it is you want it to do. Before this, you also may need to ensure that the button is registered for clicking.

http://www.wowwiki.com/UIHANDLER_OnClick

WoWWiki's info is actually pretty good. It's usually the first place I go when I'm having an issue.

Just remember that Lua is object-oriented. Object ---> When ---> Do ---> Stuff

Hope that helps, yet was still vague enough to not "give it away".
  Reply With Quote
01-22-10, 12:39 AM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You will need a secure frame to call your secure action (spell) from though. Not sure how to do that with a dropdown, but others have attempted it.
__________________
"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
01-22-10, 12:41 AM   #4
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Quick question: Do I have to use XML or can AddOns just be pure lua and no xml? I just... don't know or like XML lol Thanks again for all the responses thus far.
  Reply With Quote
01-22-10, 01:14 AM   #5
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by Seerah View Post
You will need a secure frame to call your secure action (spell) from though. Not sure how to do that with a dropdown, but others have attempted it.
Seerah... I don't want to sound like a noob! But could you possibly direct me to an article that explains secure frames and secure actions? I will look on my own for the meantime. I'm using Wowwiki and wow programming for the meantime. I'm getting there, slowly but surely
  Reply With Quote
01-22-10, 03:21 AM   #6
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Okay... Here is my Pastie... I'm nervous and ashamed to show it incase it looks completely horrible.. lol

http://pastie.org/789514

I need help basically associating the spells with the clicks, any help is greatly appreciated, and if I'm asking for too much, I don't mean to but let me know.

Thanks again!!

-Ferous

edit - I was looking at SealBar to help me out, although... I get confused a bit, so please bear with me

edit x 2 - Also, I was curious if there was a site or an AddOn that listed spell names? I seen that SealBar has the real names i.e. for Seal of Light it was SEAL_LIGHT and was curious if there is a list lingering about? Thanks again and sorry for so many questions.

Last edited by Ferous : 01-22-10 at 03:23 AM.
  Reply With Quote
01-22-10, 08:35 AM   #7
Recluse
A Cliff Giant
 
Recluse's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 70
Originally Posted by Ferous View Post
Quick question: Do I have to use XML or can AddOns just be pure lua and no xml? I just... don't know or like XML lol Thanks again for all the responses thus far.
They can be pure Lua. The XML is optional, but some people prefer it. In some situations, the XML is 'easier', but I found that using both XML and Lua together just made the code harder to read/debug - so now I avoid XML in addons like the plague. The Lua functions, such as CreateFrame(), are "creating" the XML objects internally though. (hope that made sense lol)
__________________
We'd be together, but only diamonds last forever...
  Reply With Quote
01-22-10, 09:37 AM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Ferous View Post
edit x 2 - Also, I was curious if there was a site or an AddOn that listed spell names? I seen that SealBar has the real names i.e. for Seal of Light it was SEAL_LIGHT and was curious if there is a list lingering about? Thanks again and sorry for so many questions.
I haven't looked at the SealBar code. That may be the global constant for the spell's name (to display the name in any locale WoW supports). It's only the name, though. It won't have any effect on what spell to cast. Now... since I haven't looked at the code, and that variable is actually where it assigns the spell, then SealBar may have the SEAL_LIGHT variable assigned elsewhere.


From glancing at your code...

1. don't use the global/deprecated variable "this". Use "self" instead. Actually, I don't see your WhatTheAuraForm_OnLoad funtion being called from anywhere... Your events are not even being registered.

2. You have two WhatTheAuraForm_OnEvent functions. The first is being overwritten by the second. (As an aside, to maybe explain this... --> ) Function names are just variables, which are assigned the value of a function. The following two examples are functionally equivalent:
Code:
function foo()
     print("hello")
end
Code:
foo = function()
     print("hello")
end
So... because you have two instances of the same function name, first you're saying WhatTheAuraForm_OnEvent equals one thing, then you're saying it equals something else.
__________________
"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
01-24-10, 12:33 PM   #9
ArrchDK
A Fallenroot Satyr
 
ArrchDK's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 25
Originally Posted by recluse View Post
They can be pure Lua. The XML is optional, but some people prefer it. In some situations, the XML is 'easier', but I found that using both XML and Lua together just made the code harder to read/debug - so now I avoid XML in addons like the plague. The Lua functions, such as CreateFrame(), are "creating" the XML objects internally though. (hope that made sense lol)
Lua only works great for smaller addons. Say you need to create 50 buttons with the exact same attributes with the exception of anchor points. About 15 lines of xml code and a looping for statement is going to be much better than a few hundred lines of code.
  Reply With Quote
01-24-10, 07:33 PM   #10
Ferous
Sheer Sense of Doom
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 863
Originally Posted by ArrchDK View Post
Lua only works great for smaller addons. Say you need to create 50 buttons with the exact same attributes with the exception of anchor points. About 15 lines of xml code and a looping for statement is going to be much better than a few hundred lines of code.
Makes sense I see alot of AddOns with both Lua and xml and I'm sure it makes it alot smaller as well to make.

Thank you all again for your time. For the meantime, I think I'm going to put this idea on hold until I can grasp a bit more. Although, I am learning alot! 6 months ago I didn't even know how to do anything in oUF and now I can modify to my needs very well. Thank you all
  Reply With Quote
01-24-10, 10:05 PM   #11
Recluse
A Cliff Giant
 
Recluse's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 70
Originally Posted by recluse View Post
...In some situations, the XML is 'easier'...
Originally Posted by ArrchDK View Post
Lua only works great for smaller addons. Say you need to create 50 buttons with the exact same attributes with the exception of anchor points. About 15 lines of xml code and a looping for statement is going to be much better than a few hundred lines of code.
*nod* That's what I was saying Even so, it wouldn't need hundreds of line for a Lua solution - or shouldn't lol.

lua Code:
  1. local buttons = {}
  2. local function on_click(...) end
  3. for i = 1,50 do
  4.     local anchor = (i < 10) and "TOP" or (i < 20) and "LEFT" or (i < 30) and "CENTER" or (i < 40) and "RIGHT" or "BOTTOM"
  5.     buttons[i] = CreateFrame("Button", string.format("sample%d", i), UIParent, UIPanelButtonTemplate)
  6.     buttons[i]:SetHeight(10)
  7.     buttons[i]:SetWidth(20)
  8.     buttons[i]:SetPoint(anchor)
  9.     buttons[i]:SetScript("OnClick", on_click)
  10. end

Anyhow, that's not a truly practical example, but to show that things can usually be done in Lua just as easily. BUT yes, there are times when an XML solution results in a reduction of coding, perhaps even with making 50 buttons, depending on how different they need to be. It is all in determining what you are going to do, and how best to solve the problem.
__________________
We'd be together, but only diamonds last forever...

Last edited by Recluse : 01-24-10 at 10:07 PM.
  Reply With Quote
01-25-10, 01:24 PM   #12
ArrchDK
A Fallenroot Satyr
 
ArrchDK's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 25
Originally Posted by recluse View Post
*nod* That's what I was saying Even so, it wouldn't need hundreds of line for a Lua solution - or shouldn't lol.

lua Code:
  1. local buttons = {}
  2. local function on_click(...) end
  3. for i = 1,50 do
  4.     local anchor = (i < 10) and "TOP" or (i < 20) and "LEFT" or (i < 30) and "CENTER" or (i < 40) and "RIGHT" or "BOTTOM"
  5.     buttons[i] = CreateFrame("Button", string.format("sample%d", i), UIParent, UIPanelButtonTemplate)
  6.     buttons[i]:SetHeight(10)
  7.     buttons[i]:SetWidth(20)
  8.     buttons[i]:SetPoint(anchor)
  9.     buttons[i]:SetScript("OnClick", on_click)
  10. end

Anyhow, that's not a truly practical example, but to show that things can usually be done in Lua just as easily. BUT yes, there are times when an XML solution results in a reduction of coding, perhaps even with making 50 buttons, depending on how different they need to be. It is all in determining what you are going to do, and how best to solve the problem.
Fair enough, maybe "hundreds" was an exaggeration. However, in your example, you're assuming that you're using standard button textures, and you're limiting your button names.
  Reply With Quote
01-25-10, 02:38 PM   #13
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
XML is dirty and just an outright pain. Plus if something is wrong at startup, it just doesn't load the addon.

No addon loading => No error messages to help debug

After many headaches of slamming my head on my desk for two hours and finally finding that I forgot a stupid "/" in one of the brackets, I started nuking my projects with XML and rewriting them in LUA.

Although it has it's confusing points, I'll take getting error messages with pure LUA to help me along over the alternative any day.
  Reply With Quote
01-25-10, 03:53 PM   #14
ArrchDK
A Fallenroot Satyr
 
ArrchDK's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 25
Originally Posted by ChaosInc View Post
XML is dirty and just an outright pain. Plus if something is wrong at startup, it just doesn't load the addon.

No addon loading => No error messages to help debug

After many headaches of slamming my head on my desk for two hours and finally finding that I forgot a stupid "/" in one of the brackets, I started nuking my projects with XML and rewriting them in LUA.

Although it has it's confusing points, I'll take getting error messages with pure LUA to help me along over the alternative any day.
I'll admit that the lack of error messages is discouraging. Personally, I use notepad++ and clicking a tag will show me where it closes, so it provides some help.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Noob in need ...


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