I made a mistake. Seeing you suggested PLAYER_LOGIN as event, I changed the code because I run it after login. Using wowlua.
...but there is no 'self', when the code is not a part of MyAddOn ('member' function).
Thanks for the comments, Phanx especially. Very nice of you to take the time.
I ran the script Phanx wrote using the wowlua addon and had some problems:
"attempt to index global 'self' (a nil value)"
I suppose that means that self isn't defined or initialized with MyAddOn, and I just changed 'self' to MyAddOn, and it works.
Phanx;271627]Why are you polluting the global namespace by creating a frame in XML? :(
When I saw your sad smily I just knew something was wrong.
I've no intentions of putting the addon on curse just yet, or anytime at all, so only I will have to endure the pollution, but I'm currious about something. As long as I give my frame a uniq name, like prefixing it with the modname, it shouldn't be a problem, right? I read on wowwiki, that I should use xml frames for static frames and createframe() for dynamic frames. Is that not correct?
Also, embeds.xml is for referencing libraries. If you really need to do other stuff in XML (which you don't) make a separate file.
I moved the xml frame to another file. Trying to call it before it was defined did not work! :D
Also, your frame is shown by default, so the :Show() call does nothing, but you didn't add any properties to it that would make it visually apparent, so it's invisible.
This comment saved me. I did think the button was visible, but it wasn't before it inheritede from OptionsButtonTemplate. Not even when the text attribute was set in the button element.
function MyAddon:OnInitialize()
-- Code that you want to run when the addon is first loaded goes here.
-- AceConsole used as a mixin for AceAddon
-- MyAddon:Print("Hello, world!")
MyAddon_Frame:Show()
end
function MyAddon:OnEnable()
-- Called when the addon is enabled
-- Hook the event ZONE_CHANGED to know when the game character enters a new zone.
self:RegisterEvent("ZONE_CHANGED")
MyAddon_Frame:Show()
end
function MyAddon:OnDisable()
-- Called when the addon is disabled
end
function MyAddon:ZONE_CHANGED()
-- Event handler for ZONE_CHANGED.
self:Print("You have changed zones!")
if GetBindLocation() == GetSubZoneText() then
self:Print("Welcome Home!")
end
end
This morning I read through: http://old.wowace.com/wiki/WelcomeHome_-_Your_first_Ace3_Addon. It has a lot of info for me at this point on my learning curve. One thing I would like to know more about is user interface. The addon in the mentioned article uses UIErrorsFrame to display a message.
Does Ace3 have a UI library I should use, or maybe someone can guide me to another article about making a UI and hooking it with my addon code?
To begin with I'm just going to have an area for text output and a few buttons. Later on I'll have a bar to be filled up from the buttom: The more mobs killed, the more blood in the bar.
Also, I read a bit about unitframes. It seems that the projects I came across are ment to replace blizzards UI. But I just need to add a little, so instead of digging to deep into those projects I ask here.
Thx jerry - very helpful. I now have bugbag and !buggrabber.
After correcting the order of embed.xml and main.luz in vampyr.toc I get this error from bugbag:
2009/03/31 19:52:12-1-x1]: Vampyr-0.1\main.lua:7: attempt to call method 'Print' (a nil value)
(tail call): ?:
<in C code>: ?
<string>:"safecall Dispatcher[1]":9: in function <[string "safecall Dispatcher[1]"]:5>
(tail call): ?:
AceAddon-3.0-5 (BugSack):340: in function `InitializeAddon'
AceAddon-3.0-5 (BugSack):428: in function <...ce\AddOns\BugSack\Libs\AceAddon-3.0\AceAddon-3.0.lua:421>
so maybe I didn't mixin the library with the Print("string") function. I'll have to check on that now.
Edit: yes, it works with this line instead:
MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceConsole-3.0")
No effect. I was hopping to see: Hello, world!
in the chat window.
I'm guessing OnInitialize() happens to early, and that maybe the chat window isn't ready at that time.
Hi I just started as well, and maybe we can benefit from each others learnings... maybe :)
Anyways, here is what I'm doing.
I'm using Notepad++ as my editor.
My addon will be named Vampyr - vampire in danish. It's going to add some flavor to my guilds play, giving humorous reminders for vampires.
As I start to write my addon I'm going to make mistakes and syntax errors. Having to start wow over every time I make a code change will be a hassel, and I hope to get some improved debugging help using Ace3. Perhaps even be able to reload the addon while wow is running. Can I do that?
CODE:
My first code will be in three files and a sub folder with libraries.
Vampyr.toc, main.xml and main.lua
0
...but there is no 'self', when the code is not a part of MyAddOn ('member' function).
0
I ran the script Phanx wrote using the wowlua addon and had some problems:
"attempt to index global 'self' (a nil value)"
I suppose that means that self isn't defined or initialized with MyAddOn, and I just changed 'self' to MyAddOn, and it works.
Thanks again.
0
When I saw your sad smily I just knew something was wrong.
I've no intentions of putting the addon on curse just yet, or anytime at all, so only I will have to endure the pollution, but I'm currious about something. As long as I give my frame a uniq name, like prefixing it with the modname, it shouldn't be a problem, right? I read on wowwiki, that I should use xml frames for static frames and createframe() for dynamic frames. Is that not correct?
I moved the xml frame to another file. Trying to call it before it was defined did not work! :D
This comment saved me. I did think the button was visible, but it wasn't before it inheritede from OptionsButtonTemplate. Not even when the text attribute was set in the button element.
0
Vampyr.toc
embeds.xml
main.lua
0
Does Ace3 have a UI library I should use, or maybe someone can guide me to another article about making a UI and hooking it with my addon code?
To begin with I'm just going to have an area for text output and a few buttons. Later on I'll have a bar to be filled up from the buttom: The more mobs killed, the more blood in the bar.
Also, I read a bit about unitframes. It seems that the projects I came across are ment to replace blizzards UI. But I just need to add a little, so instead of digging to deep into those projects I ask here.
0
Thx. I've corrected that in my initial post. main.xml is not used just embed.xml
0
0
After correcting the order of embed.xml and main.luz in vampyr.toc I get this error from bugbag:
2009/03/31 19:52:12-1-x1]: Vampyr-0.1\main.lua:7: attempt to call method 'Print' (a nil value)
(tail call): ?:
<in C code>: ?
<string>:"safecall Dispatcher[1]":9: in function <[string "safecall Dispatcher[1]"]:5>
(tail call): ?:
AceAddon-3.0-5 (BugSack):340: in function `InitializeAddon'
AceAddon-3.0-5 (BugSack):428: in function <...ce\AddOns\BugSack\Libs\AceAddon-3.0\AceAddon-3.0.lua:421>
so maybe I didn't mixin the library with the Print("string") function. I'll have to check on that now.
Edit: yes, it works with this line instead:
MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "AceConsole-3.0")
0
in the chat window.
I'm guessing OnInitialize() happens to early, and that maybe the chat window isn't ready at that time.
0
Anyways, here is what I'm doing.
I'm using Notepad++ as my editor.
My addon will be named Vampyr - vampire in danish. It's going to add some flavor to my guilds play, giving humorous reminders for vampires.
As I start to write my addon I'm going to make mistakes and syntax errors. Having to start wow over every time I make a code change will be a hassel, and I hope to get some improved debugging help using Ace3. Perhaps even be able to reload the addon while wow is running. Can I do that?
CODE:
My first code will be in three files and a sub folder with libraries.
Vampyr.toc, main.xml and main.lua
Vampyr.toc:
## Interface: 30000
## Title: Vampyre
## Notes: Vampire addon
## Author: Gretter1
## Version: 0.1
embeds.xml:
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="Libs\LibStub\LibStub.lua"/>
<Include file="Libs\AceAddon-3.0\AceAddon-3.0.xml"/>
<Include file="Libs\AceConsole-3.0\AceConsole-3.0.xml"/>
</Ui>
main.lua:
MyAddon = LibStub("AceAddon-3.0"):NewAddon("MyAddon")
function MyAddon:OnInitialize()
-- Code that you want to run when the addon is first loaded goes here.
-- AceConsole used as a mixin for AceAddon
MyAddon:Print("Hello, world!")
end
function MyAddon:OnEnable()
-- Called when the addon is enabled
end
function MyAddon:OnDisable()
-- Called when the addon is disabled
end
And now I'll go try it out... see if it does anything.
btw. The code I got from here:
http://www.wowace.com/projects/ace3/pages/getting-started/
oh.. and in the Libs folder are alle the files form the latest ace3 beta release.