Not Amused
Join Date: Nov 2010
Posts: 96
|
Originally Posted by Phanx
You probably won't find much on that topic in anything WoW-specific, as tables are simply part of the Lua programming language, like functions and variables.
|
Thanks for the links!
Originally Posted by Phanx
I need to go run some errands, but I'll look at the actual code when I get back.
|
Still no print messages. Everything else is peachy:
Code:
local messages = {
["FEAST"] = "{rt1} %s has cooked %s",
["MOUNT"] = "%s has cast %s",
["PORTAL"] = "{rt1} %s has opened a %s {rt1}",
["REPAIR"] = "{rt1} %s has placed %s {rt1}",
["SPELL"] = "{rt1} %s has created %s {rt1}",
["SOULWELL"] = "{rt1} %s has cast %s {rt1}",
["TABLE"] = "{rt1} %s has cast %s {rt1}",
["LIGHTWELL"] = "{rt1} %s has cast %s {rt1}",
}
local messagesSelf = {
["FEAST"] = "%s here!",
["MOUNT"] = "%s here!",
["PORTAL"] = "%s here!",
["REPAIR"] = "%s here!",
["SPELL"] = "%s here!",
["SOULWELL"] = "%s here!",
["TABLE"] = "Mage cookies here!",
["LIGHTWELL"] = "%s here!",
}
local spells = {
-- ENGINEERING/PROFESSION ITEMS
[67826] = "SPELL", -- Jeeves
[54711] = "SPELL", -- Scrapbot
[22700] = "SPELL", -- Field Repair Bot 74A
[44389] = "SPELL", -- Field Repair Bot 110G
[127129] = "SPELL", -- Blingtron 4000
[126459] = "SPELL", -- Blingtron 4000
[54710] = "SPELL", -- MOLL-E
[126462] = "SPELL", -- Thermal Anvil
-- SPELLS
[92824] = "SPELL", -- Ritual of Refreshment
[43987] = "SPELL", -- Refreshment Portal
[698] = "SPELL", -- Ritual of Summoning
[29893] = "SOULWELL", -- Ritual of Souls (Soulwell)
[126135] = "LIGHTWELL", -- Lightwell
[724] = "LIGHTWELL", -- Lightwell (Glyphed)
-- MOUNTS (for testing prposes)
[75973] = "MOUNT", -- X-53 Touring Rocket
-- GUILD MISC
[83958] = "SPELL", -- Mobile Banking
[92396] = "SPELL", -- Guild Page (Horde)
[92395] = "SPELL", -- Guild Page (Alliance)
[92398] = "SPELL", -- Guild Herald (Horde)
[92397] = "SPELL", -- Guild Herald (Alliance)
[90633] = "SPELL", -- Battle Standard of Coordination
[90631] = "SPELL", -- Battle Standard of Coordination
--VANITY/TCG ITEMS/MISC
[42753] = "FEAST", -- Goblin Gumbo Kettle
[45103] = "FEAST", -- Romantic Picnic Basket
--CAULDRONS
[92649] = "FEAST", -- Cauldron of Battle
[92712] = "FEAST", -- Big Cauldron of Battle
[41458] = "FEAST", -- Cauldron of Major Arcane Protection
[41500] = "FEAST", -- Cauldron of Major Fire Protection
[41501] = "FEAST", -- Cauldron of Major Frost Protection
--FEASTS/BANQUETS/NOODLE CARTS
[104958] = "FEAST", -- Pandaren Banquet
[126492] = "FEAST", -- Banquet of the Grill
[126494] = "FEAST", -- Great Banquet of the Grill
[126501] = "FEAST", -- Banquet of the Oven
[126502] = "FEAST", -- Great Banquet of the Oven
[126504] = "FEAST", -- Great Banquet of the Brew
[126498] = "FEAST", -- Great Banquet of the Pot
[126500] = "FEAST", -- Great Banquet of the Steamer
[126496] = "FEAST", -- Great Banquet of the Wok
[105193] = "FEAST", -- Great Pandaren Banquet
[126503] = "FEAST", -- Banquet of the Brew
[126497] = "FEAST", -- Banquet of the Pot
[126499] = "FEAST", -- Banquet of the Steamer
[126495] = "FEAST", -- Banquet of the Wok
[87915] = "FEAST", -- Goblin Barbecue Feast
[87916] = "FEAST", -- Goblin Barbecue Feast
[87644] = "FEAST", -- Seafood Magnifique Feast
[87643] = "FEAST", -- Broiled Dragon Feast
[146936] = "FEAST", -- Noodle Cart
[146933] = "FEAST", -- Noodle Cart
[146937] = "FEAST", -- Deluxe Noodle Cart
[145169] = "FEAST", -- Deluxe Noodle Cart
[146938] = "FEAST", -- Pandaren Treasure Noodle Cart
[57426] = "FEAST", -- Fish Feast
[57301] = "FEAST", -- Great Feast
-- MAGE PORTALS
[10059] = "PORTAL", -- STORMWIND PORTAL
[11416] = "PORTAL", -- IRONFORGE PORTAL
[11417] = "PORTAL", -- ORGRIMMAR PORTAL
[11418] = "PORTAL", -- UNDERCITY PORTAL
[11419] = "PORTAL", -- DARNASSUS PORTAL
[11420] = "PORTAL", -- THUNDER BLUFF PORTAL
[32266] = "PORTAL", -- EXODAR PORTAL
[32267] = "PORTAL", -- SILVERMOON PORTAL
[33691] = "PORTAL", -- SHATTRATH PORTAL
[35717] = "PORTAL", -- SHATTRATH PORTAL
[49360] = "PORTAL", -- THERAMORE PORTAL
[49361] = "PORTAL", -- STONARD PORTAL
[53142] = "PORTAL", -- DALARAN PORTAL
[88345] = "PORTAL", -- TOL BARAD PORTAL
[88346] = "PORTAL", -- TOL BARAD PORTAL
[120146] = "PORTAL", -- ANCIENT DALARAN PORTAL
[132620] = "PORTAL", -- VALE OF ETERNAL BLOSSOMS PORTAL
[132626] = "PORTAL", -- VALE OF ETERNAL BLOSSOMS PORTAL
}
------------------------------------------------------------------------
-- VARIABLES
local ADDON_NAME, namespace = ...
local db
local lastAnnounced = {}
------------------------------------------------------------------------
-- ADDON
local Addon = CreateFrame("Frame", ADDON_NAME)
Addon:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
Addon:RegisterEvent("ADDON_LOADED")
function Addon:Print(message)
DEFAULT_CHAT_FRAME:AddMessage("|cff7f7fff[Conjured Announcer]|r " .. message)
end
function Addon:AnnounceSpell(unit, spellID, spellName)
local spellLink = "|cff71d5ff|Hspell:"..spellID.."|h["..spellName.."]|h|r"
local message
if UnitIsUnit("player", unit) then
message = format(messagesSelf[ spells[spellID] ], spellLink)
else
message = format(messages[ spells[spellID] ], (UnitName(unit)), spellLink)
end
local now = GetTime()
if (lastAnnounced[message] or 0) > (now - 5) then return end
lastAnnounced[message] = now
local channel
if db.raidWarning and IsInRaid() and (UnitIsGroupLeader("player") or UnitIsGroupAssistant("player")) then
channel = "RAID_WARNING"
elseif IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
channel = "INSTANCE_CHAT"
elseif IsInRaid() and not db.partyInRaid then
channel = "RAID"
elseif IsInGroup() then
channel = "PARTY"
else if db.printSolo then
self:print(message)
end
return
end
SendChatMessage(message, channel)
end
------------------------------------------------------------------------
-- EVENT HANDLERS
function Addon:ADDON_LOADED(name)
if name ~= ADDON_NAME then return end
if not ConjuredAnnouncerDB then
ConjuredAnnouncerDB = {
enabled = true,
partyInRaid = false,
raidWarning = true,
}
self:Print("Welcome! Type /can for options.")
end
db = ConjuredAnnouncerDB
self:RegisterEvent("GROUP_ROSTER_UPDATE")
end
function Addon:GROUP_ROSTER_UPDATE()
if db.enabled and IsInGroup() then
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
else
self:UnregisterEvent("UNIT_SPELLCAST_SUCCEEDED")
end
end
function Addon:UNIT_SPELLCAST_SUCCEEDED(unit, spellName, _, _, spellID)
if spells[spellID] then
self:AnnounceSpell(unit, spellID, spellName)
end
end
------------------------------------------------------------------------
-- SLASH COMMAND
local ON = "|cff7fff7fON|"
local OFF = "|cff7f7f7fOFF|r"
SLASH_CONJUREDANNOUNCER1 = "/can"
SlashCmdList["CONJUREDANNOUNCER"] = function(input)
local command, args = strsplit(" ", input or "", 2)
command = strlower(command)
if command == "off" then
db.enabled = false
Addon:GROUP_ROSTER_UPDATE()
Addon:Print("Announcements " .. OFF .. ". Type '/can on' to enable.")
elseif command == "on" then
db.enabled = true
Addon:GROUP_ROSTER_UPDATE()
Addon:Print("Announcements " .. ON ..". Type '/can off' to disable.")
elseif command == "party" then
db.partyInRaid = not db.partyInRaid
Addon:Print("Now announcing to " .. (db.partyInRaid and "|cff87cefa/party only|r" or "|cffff0000/ra|r") .. " while in a raid group.")
elseif command == "rw" then
db.raidWarning = not db.raidWarning
Addon:Print("Raid warning announcements " .. (db.raidWarning and ON or OFF))
elseif command == "print" then
db.printSolo = not db.printSolo
Addon:Print("Print solo announcements " .. (db.printSolo and ON or OFF))
else
Addon:Print("Current state is " .. (db.enabled and ON or OFF))
print(" Use /can with the following commands:")
print(" |cffffff7fon|r - enable announcements")
print(" |cffffff7foff|r - disable announcements")
print(" |cffffff7fparty|r - announce only to |cff87cefa/party|r in a raid (" .. (db.partyInRaid and ON or OFF) .. ")")
print(" |cffffff7frw|r - announce to raid warning when possible (" .. (db.raidWarning and ON or OFF) .. ")")
print(" |cffffff7fprint|r - print announcements when solo (" .. (db.printSolo and ON or OFF) .. ")")
end
end
|