Thread Tools Display Modes
06-03-07, 11:06 AM   #1
ericstewart
A Defias Bandit
Join Date: Jun 2007
Posts: 2
Blizzard's HelloWorld

I downloaded Blizzard's AddOn Kit and used it to extract the interface data and interface art. (BTW I'm on a Mac)

I started with the first tutorial which is the HelloWorld and I have the following done.

HelloWorld.toc
Code:
## Interface: 20100
## Title: Hello World
## Notes: Learning is fun!
## Dependencies:
HelloWorld.lua
HelloWorld.xml
HelloWorld.lua
Code:
function HelloWorld() 
  message("Hello World!"); 
end
HelloWorld.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ 
..\..\FrameXML\UI.xsd"> 
<Frame name="HelloWorldFrame">
	<Scripts>
		<OnLoad>
			HelloWorld();
		</OnLoad>
	</Scripts>
</Frame>
</Ui>
I put all three files in a folder called HelloWorld in the ~/Interface/AddOns/ directory.

The mod shows up in the AddOns screen list of the character selection screen but nothing happens when I enter the game as a character.

One thing that I can't figure out is the UI tag in the xml file. The tutorial references a UI.xsd, but the only UI.xsd I can find is inside "Blizzard Interface Data (enUS)" folder which was created by the AddOns Kit. Am I supposed to be providing the path to that? Am I supposed to have moved the data insided the "Blizzard Interface Data (enUS)" to somewhere inside the "Interface" folder? Or is the one I'm currently using acceptable?
Thanks,

Eric Stewart
  Reply With Quote
06-04-07, 08:37 AM   #2
ericstewart
A Defias Bandit
Join Date: Jun 2007
Posts: 2
I fixed the problem.

There is a line break in the <Ui> tag in the tutorial which should not be there.

Remove the line break so the entire tag is on one line fixes the problem.

Eric Stewart
  Reply With Quote
08-02-07, 10:06 AM   #3
Thalas
A Murloc Raider
Join Date: Aug 2007
Posts: 5
It cant seem to work for me

I'm having the same problem you had, did the same thing and it's still not working
The codes are the same as yours, but it won't work when I log on Wow..
  Reply With Quote
08-02-07, 11:05 AM   #4
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
I cannot test it right now, but I don't think there's a function called "message". Try after replacing
Code:
message("Hello World!");
by
Code:
DEFAULT_CHAT_FRAME:AddMessage("Hello World!")
Edit: Removed the edit which was pretty dumb

Last edited by Layrajha : 08-02-07 at 11:08 AM.
  Reply With Quote
08-02-07, 12:36 PM   #5
Kyahx
A Wyrmkin Dreamwalker
 
Kyahx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 52
I personally think Blizzard's example isn't the best, all of their functions are defined as global (which makes perfect sense for the base UI mind you, just not the best for addons )

http://www.wowwiki.com/UI_Best_Practices -- Has some really good examples of different styles (pure lua and lua + xml). Also explains why locals are faster, and some other nice efficency tips.

For example, the HelloWorld example using pure Lua:
Code:
HelloWorld = CreateFrame("Frame", nil, UIParent)
HelloWorld:RegisterEvent("PLAYER_LOGIN")

HelloWorld:SetScript("OnEvent", function(self, event)
    if event == "PLAYER_LOGIN" then
        self:Enable()
    end
end)

function HelloWorld:Enable()
    DEFAULT_CHAT_FRAME:AddMessage("Hello World!")
end
Both styles are valid mind you, it just comes down to preferance
  Reply With Quote
08-02-07, 01:41 PM   #6
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
Yep, I have to agree with Kyahx here.
The second way might be a tiny little bit harder if you have no experience in Lua, Javascript or any (partially at least) object-oriented language, and you'll need to find out some few things about how Lua works with it from time to time, but it's still better

If you just want to code small addons first to "see how it works", you can just practice WoW's API and Lua's base syntax using code that looks more like Blizzard's (with global variables everywhere and code copy-pasted if two functions do almost the same thing but not exactly, rather than functional programming etc). Blizzard's code is kinda easy to read (I think it's one of their aims, somehow o_O), so you can find "help" there too. Trying to understand how things work by reading Prat or KTM's files would be a loss of time if you don't have a good knowledge yet (well, and those implies Ace2, but addons which are standalone can be just as complicated).
  Reply With Quote
08-02-07, 04:40 PM   #7
Karrion
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Oct 2006
Posts: 23
Originally Posted by Layrajha
I cannot test it right now, but I don't think there's a function called "message".
There is, but if you have "show lua errors" turned off in your interface options, it doesn't actually do anything, because it displays its argument in the error dialog box which is suppressed by that option.
  Reply With Quote
08-03-07, 06:37 AM   #8
Thalas
A Murloc Raider
Join Date: Aug 2007
Posts: 5
That's true, I just marked the Display LUA Errors on the Interface Menu and re-logged for it to work...
Thanks a lot for your help, and Layrajha, thanks for your suggestion up there, but what I wanted was indeed to open a pop up window in WoW, but I'll surely use that for something else... I'm still starting with LUA and stuff so it will take sometime for me to do something decent =P but I intend to ^^
Thanks all for your help =]
  Reply With Quote
08-03-07, 11:35 AM   #9
Layrajha
A Frostmaul Preserver
 
Layrajha's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 275
Depending on what kind of popup you want to show, you should maybe read a bit about "StaticPopup"s, both the HOWTO on wowwiki (search "popup simple dialog boxes", I think), and the StaticPopup.lua file in wow's directory (it gives examples).
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Blizzard's HelloWorld


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