Thread Tools Display Modes
12-24-11, 09:43 PM   #1
phillydave2012
A Murloc Raider
Join Date: Dec 2011
Posts: 6
wowiki tutorial question

I have a hankering to write an addon to parse text going to the chat window and format it in a particular way.

I went to wowwiki's tutorial on writing addons. It has a hello world program to get one started.

I placed the HelloWorld directory in my addons directory next to Blizzard's directories and the other directories for things like Gatherer and Recount.

I added inside my directory the HelloWorld.lua , HelloWorld.xml, and HelloWorld.toc files.

As a software developer I know that you have to be very careful and specific. For the life of me I cannot see why my HelloWorld addon does not appear with a checkbox when I open the WoW UI.

I'd swear the directory and files have proper permissions and are in the proper directory. All my other addons are there and all work.

I actually had tried this a few years back and had it working but for the life of me now that I actually have an idea I really want to implement I cannot figure out what I am doing wrong to even get going.

Any help at all would be greatly appreciated.
  Reply With Quote
12-24-11, 10:03 PM   #2
Coote
A Scalebane Royal Guard
 
Coote's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 440
It would help if you post your folder structure, and code.
__________________

"This is the fifteen-thousandth four hundredth and ninety-eighth occurence".
  Reply With Quote
12-24-11, 10:49 PM   #3
phillydave2012
A Murloc Raider
Join Date: Dec 2011
Posts: 6
structure

Had to tried to describe it so I wouldn't waste bandwidth. Sorry.

Here are two screen prints showing the addons directory and the contents of my directory inside.

They are just saved using paint from Windows 7.
Attached Thumbnails
Click image for larger version

Name:	addons.png
Views:	653
Size:	183.1 KB
ID:	6662  Click image for larger version

Name:	files inside.png
Views:	628
Size:	154.6 KB
ID:	6663  

Last edited by phillydave2012 : 12-25-11 at 12:24 AM.
  Reply With Quote
12-24-11, 11:54 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
You forgot your screenshots. You can attach them to your post by scrolling below the "submit reply" button when typing a comment.

PS- you should switch to wowpedia rather than wowwiki - it will be updated more reliably, as most of the wowwiki staff moved to the new site.
__________________
"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
12-25-11, 12:37 AM   #5
JerichoHM
A Kobold Labourer
 
JerichoHM's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 1
Originally Posted by phillydave2012 View Post
Had to tried to describe it so I wouldn't waste bandwidth. Sorry.

Here are two screen prints showing the addons directory and the contents of my directory inside.

They are just saved using paint from Windows 7.
It seems your file structure is correct. Perhaps you can create a paste at wowace.com of each file that will allow us to browse the code. You could also us the code tags here since the HelloWorld is so small.
  Reply With Quote
12-25-11, 01:04 AM   #6
phillydave2012
A Murloc Raider
Join Date: Dec 2011
Posts: 6
file contents

As per your instructions I switched to wowpedia.

Because I could not see a single thing wrong. I did two things.

I deleted the Omen directory from addons to confirm I was in the right place.

Sure enough, it vanished.

Also I started from scratch with the wowpedia versions of the code, cut and pasted exactly from the wowpedia hello world program.

So the code you ask for is at:
http://www.wowpedia.org/AddOn_progra...l/Introduction

I am having trouble getting in to my wowace since curse is one of the few things I allow to store my pw and have forgotten. Resetting but I will post it.

But it really is copied and pasted from the link above.



PS ok I now have it posted over at WoWace!

Goodness I really have got to know what it is because I feel like I am following along and doing exactly as instructed. In fact I even had this working once years back but didn't really have a good idea for an addon and just never went further.

Now of course that I have an idea, stumped.

Last edited by phillydave2012 : 12-25-11 at 01:16 AM.
  Reply With Quote
12-25-11, 03:33 AM   #7
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Have you restarted wow (a simple reload will not find new created files in the filestructure) ?

Really make sure that the number in the toc for your interface is not bigger than 40300.

Edit:

I tested the code on wowpedia and now I know where all the faults with duplicated stuff comes from
The code itself is fine and should do what you want. The only "problem" is that the HelloWorld.lua is loaded twice.
Once in your toc and once in your xml.
You should decide if you want to use xml at all as it is only required for very few special cases.
See http://www.wowpedia.org/AddOn_progra...implementation
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 12-25-11 at 03:43 AM.
  Reply With Quote
12-25-11, 05:44 AM   #8
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Originally Posted by phillydave2012 View Post
Had to tried to describe it so I wouldn't waste bandwidth. Sorry.

Here are two screen prints showing the addons directory and the contents of my directory inside.

They are just saved using paint from Windows 7.
So, out of curiosity, it says that the file type is a "text document", did you - by accident perhaps - maybe not save the file as it should've been saved, and instead it is saving a text document with an invalid extension?
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
12-25-11, 05:54 AM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,929
Yep, that is indeed what it looks like. programmers notepad does that if youre not careful.

If you create a text file with windows 7 without notepad then it will give it the .txt extension by default. However if you open notepad and do save as a non text document and put the correct extension on it should work fine.

So in essence they are HelloWorld.lua.txt etc

To check this, right click on the file and choose properties and then details. The name will be the full name.

However, to rename it you will either have to copy and paste the contents of the file into a new one and save it correctly or ... use the Organize/Folder and Search Options to restore the extension display as my images attached show.
Attached Thumbnails
Click image for larger version

Name:	test1.png
Views:	626
Size:	189.4 KB
ID:	6664  Click image for larger version

Name:	test2.png
Views:	638
Size:	236.7 KB
ID:	6665  Click image for larger version

Name:	test3.png
Views:	618
Size:	182.8 KB
ID:	6666  
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 12-25-11 at 06:12 AM.
  Reply With Quote
12-25-11, 10:40 AM   #10
phillydave2012
A Murloc Raider
Join Date: Dec 2011
Posts: 6
HUGE thank you!

(edit) Well as stated below my addon is seen by WoW now. Very happy. It is not however sending the line of text to my chat window. The earlier responder suggested it is being called twice. To my mind the result of that should be two lines of text but I guess not. I wish I was not so clueless as to syntax and usage at this point. I feel a bit helpless but I am pretty good with fiddling. But if anybody can see from the code I took from wowpedia why it might not be actually sending the simple line of text to the window I'd love to hear from you.

Xrystal's suggestion finally got me over the top. I had seen the .txt extension problem suggested and was sure I had fixed it by starting over and switching to notepad but I had created the files as text files from Windows and so using notepad had done nothing about it.

The files did in fact have those stupid extra .txt and because I was sure they did not I would have NEVER revisited it.

Thanks to everyone, I cannot get over how helpful this site is. Special thanks Xrystal for those screen prints on Windows7 since I had known where to find that resetting of Windows options on previous versions but had not done that sort of thing with the new OS yet.

I really hope I can learn a bit about the actual syntax, api's, lua and xml now because having come back to wow in 4.3 I actually have a few tools I need that have not been implemented so maybe I can make a tiny contribution.

It is so frustrating when you think you are being careful about using the suggested example exactly and it does not work.

I knew it would be something important but I could not see those darn hidden extensions and thought I had already addressed it.

Again, huge thanks.

Last edited by phillydave2012 : 12-25-11 at 10:53 AM.
  Reply With Quote
12-25-11, 12:46 PM   #11
Coote
A Scalebane Royal Guard
 
Coote's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 440
Originally Posted by phillydave2012 View Post
I really hope I can learn a bit about the actual syntax, api's, lua and xml now
For the most part, you can ditch XML completely, and do it all in Lua. I recommend taking a look at WoWProgramming, and Programming in Lua. If you have questions, your always welcome to ask in IRC(#wowuidev on Freenode).
__________________

"This is the fifteen-thousandth four hundredth and ninety-eighth occurence".
  Reply With Quote
12-25-11, 12:58 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
If the .lua were being loaded twice, you would indeed have the printed statement twice. And, without actually seeing what you have in your file, we can only assume that you copy-pasted correctly. I also assume that you fixed the file extension for your Lua file as well as the TOC file.


1. Make sure that you are not hiding Lua errors in your Interface Options.

2. Disable all other addons when testing. If you have a chat addon that changes the number of saved lines in the chat frame, for example, it wipes everything previously printed to the chat frame.
__________________
"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
12-25-11, 06:44 PM   #13
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
Its loaded twice, but in this case not executed twice since the .lua only has a function that is called on startup (once).

The print is done early in your starting process. Scroll back your default chat frame. MoTD and addons loading messages probably just moved it out of the window
__________________
The cataclysm broke the world ... and the pandas could not fix it!
  Reply With Quote
12-25-11, 08:06 PM   #14
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Ah, that's right, it is a function that is not called from within the .lua file, only from the XML file. So, yes, it should just show up once. (Still, you should only load your .lua file once.)
__________________
"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
12-26-11, 03:11 AM   #15
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
After reading that tutorial on Wowpedia, I'm not surprised that you're confused. It's overwhelmingly verbose.

Anyway, I'd suggest not using the XML file, as it is not needed in 99.99999% of cases, and just adds a second syntax to learn. Using only Lua is easier to learn, easier to read, easier to maintain, and is slightly faster to load (since only one file has to be read from disk, instead of two).

Here is a Lua-only implementation:

Code:
## Interface: 40300
## Title: Hello World!
## Notes: My first addon.

HelloWorld.lua
Wowpedia already explained the TOC format in great detail, so I won't repeat it all here.

Lua Code:
  1. local frame = CreateFrame("Frame")
  2. -- This line creates a frame, which is a basic UI object in WoW.
  3. -- You need a frame to listen for events, so you know when things happen,
  4. -- and can respond to them.
  5.  
  6. frame:RegisterEvent("PLAYER_LOGIN")
  7. -- This line tells your frame to listen for the PLAYER_LOGIN event,
  8. -- which fires (happens) when WoW finishes logging in your character.
  9.  
  10. frame:SetScript("OnEvent", function(self, event)
  11. -- This line gives your frame something to do when an event fires.
  12.     DEFAULT_CHAT_FRAME:AddMessage("Hello world!")
  13.     -- This line tells WoW to add a message to the default chat frame
  14.     -- (usually Chat Frame 1) that says "Hello world!")
  15. end)

You can only give each frame one OnEvent script, so if you want to listen for additional events and do something differently depending on which one fired, you would need to add a check inside your OnEvent script, like this:

Lua Code:
  1. frame:SetScript("OnEvent", function(self, event)
  2.     if event == "PLAYER_LOGIN" then
  3.     -- This line tells your frame what to do when PLAYER_LOGIN happens.
  4.         DEFAULT_CHAT_FRAME:AddMessage("Hello world!")
  5.     elseif event == "ZONE_CHANGED_NEW_AREA" then
  6.     -- This line tells your frame what to do when you change zones.
  7.         DEFAULT_CHAT_FRAME:AddMessage("New zone!")
  8.     else
  9.     -- This line tells your frame what to do if any event happens that
  10.     -- your frame has registered for, but isn't specifically checked for
  11.     -- in one of the lines above.
  12.         DEFAULT_CHAT_FRAME:AddMessage("Something happened!")
  13.     end
  14. end)
  Reply With Quote
12-26-11, 06:56 PM   #16
phillydave2012
A Murloc Raider
Join Date: Dec 2011
Posts: 6
big thank yous to all

The wowpedia version continued to not work. It was not that the motd and early messages were hiding it, that version simply was not displaying a message to the chat box.

Phanx, HUGE THANK YOU.

Your version not only works but the comments were very helpful as well.

It was incredibly nice of you to take that time.

I continue to be amazed at the number of responses from the community here and the selflessness in actually doing things like helping with Windows setting and Phanx's wonderful alternate newbie program.

It is working which is so important because until you actually see output, you are not sure if you are even in the right area code.

I am getting a book and reading all the online documentation and shall continue to read people's wonderful responses here.

Again, thanks.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » wowiki tutorial question


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