Skip to content

Commit

Permalink
Add command to edit mob kills
Browse files Browse the repository at this point in the history
Fixes #15.
  • Loading branch information
Sharparam committed Oct 30, 2020
1 parent 4d7abff commit 0d67607
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
37 changes: 37 additions & 0 deletions Command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ C:Register("__DEFAULT__", function()
KT:Msg("/kt lookup <name> - Display number of kills on <name>, <name> 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 <id> <name> <global> <char> - Set kill counts for a mob")
KT:Msg("/kt delete <id> - Delete entry with NPC id <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.")
Expand Down Expand Up @@ -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 <id> <name> <global> <char>")
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")
Expand Down
22 changes: 22 additions & 0 deletions KillTrack.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0d67607

Please sign in to comment.