-
Posted by voyager69 on Fri, 25 Mar 2011 16:59:47
I am kinda new to this all, but i wanna learn how i can make some simple addons .. so maybe in future maybe even i can contribute with idea's, advice or handson-addons to help the community.
Since you learn best by example I would like to ask if someone could make me a simple snippet (incl. TOC, XML and LUA code) that does the following:
When i cast a certain spell (for instance: DEATH GRIP or WINDSHEAR) i would like to see a info/warning-text (like DMB-warning) in the middle of my screen for 1 or 2 seconds saying: -- in RED TEXT-color: YOUR DEATH GRIP missed!! -- in BLUE TEXT-color: YOUR DEATH GRIPPED:
<name mob>
Some people already made some parts of the ability i would like, so i didnt invent the code below (if the didnt invent i am sorry if i insult someone :( )
TOC-CODE? note -- dunno what code to put in :(
XML-CODE? (with tnx to l3gsh0t here @wow-programming) note -- see FadingTextFrame
LUA-code: (with tnx to TREESTON @mmo-champion) note -- the else part isnt defined, dunno how :(
local a = CreateFrame("Frame") a:SetScript("OnEvent", function(self, event, ...) self.pguid = self.pguid or UnitGUID("player") local arg = {...} if arg[2] == "SPELL_CAST_SUCCESS" and arg[10] == "Death Grip" and arg[3]==self.pguid then SendChatMessage("Taunted: "..arg[7], "YELL") end end) a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
WOULD BE REALLY GREATFULL IF ANYONE COULD HELP ME OUT HERE SO I CAN LEARN MORE ABOUT THIS WONDERFULL WORLD OF WOW-PROGRAMMING!!
Kind regards
-
Posted by jnwhiteh on Fri, 25 Mar 2011 17:09:43
I'm not sure how to help you. The basics of creating an addon are covered in the first few chapters of the book. The code you linked as the XML actually needs to go in your Lua file. Also you don't really ask any specific questions. Unfortunately, I'm happy to see any questions that you have, but unfortunately don't have much time to try and make things work on my own.
Let me know!
-
Posted by voyager69 on Fri, 25 Mar 2011 17:52:25
I bought the book .. and read it untill page 1357 (index) and all makes sence, but still need to start putting things together and there it goes wrong :( I still don't see how I can create a lua that prints a message in YELL-chat (that part works) but also prints a message in the middle of the screen (preferably a big nice red font like in MIK's). Untill now i made the below code, but it only generates errormessages. I feel if i get this probably simple addon going it opens the door to some more difficult programming.
PLEASE PLEASE can someone check my functionalcode (i dont get it nicely in this post; how does it work??) and improve it; or give me otherwise the code i need.
Forever greatfull!! plz help
LUA-code (functional) see above post: i fixed the elseif-part; so all goes well in yell BUT i dont get a big nice red message in middle of screen; used many stuff from other addons, examples from book; the snippet i posted earlier
i f mind freeze is succes then
yell: succes print middle of screen: succes elseif mind freeze is miss then yell: missed! print middle of screen: missed! end
actual LUA-code i cant get nicely in this post
local a = CreateFrame("Frame") a:SetScript("OnEvent", function(self, event, ...) self.pguid = self.pguid or UnitGUID("player") local arg = {...} if arg[2] == "SPELL_CAST_SUCCESS" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then SendChatMessage("I interrupted with Mind Freeze: "..arg[7], "YELL") elseif arg[2] == "SPELL_CAST_SUCCESS" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then PRINT MESSAGE TO MIDDLE OF SCREEN IN NICE BIG RED FONT (MIK STYLE) elseif arg[2] == "SPELL_MISSED" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then SendChatMessage("I couldnt interrupt with Mind Freeze: "..d Freeze: "..arg[7], "YELL") elseif arg[2] == "SPELL_MISSED" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then PRINT MESSAGE TO MIDDLE OF SCREEN IN NICE BIG RED FONT (MIK STYLE) end end) a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
-
Posted by jnwhiteh on Sat, 02 Apr 2011 08:28:23
I bought the book .. and read it untill page 1357 (index) and all makes sence, but still need to start putting things together and there it goes wrong :( I still don't see how I can create a lua that prints a message in YELL-chat (that part works) but also prints a message in the middle of the screen (preferably a big nice red font like in MIK's). Untill now i made the below code, but it only generates errormessages. I feel if i get this probably simple addon going it opens the door to some more difficult programming.
PLEASE PLEASE can someone check my functionalcode (i dont get it nicely in this post; how does it work??) and improve it; or give me otherwise the code i need.
Forever greatfull!! plz help
LUA-code (functional) see above post: i fixed the elseif-part; so all goes well in yell BUT i dont get a big nice red message in middle of screen; used many stuff from other addons, examples from book; the snippet i posted earlier
i f mind freeze is succes then
yell: succes print middle of screen: succes elseif mind freeze is miss then yell: missed! print middle of screen: missed! end
actual LUA-code i cant get nicely in this post
local a = CreateFrame("Frame") a:SetScript("OnEvent", function(self, event, ...) self.pguid = self.pguid or UnitGUID("player") local arg = {...} if arg[2] == "SPELL_CAST_SUCCESS" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then SendChatMessage("I interrupted with Mind Freeze: "..arg[7], "YELL") elseif arg[2] == "SPELL_CAST_SUCCESS" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then PRINT MESSAGE TO MIDDLE OF SCREEN IN NICE BIG RED FONT (MIK STYLE) elseif arg[2] == "SPELL_MISSED" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then SendChatMessage("I couldnt interrupt with Mind Freeze: "..d Freeze: "..arg[7], "YELL") elseif arg[2] == "SPELL_MISSED" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then PRINT MESSAGE TO MIDDLE OF SCREEN IN NICE BIG RED FONT (MIK STYLE) end end) a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
I have no idea what MIK is. The easiest way to print a message that appears like a boss emote or the other messages in the middle of the screen is to use the exact same code that Blizzard uses. That's always the first point, you should look at how they do it if you want to replicate something. In this case, you can do this:
RaidNotice_AddMessage(RaidWarningFrame, "This is a message", ChatTypeInfo["RAID_WARNING"])
Also, posting code here is quite simple. Just highlight the code, and click the code button in the toolbar.