Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Death Logger 0.2
- -- By: NuAoA
- local list = {}
- if not fs.exists("wrap") then
- print("wrap API not found, downloading from http://pastebin.com/g5tBarus")
- shell.run("pastebin get g5tBarus wrap")
- end
- if not fs.exists("Draw") then
- print("Draw API not found, downloading from http://pastebin.com/3sAGiX7j")
- shell.run("pastebin get 3sAGiX7j Draw")
- end
- os.loadAPI("wrap")
- os.loadAPI("Draw")
- chat = wrap.attach("chat")
- mon = wrap.attach("monitor")
- function recordDeaths()
- sleep(0.2)
- os.queueEvent("read!")
- while true do
- local event,player = os.pullEvent("chat_death")
- local prev = ""
- if fs.exists("death.data") then
- local file = fs.open("death.data","r")
- prev = file.readAll()
- file:close()
- end
- local file = fs.open("death.data","w")
- file.write(player)
- file.write("\n")
- file.write(prev)
- file.close()
- os.queueEvent("read!")
- end
- end
- function readDeaths()
- while true do
- local event = os.pullEvent("read!")
- if event ~= "read!" then
- else
- local file = fs.open("death.data","r")
- local slist = file.readAll()
- list = nil
- list = {}
- for word in string.gmatch(slist,"%S+") do
- if list[word] == nil then
- list[word] = 1
- else
- list[word] = list[word] + 1
- end
- end
- os.queueEvent("Print!")
- end
- end
- end
- function writeScreen()
- while true do
- local event = os.pullEvent("Print!")
- if event ~= "Print!" then
- else
- local t_c,t_t = Draw.emptyScreen(mon)
- local BubbleList = {}
- for i=1,#t_c,2 do
- Draw.tc(t_c,1,i,colors.brown,#t_c[1],i)
- end
- Draw.tc(t_c,1,1,colors.red,#t_c[1],1)
- Draw.tt(t_t,11,1,"Death Leaderboard")
- for i=1,#t_c do
- local high_val = 0
- local high_name = ""
- for k,v in pairs(list) do
- if v > high_val then
- high_val = v
- high_name = k
- end
- end
- if high_val > 0 then
- Draw.tt(t_t,1,i+1,string.sub(i..". ",0,5)..string.sub(high_name.." ",0,25).." "..string.sub(" ",string.len(high_val),10)..high_val)
- list[high_name] = nil
- end
- end
- Draw.draw(mon,t_c,1,1,colors.black,t_t)
- end
- end
- end
- mon.setTextScale(0.5)
- parallel.waitForAll(writeScreen,recordDeaths,readDeaths)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement