Advertisement
hhaos

slain 2.0

Nov 28th, 2011
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1.  
  2.  
  3. Slain Tracking version 2.0
  4.  
  5. SLAIN - Display what you've bagged so far!
  6. SLAIN [DENIZENS/PLAYERS] - Specify which list of kills to see.
  7. SLAIN SEARCH [TERM] - Search your kills for specific things.
  8. SLAIN ADD [DENIZENS/PLAYERS] [#] [THING] - Add kills to the denizen or player lists.
  9. SLAIN REMOVE [DENIZENS/PLAYERS/BY] [#] [THING] - Remove the specified number and type of kills from the lists.
  10. SLAIN RESET - Reset your kill counters
  11. SLAIN RESET [DENIZENS/PLAYERS] - Speicify which list of kills to reset.
  12. SLAIN HELP - View the help for this script.
  13. Note - search, add, and remove are case sensitive.
  14.  
  15. --]]
  16.  
  17.  
  18. --------
  19. --SLAIN
  20. --------
  21.  
  22.  
  23. slain = {
  24.  
  25. things = {
  26.  
  27. denizens = {},
  28.  
  29. players = {},
  30.  
  31. by = {},
  32.  
  33. },
  34.  
  35.  
  36. add = function (name, type, num)
  37. slain.things[type][name] = (slain.things[type][name] or 0) + (num or 1)
  38. if num then
  39. cecho("\n<red>[<white>SLAIN<red>]<white> Added " .. num .. " " .. name .. " to the " .. type .. " kill list.")
  40. end -- if
  41. slain.save()
  42. end, -- func
  43.  
  44.  
  45. find = function (string)
  46. slain.search = string
  47. slain.display ()
  48. end, -- fun
  49.  
  50.  
  51. remove = function (item, num, group)
  52. if slain.things[group][item] then
  53. slain.things[group][item] = slain.things[group][item] - num or nil
  54. cecho("\n<red>[<white>SLAIN<red>]<white> Removed " .. num .. " \"" .. item .. "\" from the slain tracker.")
  55. if slain.things[group][item] == 0 then
  56. slain.things[group][item] = nil
  57. end -- if
  58. slain.save()
  59. else
  60. if group == "by" then
  61. cecho("\n<red>[<white>SLAIN<red>]<white> You have not been slain by anything of that name.")
  62. else
  63. cecho("\n<red>[<white>SLAIN<red>]<white> You have not slain anything by that name.")
  64. end -- if
  65. end -- if
  66. end, -- func
  67.  
  68.  
  69. reset = function (group)
  70. if not group then
  71. slain.things.denizens = {}
  72. slain.things.players = {}
  73. slain.things.by = {}
  74. cecho("\n<red>[<white>SLAIN<red>]<white> Reset all slain counters.")
  75. else
  76. slain.things[group] = {}
  77. cecho("\n<red>[<white>SLAIN<red>]<white> Reset " .. group .. " counter.")
  78. end -- if
  79. slain.save()
  80. end, -- func
  81.  
  82.  
  83. display = function (group)
  84. local ntotal
  85. if group then
  86. group = string.lower (group)
  87. end -- if
  88. cecho("\n<green>You have slain:")
  89. if slain.search then
  90. cecho("<white> " .. slain.search)
  91. end -- if
  92. for k, v in pairs (slain.things) do
  93. ntotal = 0
  94. if group == k or not group then
  95. cecho("<red>\n " .. string.title(k))
  96. for k,v in pairs (slain.things[k]) do
  97. if not slain.search or string.find(tostring(k),slain.search,1,true) then
  98. ntotal = ntotal + v
  99. end -- if
  100. end -- for
  101. cecho("<red>:<white> " .. ntotal .. "\n")
  102. slain.displaygroup (k)
  103. end -- if
  104. end -- for
  105. slain.search = nil
  106. end, -- func
  107.  
  108.  
  109. displaygroup = function (group)
  110. if next (slain.things[group]) == nil and slain.search == nil then
  111. cecho("<white> None!")
  112. else
  113. local last = {}
  114. for k, v in pairs (slain.things[group]) do
  115. if not slain.search or string.find(tostring(k),slain.search,1,true) then
  116. if string.len (k) > 31 or string.len (k) + string.len (tostring(v)) > 37 then
  117. cecho(" <blue>[<white>" .. string.format ("%6s", v))
  118. cecho("<blue>]<white> " .. k .. "\n")
  119. elseif last[1] then
  120. cecho(" <blue>[<white>" .. string.format ("%6s", last[2]))
  121. cecho("<blue>]<white> " .. string.format ("%-31s", last[1]))
  122. cecho(" <blue>[<white>" .. string.format ("%6s", v))
  123. cecho("<blue>]<white> " .. k .. "\n")
  124. last = {}
  125. else
  126. last = {k, v}
  127. end -- if
  128. end -- if
  129. end -- for
  130. if last[1] then
  131. cecho(" <blue>[<white>" .. string.format ("%6s", last[2]))
  132. cecho("<blue>]<white> " .. last[1] .. "\n")
  133. end -- if
  134. end -- if
  135. end, -- func
  136.  
  137.  
  138. help = function ()
  139. cecho("\n<red>[<white>SLAIN TRACKER<red>]")
  140. cecho("\n<white>-------------")
  141. cecho("\n<white>SLAIN - Display what you've bagged so far!")
  142. cecho("\n<white>SLAIN [DENIZENS/PLAYERS/BY] - Specify which list of kills to see.")
  143. cecho("\n<white>SLAIN SEARCH [TERM] - Search your kills for specific things.")
  144. cecho("\n<white>SLAIN ADD [DENIZENS/PLAYERS/BY] [#] [THING] - Add kills to the denizen or player lists.")
  145. cecho("\n<white>SLAIN REMOVE [DENIZENS/PLAYERS/BY] [#] [THING] - Remove the specified number and type of kills from the lists.")
  146. cecho("\n<white>SLAIN RESET - Reset your kill counters.")
  147. cecho("\n<white>SLAIN RESET [DENIZENS/PLAYERS/BY] - Speicify which list of kills to reset.")
  148. cecho("\n<white>SLAIN HELP - View the help for this script.")
  149. cecho("\n<white>Note - Search, add, and remove are case sensitive.")
  150. end, -- func
  151.  
  152.  
  153. save = function ()
  154. if string.char(getMudletHomeDir():byte()) == "/"
  155. then _sep = "/"
  156. else _sep = "\\"
  157. end -- if
  158. local slain_things = getMudletHomeDir() .. _sep .. "slain_things.lua"
  159. table.save(slain_things, slain.things)
  160.  
  161. end, -- func
  162.  
  163. load = function ()
  164. if string.char(getMudletHomeDir():byte()) == "/"
  165. then _sep = "/"
  166. else _sep = "\\"
  167. end -- if
  168. local slain_things = getMudletHomeDir() .. _sep .. "slain_things.lua"
  169. if (io.exists(slain_things)) then
  170. table.load(slain_things, slain.things)
  171. end -- if
  172.  
  173. end, -- func
  174.  
  175. }
  176.  
  177. slain.load()
  178.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement