sTotal noob question
Hi all,
I'm having some difficulties getting into writing an addon. It seems that the APIs aren't really documented in any one place - I've tried wowprogramming, wowhead, wowwiki, and just not sure if there's a 'definitive' description available. I'm trying to get past the "Hello, world" coding, and just get something as simple as the current player's mana, etc. I try something like: Code:
local powerType, powerToken = UnitPowerType("player"); If I try calling and then printing the value of UnitPower("player"), I always end up with 0 being output. I'm not sure if I'm missing something very obvious, or what. If anyone has some suggestions, or even a helpful smack upside the head, I'd appreciate it! |
Maybe this will help a little: WoWPedia: Interface Customization Portal
|
The API is as fully documented as it can get, being put there and updated only by authors like us. I use wowpedia and wowprogramming, myself.
If you are looking for information on the Lua language itself, then you need to go to lua.org and read through the PIL: http://www.lua.org/manual/5.1/ |
The WoW API tries to run in an object-oriented approach, in which UI objects generate events to be handled by registered functions called handlers. Frame events will be called by this name to differentiate from data events that fire through the "OnEvent" handler. It is common for data functions in the WoW API to not have valid data until after a specific event related to the function has fired.
In this example, we'll have the code wait until after the PLAYER_LOGIN event fires before printing out our info. lua Code:
Information is only as good as a person's understanding of it. |
Hey there,
Thanks very much for your responses - I appreciate it! I understood that the functions are executed based on events (which your addon needs to register for). I just had my function get called when the "OnLoad" event happened. I was just surprised when 0 was always returned by the UnitPower() calls. I'll keep poking around and looking at more examples, and at the sites that you listed. Thanks again! |
Quote:
either way, OnLoad doesnt refer to the client or the game as being loaded, just your addon. http://www.wowpedia.org/Events_that_...oading_Process Try using wowpedia.org over wowwiki... wowwiki moved to wowpedia when the hosting wiki site overloaded the site with ads and forced a certain formatting style to non registered users, which was some white thingy, and a lot of people didnt like that. |
All times are GMT -6. The time now is 04:44 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI