I'm basically using a template from the other notes plugins I have compiled..
Lua Code:
CBwodtreasures = LibStub("AceAddon-3.0"):NewAddon("CBwodtreasures", "AceConsole-3.0", "AceEvent-3.0")
local nodes = { }
--Shadowmoon valley (947)
nodes[1] = { 947, 35280, 27.1, 2.5, "Stolen Treasure" }
nodes[2] = { 947, 34174, 26.5, 5.7, "Fantastic Fish" }
nodes[3] = { 947, 35279, 28.8, 7.1, "Sunken Treasure" }
--
function CBwodtreasures:OnInitialize()
self:RegisterEvent("PLAYER_ENTERING_WORLD", "WorldEnter")
local defaults = {
profile = {
alwaysshow = false,
save = true,
icon = 6,
},
}
self.db = LibStub("AceDB-3.0"):New("CBwodtreasuresDB", defaults, true)
end
function CBwodtreasures:WorldEnter()
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self:PopulateNotes()
end
function CBwodtreasures:PopulateNotes()
local icon = self.db.profile.icon or 6
for k, v in pairs(nodes) do
-- Nodes: MapID, QuestID, X Coord, Y Coord, QuestName, isDaily
-- AddonNote: folder, name, icon, id, x, y
if (not self:HasBeenLooted(v)) then
Nx.Notes:AddonNote("WOD Treasures", v[5], icon, v[1], v[3], v[4])
end
end
end
function CBwodtreasures:HasBeenLooted(value)
if (self.db.profile.alwaysshow) then return false end
if (self.db.char[value[2]] and self.db.profile.save) then return true end
if (IsQuestFlaggedCompleted(value[2])) then
if (self.db.profile.save and not value[6]) then -- Save the chest but not if it's a daily
self.db.char[value[2]] = true;
end
return true
end
return false
end