ZONE_CHANGED fires on minor region changes (such as moving from the bank to the AH and the minimap text changes). It doesn't fire on zoning between instances and the world (you would use PLAYER_ENTERING_WORLD for that, or ZONE_CHANGED_NEW_AREA for changing between major zones (where you change chat channels)).
You might have just zoned in and out of say deep run tram and failed to notice.
Noooo... I just tried between the UC auction house ( minimap says "Canals" ) and the UC bank ( minimap says "Trade Quarter" ) and no trigger. I'd just ignore this problem because it's just a sample program but I'm concerned that other things will fail when I get to the real programming.
In order for the "PLAYER_TARGET_CHANGED" to work both the toc and xml files must be correct? Have I left out a semicolon or misspelled something? Color me confused...
The toc and xml files must be correct or Wow will not load the libraries and your addon lua file. The main thing they do is tell wow what to load. If you get the oninitialize message then it's loading. You might want to make sure you are running Bugsack and Buggrabber also so you can see error messages easier.
Arghhhh! My test case was incorrect; ZONE_CHANGED is an outdoors only event. Going from Canals to Bank will not trigger this code. The correct event is ZONE_CHANGED_INDOORS for this test case.
I was doing the tutorial as part of learning about Ace programming, and found the issue that made it not work during the tutorial steps. I made the corrections, so if you try it now, may work for you.
The issue involved a wrong API call. The tutorial has the correct one at the end, but close to the middle when introduced, was wrong. I also add the default profile values to the core.lua code file at the end file which also was missing.
local options = {
type = 'group',
args = {
someopt = {
--code for options
}
--maybe more options
profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
}
}[/quote]
This didn't seem to work for me, because self.db was not set yet. (I have it set in my initialization function.) I assume setting it in the init is the proper way to do things, but I don't really know for sure.
I have the following technically working, but ugly as crap in the addon config window.
[code]
function Tabbins:OnInitialize()
-- Called when the addon is loaded
self.db = LibStub("AceDB-3.0"):New("TabbinsDB", defaults, "Default")
options.args.profile = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db)
LibStub("AceConfig-3.0"):RegisterOptionsTable("Tabbins", options)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Tabbins", "Tabbins")
self:RegisterChatCommand("tabbins", "ChatCommand")
end
What happens is that I get a large box on the left with "Profiles" and another box on the right that allows you to configure them. What I really want, is for "Profiles" to appear under Tabbins, in a tree structure, in the Bliizard Addons window and for the configuration to display like normal once the profiles part is selected. Not sure what I am doing wrong really.
Also, it was mentioned in the ace3 tutorials that you should put your locales in a locales directory, and use a locales.xml file to load them so that other people will/can not have access to your .toc file and base directory. I tied this, but blew things up. So I was wondering if anyone had a basic template for an enUS.lua and locale.xml loading from a sub-directory.
IMO it's a glitch with the way they implemented the "AddToBlizOptions", but what your seeing is expected. You have to individually add each options table set to the BlizOptions window in order to get it to look like how your describing.
IMO it's a glitch with the way they implemented the "AddToBlizOptions", but what your seeing is expected. You have to individually add each options table set to the BlizOptions window in order to get it to look like how your describing.
A glitch would imply a bug, which it is not. You can pass a sub-path argument to the AddToBlizzOptions call and add multiple sub-tables without creating them individually.
A glitch would imply a bug, which it is not. You can pass a sub-path argument to the AddToBlizzOptions call and add multiple sub-tables without creating them individually.
Can you please post a simple example of how to do this? I've been digging through the Lua of Omen, Bartender, Button Facae, etc. trying to figure out how, and reminded myself what I don't like about LUA. Everyone has their own style/syntax and its like smashing your face into a brick wall when trying to figure out how someone did something.
This would register one parent entry "DisplayName" and 3 sub-entrys under that parent entry.
If you need to go deeper in the path of the option table, you can do so as well, just pass more keys as required.
Syntax of AddToBlizOptions is:
table_name - Name of the Options Table (as passed to AceConfig/AceConfigRegistry)
display_name - String to be Displayed in the Blizzard Tree (defaults to table_name)
parent_name - display_name of the parent, if any.
path - List of keys that specify the path in the options table.
ACD:AddToBlizOptions(table_name, display_name, parent_name, path, ...)
Thanks, it still took me a bit since my lua skills are very rusty. Between the example and some more poking around in Button Facade, I was able to get it working so far. Now to flesh out the options panel. ^.^
I'm hoping it's easy to do things like I see in the Omen panel like:
[drop down|V] [X] Check Box1
[_] Check box2 [_] Check box3
Also, hoping it's relatively easy to add inline elements, like Baggins does for adding rules/categores/bags.
but it's only just an exact copy of the code that's at the end of the tutorial. It wasn't working through the progression of the tutorial so i just decided to copy and paste the final code to see if that worked...but nothing..=(
Delete that line:
if GetBindLocation() == GetSubZoneText() then
That if statement only works when using your heart stone to actually go home.
Here is the correct full code:
WelcomeHome = LibStub("AceAddon-3.0"):NewAddon("WelcomeHome", "AceConsole-3.0", "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("WelcomeHome")
local options = {
name = "WelcomeHome",
handler = WelcomeHome,
type = 'group',
args = {
msg = {
type = 'input',
name = L['Message'],
desc = L['The message to be displayed when you get home.'],
usage = L['<Your message>'],
get = 'GetMessage',
set = 'SetMessage',
},
showInChat = {
type = 'toggle',
name = L['Show in Chat'],
desc = L['Toggles the display of the message in the chat window.'],
get = 'IsShowInChat',
set = 'ToggleShowInChat',
},
showOnScreen = {
type = 'toggle',
name = L['Show on Screen'],
desc = L['Toggles the display of the message on the screen.'],
get = 'IsShowOnScreen',
set = 'ToggleShowOnScreen',
},
},
}
local defaults = {
profile = {
message = L["Welcome Home!"],
showInChat = true,
showOnScreen = true,
},
}
function WelcomeHome:OnInitialize()
-- Called when the addon is loaded
self.db = LibStub("AceDB-3.0"):New("WelcomeHomeDB", defaults, "Default")
LibStub("AceConfig-3.0"):RegisterOptionsTable("WelcomeHome", options, [COLOR="Red"]{"wh", "WelcomeHome"}[/COLOR])
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("WelcomeHome", "WelcomeHome")
self:RegisterChatCommand("wh", "ChatCommand")
self:RegisterChatCommand("welcomehome", "ChatCommand")
end
function WelcomeHome:OnEnable()
-- Called when the addon is enabled
self:Print("OnEnabled Called with Zone")
self:RegisterEvent("ZONE_CHANGED")
end
function WelcomeHome:ZONE_CHANGED()
if self.db.profile.showInChat then
self:Print(self.db.profile.message)
end
if self.db.profile.showOnScreen then
UIErrorsFrame:AddMessage(self.db.profile.message, 1.0, 1.0, 1.0, 5.0)
end
end
function WelcomeHome:ChatCommand(input)
if not input or input:trim() == "" then
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
else
LibStub("AceConfigCmd-3.0").HandleCommand(WelcomeHome, "wh", "WelcomeHome", input)
end
end
function WelcomeHome:GetMessage(info)
return self.db.profile.message
end
function WelcomeHome:SetMessage(info, newValue)
self.db.profile.message = newValue
end
function WelcomeHome:IsShowInChat(info)
return self.db.profile.showInChat
end
function WelcomeHome:ToggleShowInChat(info, value)
self.db.profile.showInChat = value
end
function WelcomeHome:IsShowOnScreen(info)
return self.db.profile.showOnScreen
end
function WelcomeHome:ToggleShowOnScreen(info, value)
self.db.profile.showOnScreen = value
end
See the part I highligted in red color? that's what was missing in order for the chat command to actually work, you have to add them when you register you options table. I also found that the if statement at the beginning of the WelcomeHome:ZONED_CHANGED() was not needed, and caused the addon to not work, so no zone changing was detected at all. Now it should work.
And change the ##Interface: 30000 to 40000 in the toc file, so the addon won't trigger an outdated statement to the WoW engine. Don't forget to change it to 40100 when the 4.1.0 patch gets released.
Here is a variant that prints the location in the chat and on the screen. I took out the 'message' option and instead print a greetings message when you enter in any zone.
WelcomeHome = LibStub("AceAddon-3.0"):NewAddon("WelcomeHome", "AceConsole-3.0", "AceEvent-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("WelcomeHome")
local options = {
name = "WelcomeHome",
handler = WelcomeHome,
type = 'group',
args = {
showInChat = {
type = 'toggle',
name = L['Show in Chat'],
desc = L['Toggles the display of the message in the chat window.'],
get = 'IsShowInChat',
set = 'ToggleShowInChat',
},
showOnScreen = {
type = 'toggle',
name = L['Show on Screen'],
desc = L['Toggles the display of the message on the screen.'],
get = 'IsShowOnScreen',
set = 'ToggleShowOnScreen',
},
},
}
local defaults = {
profile = {
showInChat = true,
showOnScreen = true,
},
}
function WelcomeHome:OnInitialize()
-- Called when the addon is loaded
self.db = LibStub("AceDB-3.0"):New("WelcomeHomeDB", defaults, "Default")
LibStub("AceConfig-3.0"):RegisterOptionsTable("WelcomeHome", options, {"wh", "WelcomeHome"})
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("WelcomeHome", "WelcomeHome")
self:RegisterChatCommand("wh", "ChatCommand")
self:RegisterChatCommand("welcomehome", "ChatCommand")
end
function WelcomeHome:OnEnable()
-- Called when the addon is enabled
self:Print("OnEnabled Called with Zone")
self:RegisterEvent("ZONE_CHANGED")
self:RegisterEvent("ZONE_CHANGED_INDOORS")
end
function WelcomeHome:ZONE_CHANGED()
-- Prints a welcome to <subzone> : <mainzone> message
if GetSubZoneText() ~= "" then
if self.db.profile.showInChat then
self:Print("Bienvenue à" .. " " .. GetSubZoneText() .. " : " .. GetRealZoneText())
end
if self.db.profile.showOnScreen then
UIErrorsFrame:AddMessage(("Bienvenue à" .. " " .. GetSubZoneText() .. " : " .. GetRealZoneText()), 1.0, 1.0, 1.0, 5.0)
end
end
-- Print only the mainzone if GetZubZone returns nothing
if GetSubZoneText() == "" then
if self.db.profile.showInChat then
self:Print("Bienvenue à" .. " " .. GetRealZoneText())
end
if self.db.profile.showOnScreen then
UIErrorsFrame:AddMessage(("Bienvenue à" .. " " .. GetRealZoneText()), 1.0, 1.0, 1.0, 5.0)
end
end
end
function WelcomeHome:ZONE_CHANGED_INDOORS()
-- prints the welcome message when entering a city, or an indoor zone
if self.db.profile.showInChat then
self:Print("Bienvenue à" .. " " .. GetMinimapZoneText() .. " : " .. GetRealZoneText())
end
if self.db.profile.showOnScreen then
UIErrorsFrame:AddMessage(("Bienvenue à" .. " " .. GetMinimapZoneText() .. " : " .. GetRealZoneText()), 1.0, 1.0, 1.0, 5.0)
end
end
function WelcomeHome:ChatCommand(input)
if not input or input:trim() == "" then
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
else
LibStub("AceConfigCmd-3.0").HandleCommand(WelcomeHome, "wh", "WelcomeHome", input)
end
end
function WelcomeHome:IsShowInChat(info)
return self.db.profile.showInChat
end
function WelcomeHome:ToggleShowInChat(info, value)
self.db.profile.showInChat = value
end
function WelcomeHome:IsShowOnScreen(info)
return self.db.profile.showOnScreen
end
function WelcomeHome:ToggleShowOnScreen(info, value)
self.db.profile.showOnScreen = value
end
That version prints the subzone followed by the main zone in the chat and on screen. I added comments to describe what the if statements do.
WelcomeHome = LibStub("AceAddon-3.0"):NewAddon("WelcomeHome", "AceConsole-3.0", "AceEvent-3.0")
function WelcomeHome:OnInitialize()
-- Called when the addon is loaded
end
function WelcomeHome:OnEnable()
-- Called when the addon is enabled
self:RegisterEvent("ZONE_CHANGED")
end
function WelcomeHome:ZONE_CHANGED()
self:Print("Du hast die Zone gewechselt!")
end
Lua Error-Message in WoW
Message: Interface\AddOns\WelcomeHome\Core.lua:1: Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of "AceEvent-3-0".
Time: 10/25/11 10:38:53
Count: 1
Stack: [C]: ?
...ddOns\WelcomeHome\Libs\AceAddon-3.0\AceAddon-3.0.lua:210: in function `EmbedLibrary'
...ddOns\WelcomeHome\Libs\AceAddon-3.0\AceAddon-3.0.lua:192: in function `EmbedLibraries'
...ddOns\WelcomeHome\Libs\AceAddon-3.0\AceAddon-3.0.lua:159: in function `NewAddon'
Interface\AddOns\WelcomeHome\Core.lua:1: in main chunk
Locals: (*temporary) = "Usage: EmbedLibrary(addon, libname, silent, offset): 'libname' - Cannot find a library instance of "AceEvent-3-0"."
off-topic, but can we also just link to e.g. the online FrameXML browsers/repositories in our XML files
No. I don't think WoW even cares about the xmlns attribute (I've seen plenty of addons that don't include it but do, presumably, work just fine), but if it does, Blizzard certainly would not let you point it to random third-party URLs.
My Addon don't want save the Settings, when I change the both msg's (hmsg and vmsg).
Here is my Core.lua
WelcomeHome = LibStub("AceAddon-3.0"):NewAddon("WelcomeHome", "AceConsole-3.0", "AceEvent-3.0")
----------------------------------------
-- Main
----------------------------------------
local options = {
name = "WelcomeHome",
handler = WelcomeHome,
type = "group",
args = {
-- Enter Home Option
hmsg = {
type = "input",
name = "At Home",
desc = "Message when you enter your home.",
usage = "<Your message>",
get = "Get_hmsg",
set = "Set_hmsg",
},
-- Leave Home Option
vmsg = {
type = "input",
name = "Leave Home",
desc = "Message if you leave your home.",
usage = "<Your message>",
get = "Get_vmsg",
set = "Set_vmsg",
},
-- ShowInChat Option
showInChat = {
type = "toggle",
name = "Show in Chat",
desc = "Toggles the display of the message in the chat window.",
get = "IsShowInChat",
set = "ToggleShowInChat",
},
-- ShowOnChat Option
showOnScreen = {
type = "toggle",
name = "Show on Screen",
desc = "Toggles the display of the message on the screen.",
get = "IsShowOnScreen",
set = "ToggleShowOnScreen"
},
},
}
----------------------------------------
-- Default Settings
----------------------------------------
local defaults = {
profile = {
message = "Welcome....!", -- Message = At Home
message2 = "Good Bye....!", -- Message2 = Leave Home
showInChat = false,
showOnScreen = true,
},
}
----------------------------------------
-- Addon Standard
----------------------------------------
function WelcomeHome:OnInitialize()
-- Called when the addon is loaded
self.db = LibStub("AceDB-3.0"):New("WelcomeHomeDB", defaults, "Default")
LibStub("AceConfig-3.0"):RegisterOptionsTable("WelcomeHome", options)
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("WelcomeHome", "WelcomeHome")
self:RegisterChatCommand("wh", "ChatCommand")
self:RegisterChatCommand("welcomehome", "ChatCommand")
end
function WelcomeHome:OnEnable()
-- Called when the addon is enabled
self:Print("...loaded! .:: Version: Alpha 0.1 ::." )
self:RegisterEvent("ZONE_CHANGED")
end
----------------------------------------
-- Event Handler For Zone/Message
----------------------------------------
function WelcomeHome:ZONE_CHANGED()
-- When Home Entered
if GetBindLocation() == GetSubZoneText() then
if self.db.profile.showInChat then
self:Print(self.db.profile.message)
end
if self.db.profile.showOnScreen then
UIErrorsFrame:AddMessage(self.db.profile.message, 1.0, 1.0, 1.0, 5.0)
end
-- When Leave Home
else if self.db.profile.showInChat then
self:Print(self.db.profile.message2)
end
if self.db.profile.showOnScreen then
UIErrorsFrame:AddMessage(self.db.profile.message2, 1.0, 1.0, 1.0, 5.0)
end
end
end
----------------------------------------
-- Addon To BlizzAddons
----------------------------------------
function WelcomeHome:ChatCommand(input)
if not input or input:trim() == "" then
InterfaceOptionsFrame_OpenToCategory(self.optionsFrame)
else
LibStub("AceConfigCmd-3.0").HandleCommand(WelcomeHome, "wh", "WelcomeHome", input)
end
end
----------------------------------------
-- Display: hmsg/vmsg
----------------------------------------
-- At Home : hmsg
function WelcomeHome:Get_hmsg(info)
return self.db.profile.message
end
function WelcomeHome:Set_hmsg(info, newValue)
self.db.profile.message = newValue
end
-- Leave Home : vmsg
function WelcomeHome:Get_vmsg(info)
return self.db.profile.message2
end
function WelcomeHome:Set_vmsg(info, newValue)
self.db.profile.message2 = newValue
end
-- hmsg In Chat/On Screen
function WelcomeHome:IsShowInChat(info)
return self.db.profile.showInChat
end
function WelcomeHome:ToggleShowInChat(info, value)
self.db.profile.showInChat = value
end
function WelcomeHome:IsShowOnScreen(info)
return self.db.profile.showOnScreen
end
function WelcomeHome:ToggleShowOnScreen(info, value)
self.db.profile.showOnScreen = value
end
-- vmsg In Chat/On Screen
function WelcomeHome:IsShowInChat(info)
return self.db.profile.showInChat
end
function WelcomeHome:ToggleShowInChat(info, value)
self.db.profile.showInChat = value
end
function WelcomeHome:IsShowOnScreen(info)
return self.db.profile.showOnScreen
end
function WelcomeHome:ToggleShowOnScreen(info, value)
self.db.profile.showOnScreen = value
end
No. I don't think WoW even cares about the xmlns attribute (I've seen plenty of addons that don't include it but do, presumably, work just fine), but if it does, Blizzard certainly would not let you point it to random third-party URLs.
ehmm I meant the xsi:schemaLocation attribute instead of the xmlns attribute
since blizzard doesn't provide an online mirror themselves (except for the outdated download), wouldn't it still be better to just point straight to the third-party URLs?
and as far as I can see, nobody seems to really care about it ..
Can you please post a simple example of how to do this? I've been digging through the Lua of Omen, Bartender, Button Facae, etc. trying to figure out how, and reminded myself what I don't like about LUA. Everyone has their own style/syntax and its like smashing your face into a brick wall when trying to figure out how someone did something.
Immediately after the post you quoted, Nevcairiel answered the question in great detail, with multiple example code snippets. If there was some part of his answer you didn't understand, please be more specific about what question(s) you still have.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
ZONE_CHANGED fires on minor region changes (such as moving from the bank to the AH and the minimap text changes). It doesn't fire on zoning between instances and the world (you would use PLAYER_ENTERING_WORLD for that, or ZONE_CHANGED_NEW_AREA for changing between major zones (where you change chat channels)).
You might have just zoned in and out of say deep run tram and failed to notice.
In order for the "PLAYER_TARGET_CHANGED" to work both the toc and xml files must be correct? Have I left out a semicolon or misspelled something? Color me confused...
The issue involved a wrong API call. The tutorial has the correct one at the end, but close to the middle when introduced, was wrong. I also add the default profile values to the core.lua code file at the end file which also was missing.
Also, it was mentioned in the ace3 tutorials that you should put your locales in a locales directory, and use a locales.xml file to load them so that other people will/can not have access to your .toc file and base directory. I tied this, but blew things up. So I was wondering if anyone had a basic template for an enUS.lua and locale.xml loading from a sub-directory.
A glitch would imply a bug, which it is not. You can pass a sub-path argument to the AddToBlizzOptions call and add multiple sub-tables without creating them individually.
Can you please post a simple example of how to do this? I've been digging through the Lua of Omen, Bartender, Button Facae, etc. trying to figure out how, and reminded myself what I don't like about LUA. Everyone has their own style/syntax and its like smashing your face into a brick wall when trying to figure out how someone did something.
You would then register the full table as usual, but your AddToBlizz calls would look like this:
This would register one parent entry "DisplayName" and 3 sub-entrys under that parent entry.
If you need to go deeper in the path of the option table, you can do so as well, just pass more keys as required.
Syntax of AddToBlizOptions is:
I'm hoping it's easy to do things like I see in the Omen panel like:
[drop down|V] [X] Check Box1
[_] Check box2 [_] Check box3
Also, hoping it's relatively easy to add inline elements, like Baggins does for adding rules/categores/bags.
Your help is much appreciated though.
Delete that line:
That if statement only works when using your heart stone to actually go home.
Here is the correct full code:
See the part I highligted in red color? that's what was missing in order for the chat command to actually work, you have to add them when you register you options table. I also found that the if statement at the beginning of the WelcomeHome:ZONED_CHANGED() was not needed, and caused the addon to not work, so no zone changing was detected at all. Now it should work.
And change the ##Interface: 30000 to 40000 in the toc file, so the addon won't trigger an outdated statement to the WoW engine. Don't forget to change it to 40100 when the 4.1.0 patch gets released.
Here is a variant that prints the location in the chat and on the screen. I took out the 'message' option and instead print a greetings message when you enter in any zone.
That version prints the subzone followed by the main zone in the chat and on screen. I added comments to describe what the if statements do.
Core.lua
Lua Error-Message in WoW
Edit: Problem Found
I had in the embeds.xml this line wrong(line1):
Wrong
Works
You don't have AceEvent-3.0 referenced for loading.
I googled some links on it, but I didn't really understand what is the proper way to link to the UI.xsd >:(
http://www.w3schools.com/schema/schema_schema.asp
http://www.w3.org/TR/xmlschema-0/#schemaLocation
http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/datatypes.html#anyURI
Otherwise, I'm also wondering which way would be the right way do it. With or without a newline??
No. I don't think WoW even cares about the xmlns attribute (I've seen plenty of addons that don't include it but do, presumably, work just fine), but if it does, Blizzard certainly would not let you point it to random third-party URLs.
My Addon don't want save the Settings, when I change the both msg's (hmsg and vmsg).
Here is my Core.lua
ehmm I meant the xsi:schemaLocation attribute instead of the xmlns attribute
since blizzard doesn't provide an online mirror themselves (except for the outdated download), wouldn't it still be better to just point straight to the third-party URLs?
and as far as I can see, nobody seems to really care about it ..
I couldn't find anything weird, are you sure you properly defined the SavedVariables in the .TOC?
I could not agree more