Permalink
Browse files

Bug fixes, also got saving data implemented. Now to figure out the up…

…load process.
  • Loading branch information...
1 parent 5ef9ffe commit 9f14e79fbd5f6669978f79dd6481c60aed2ffad1 @jbueza committed May 10, 2010
Showing with 37 additions and 13 deletions.
  1. +35 −12 Ninjalist.lua
  2. +2 −1 options.lua
View
@@ -1,6 +1,9 @@
Ninjalist = LibStub("AceAddon-3.0"):NewAddon("Ninjalist", "AceEvent-3.0", "AceConsole-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("Ninjalist", true)
local ninjas = {}
+local tinsert = table.insert
+local tremove = table.remove
+
function Ninjalist:OnInitialize()
-- Assuming the .toc says ## SavedVariables: MyAddonDB
@@ -10,31 +13,51 @@ function Ninjalist:OnInitialize()
-- Hook into events
self:Print("Ninjalist: Initializing hooks for raid/party changes")
self:RegisterEvent("PARTY_MEMBERS_CHANGED","Scan")
- self:RegisterEvent("RAID_ROSTER_UPDATE","Scan")
+ self:RegisterEvent("RAID_ROSTER_UPDATE","Scan")
end
+function Ninjalist:List()
+ if not self.db then
+ return
+ end
+
+
+ print("Ninjas Found: " .. table.getn(self.db.global))
+ for i,v in ipairs(self.db.global) do
+ print("Ninja: "..v)
+ end
+end
function Ninjalist:Scan()
local NumRaidMembers = GetNumRaidMembers()
- local NumPartyMembers = GetNumPartyMembers()
-
- self.inGroup = false
+ local NumPartyMembers = GetNumPartyMembers()
+
+
+
+ self.inGroup = false
self.inRaid = false
- if NumPartyMembers > 0 and NumRaidMembers == 0 then Ninjalist.inGroup = true end
- if NumRaidMembers > 0 then Ninjalist.inRaid = true end
-
- --SendChatMessage("Ninjalist: scanning for ninjas in current party and raid...", "GUILD")
- if self.inRaid or self.inGroup then
- self:Print("Scanning for ninjas in current party and raid...")
- end
+ if NumPartyMembers > 0 and NumRaidMembers == 0 then Ninjalist.inGroup = true end
+ if NumRaidMembers > 0 then Ninjalist.inRaid = true end
+
+ --SendChatMessage("Ninjalist: scanning for ninjas in current party and raid...", "GUILD")
+ if self.inRaid or self.inGroup then
+ self:Print("Scanning for ninjas in current party and raid...")
+ end
end
function Ninjalist:Add(name)
if name == "" or name == nil then
return
end
- self:Print("Added ninja - "..name.." on "..date("%a %b %d %H:%M:%S %Y"))
+ local serverName = GetRealmName()
+
+ self:Print(serverName.."|"..name.."|"..date("%a %b %d %H:%M:%S %Y"))
+ local data = serverName.."|"..name.."|"..date("%a %b %d %H:%M:%S %Y")
+ --ninjas.insert()
+
+
+ tinsert(self.db.global, data)
--SendChatMessage("Ninjalist: Added ninja - "..name.." on "..date("%a %b %d %H:%M:%S %Y"), "GUILD")
end
View
@@ -46,14 +46,15 @@ local function slashHandler(option)
option = string.lower(option)
if option == "add" then
-
--SendChatMessage("Invoke: AddNinjaCommand(ninjaName)", "PARTY")
Ninjalist:Print("Invoke: AddNinjaCommand(ninjaName)")
elseif option == "scan" then
--self:ToggleFrame(1)
Ninjalist:Print("Invoke: Scan(raidGroup)")
Ninjalist:Scan()
--SendChatMessage("Invoke: Scan(raidGroup)", "GUILD")
+ elseif option == "list" then
+ Ninjalist:List()
else
Ninjalist:Toggle()
end

0 comments on commit 9f14e79

Please sign in to comment.