Posted by Macvombat on Fri, 10 Jul 2009 12:37:24
im Basically looking for someone with a bit of knowledge in Lua scripting, Why?
a while ago i downloaded the WoWuiDesigner Addon from Wowinterface but quickly threw it away cause it was waaay more complicated than i could handle (you are allowed to laugh a bit)
Yesterday i downloaded the NI Karma System (a loot system for raids) for this addon you need to make a ton of /commands, i made macro's for the lot, it works but...
Anyways when i was in my bed trying to sleep i thought that it would be absolutely brilliant if someone made a addon (or extended NKS) so that with a command like "/nks" you would open up a window that makes it possible to add new channels or karma to a single player or everyone, with a slight bar that decides how much karma you wan't to add
All in all i want to get rid of all those darn /commands and make the addon a bit more user friendly, so the lazy bastards like myself can use it a bit more efficient..
Okay.. i made the design of the frame in WoWuiDesigner and realised that my knowledge in Lua (wich equals non) couldn't quite cobe with the task i had at hand..
i need a few OnClick events and ofc whatever event it takes to load the addon
If you can help me out it would be most appreciated ^^
Ps. if it helps you out i can send you the layout from WoWuiDesigner
Posted by jnwhiteh on Fri, 10 Jul 2009 15:51:00
I would love to help, but unfortunately I'm very short on time.
Posted by Macvombat on Fri, 10 Jul 2009 21:43:07
Okay no worries mate, im just gonna have to buy that fancy book everyone is talking about :P It is a bit too expensive for my liking, but so far i've only heard people being happy about it so it might just be worth it..
I got one question about it though, does it actually tell me anything about Lua coding? cause i know nothing about it except for a few VERY basic things. i tried looking at a few guides and tutorials but everything i found seemed to think you already know what they were talking about :S
I looked into a few addons and found that the code in the different ones was VERY different from one another.. some had a shit load of True/False others a load of When [wtf?] If (event) (or what ever) and i believe this is because they were written in different editors?
Anyways.. a bit of advise/help would be most appreciated but i'll deffinatly buy the book when i get some bloody money again xD
Posted by Macvombat on Sat, 11 Jul 2009 16:24:54
Hmm I just so happend to get a bit further by using a bit of forums here and there, i got the frame popping up on my screen as soon as i logged in, took me by surprise to be fairly honest with you.. now the next problem came up.. i would like it to load when i do something like /KMS in the chatbox but it doesn't really matter at the moment.
After a while on forums i figured out that when you do a
<somestupidevent>OnClick (something like it at least) in your xml, you need to put in a handler (i think it's called?) in your lua for it to even know what to do with the script, correct?
Could anyone throw me in the right direction? any ideas on tutorials or webpages what ever that might explain this?
Anyways i'll keep searching, and hoping to get this "Bible of WoW Addons" some time soon
Posted by jnwhiteh on Sat, 11 Jul 2009 23:05:46
There are three ways you can attach a handler to a frame:
Writing code directly in the XML
This method is hardly used, since it makes the organization of your addon a bit weird. But you can do the following (code not verified)
<Button name="FooButton" parent="UIParent"> <!-- Make a 100x100 square in center of screen --> <Size x="100" y="100"> <Anchors> <Anchor point="CENTER"/> </Anchors> <!-- Color it blue --> <Layers> <Layer level="BACKGROUND"> <Texture setAllPoints="true"> <Color r="0.3" g="0.3" b="1.0" a="1.0"/> </Texture> </Layer> </Layers> <!-- Set an inline OnClick handler --> <Scripts> <OnClick> local button = ... local name = tostring(self:GetName()) print("You clicked on frame object " .. self .. " with name " .. name .. " and button " .. button) </OnClick> </Scripts> </Button>
As you can see the code to run onclick is included inline.
Calling a Lua handler inline
Instead of doing the actual work in the onclick portion of the XML, you can simply call a Lua function defined elsewhere. This looks like this:
<OnClick> MyAddon_Button_OnClick(self, ...) </OnClick>
The most compact way to do things is just to tell WoW what function to call when creating the onclick handler. THis looks like the following:
This has roughly the same behavior as calling the function inline, with less writing.
Posted by Macvombat on Sun, 12 Jul 2009 09:28:50
Thanks alot i'll try that out ^^