diff --git a/Command.lua b/Command.lua index da8d9eb..04751cd 100644 --- a/Command.lua +++ b/Command.lua @@ -69,6 +69,7 @@ C:Register("__DEFAULT__", function() KT:Msg("/kt lookup - Display number of kills on , can also be NPC ID.") KT:Msg("/kt print - Toggle printing kill updates to chat.") KT:Msg("/kt list - Display a list of all mobs entries.") + KT:Msg("/kt set - Set kill counts for a mob") KT:Msg("/kt delete - Delete entry with NPC id .") KT:Msg("/kt purge [threshold] - Open dialog to purge entries, specifiying a threshold here is optional.") KT:Msg("/kt reset - Clear the mob database.") @@ -105,6 +106,42 @@ C:Register({"printnew", "pn"}, function() end end) +C:Register({"set", "edit"}, function(args) + local id = tonumber(args[1]) + local name = args[2] + local global = tonumber(args[3]) + local char = tonumber(args[4]) + + local err + + if not id then + KT:Msg("Missing or invalid argument: id") + err = true + end + + if not name then + KT:Msg("Missing or invalid argument: name") + err = true + end + + if not global then + KT:Msg("Missing or invalid argument: global") + err = true + end + + if not char then + KT:Msg("Missing or invalid argument: char") + err = true + end + + if err then + KT:Msg("Usage: /kt set ") + return + end + + KT:SetKills(id, name, global, char) +end) + C:Register({"delete", "del", "remove", "rem"}, function(args) if #args <= 0 then KT:Msg("Missing argument: id") diff --git a/KillTrack.lua b/KillTrack.lua index 2a799ec..4727089 100644 --- a/KillTrack.lua +++ b/KillTrack.lua @@ -418,6 +418,28 @@ function KT:AddKill(id, name) end end +function KT:SetKills(id, name, globalCount, charCount) + if type(id) ~= "number" then + error("'id' argument must be a number") + end + + if type(globalCount) ~= "number" then + error("'globalCount' argument must be a number") + end + + if type(charCount) ~= "number" then + error("'charCount' argument must be a number") + end + + name = name or NO_NAME + + self:InitMob(id, name) + self.Global.MOBS[id].Kills = globalCount + self.CharGlobal.MOBS[id].Kills = charCount + + self:Msg(("Updated %q to %d global and %d character kills"):format(name, globalCount, charCount)) +end + function KT:AddSessionKill(name) if self.Session.Kills[name] then self.Session.Kills[name] = self.Session.Kills[name] + 1