Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Info Board by Southp0le
- --adjusted for 6x8 Advanced Monitor
- --Main Monitor Coordinates:
- ----x:=[1,55]
- ----y:=[1,27]
- --Touch Monitor Coordinates:
- ----x:=[1,80]
- ----y:=[1,5]
- --working, but a giant mess in the code.. => work =(
- ---------------------
- -------Options-------
- ---------------------
- os.loadAPI("buttonAPI")
- local serverAdmin = "Guracao"
- local boardAdmin = "Southp0le"
- local mon = peripheral.wrap("monitor_1")
- local mon2 = peripheral.wrap("top")
- local chat = peripheral.wrap("bottom")
- local mod = peripheral.wrap("back")
- local det = peripheral.wrap("playerDetector_1")
- local filled
- local page = 1
- local pages = 1
- local showed
- local listSorted = {}
- local numbersSorted = {}
- local deathReasonsSorted = {}
- local killNumbersSorted = {}
- local list = {}
- local numbers = {}
- local deathReasons = {}
- local killNumbers = {}
- mon.setTextColor(colors.black)
- mon.setBackgroundColor(colors.lightBlue)
- mon.setTextScale(1.5)
- mon2.setTextColor(colors.black)
- mon2.setBackgroundColor(colors.lightBlue)
- mon2.setTextScale(1)
- -----------------------
- -------Functions-------
- -----------------------
- function table.copy(t)
- local t2 = {};
- for k,v in pairs(t) do
- if type(v) == "table" then
- t2[k] = table.copy(v);
- else
- t2[k] = v;
- end
- end
- return t2;
- end
- ----------------
- --file control--
- ----------------
- --saves the file
- function saveFile(filename)
- local file = fs.open(filename,"w")
- if filename == "list1" then
- listSorted = table.copy(list)
- file.write(textutils.serialize(list))
- file.close()
- print("File '"..filename.."' saved.")
- refresh()
- return true
- elseif filename == "numbers" then
- file.write(textutils.serialize(numbers))
- file.close()
- print("File '"..filename.."' saved.")
- refresh()
- return true
- elseif filename == "deathReasons" then
- deathReasonsSorted = table.copy(deathReasons)
- file.write(textutils.serialize(deathReasons))
- file.close()
- print("File '"..filename.."' saved.")
- refresh()
- return true
- elseif filename == "killNumbers" then
- file.write(textutils.serialize(killNumbers))
- file.close()
- print("File '"..filename.."' saved.")
- refresh()
- return true
- elseif filename == "coords" then
- file.write(textutils.serialize(coords))
- file.close()
- print("File '"..filename.."' saved.")
- refresh()
- return true
- else
- return false
- end
- end
- --loads the file and returns the file
- function loadFile(filename)
- local file = fs.open(filename,"r")
- local data = file.readAll()
- file.close()
- if string.len(data) > 0 and data ~= nil then
- print("File '"..filename.."' loaded.")
- return textutils.unserialize(data)
- else
- return {}
- end
- end
- --checks if there's a file, creates one if not
- function checkFile(file)
- if fs.exists(file) == false then
- if saveFile(file) then
- print("Created a new file: " ..file..".")
- end
- else
- print("Everything fine, file '" ..file.."' exists already.")
- end
- end
- ----------
- --Tables--
- ----------
- --creates table "list" with all infomation (overloaded)
- function setTable(...)
- local n = length(list)+1
- local arguments = {select(1,...)}
- local player = arguments[1]
- numbers[n] = player
- deathReasons[n] = {}
- coords = {}
- coords[n] ={}
- if table.getn(arguments) == 1 then
- list[n] = {}
- list[n]["player"] = arguments[1]
- list[n]["deaths"] = 0
- list[n]["kills"] = 0
- list[n]["ratio"] = "-"
- list[n]["logins"] = 0
- list[n]["messages"] = 0
- list[n]["average"] = 0
- print("Player '" ..player.. "' successfully created.")
- elseif table.getn(arguments) == 7 then
- list[n] = {}
- list[n]["player"] = arguments[1]
- list[n]["deaths"] = arguments[2]
- list[n]["kills"] = arguments[3]
- list[n]["ratio"] = arguments[4]
- list[n]["logins"] = arguments[5]
- list[n]["messages"] = arguments[6]
- list[n]["average"] = arguments[7]
- print("Player '" ..player.. "' successfully created.")
- else
- print("Error: setTable: Wrong parameter passed to function 'setTable'!")
- end
- end
- --returns lenght of list
- function length(table)
- local n = 0
- if table ~= nil then
- n = #table
- end
- return n
- end
- --returns related number from player
- function getNumber(player)
- if numbers == nil then
- print("Error: getNumbers: nil list!")
- elseif length(numbers) == 0 then
- print("Error: getNumbers: empty list!")
- return
- else
- for k in ipairs(list) do
- if numbers[k] == player then
- return k
- end
- end
- end
- end
- --checks if player exists
- function checkPlayer(player)
- local x = 0
- if numbers ~= nil then
- for k in pairs(numbers) do
- if numbers[k] == player then
- return true
- end
- end
- end
- return false
- end
- --removes table-entry
- function table.removePlayer(player)
- local key = getNumber(player)
- if checkPlayer(player) then
- table.remove(list, key)
- table.remove(numbers, key)
- if deathReasons[key] ~= nil then
- table.remove(deathReasons, key)
- end
- if killNumbers[key] ~= nil then
- table.remove(killNumbers, key)
- end
- saveFile("list1")
- saveFile("numbers")
- saveFile("deathReasons")
- saveFile("killNumbers")
- print("Player " ..player.. " successfully removed.")
- else
- print("Error: removePlayer: Player '" ..player.. "' could not be removed. Is the name written correctly?")
- end
- end
- --creates a dummy-player for comparative
- --removes it if no longer needed
- function dummy()
- local number = length(list)
- --setTable("dummy")
- print("Players:")
- if number == 0 then
- setTable("dummy")
- end
- if list ~= nil then
- for k in ipairs(list) do
- print(list[k]["player"])
- end
- else
- print(" ")
- end
- if number>1 and checkPlayer("dummy") then
- table.removePlayer("dummy")
- end
- print("There're " ..number.. " Players on the server.")
- end
- --adds a new player to the list
- function addPlayer()
- while true do
- event,newcomer = os.pullEvent("player")
- local x = 0
- if checkPlayer(newcomer) then
- chat.tell(newcomer,"Error: "..newcomer..", you're already listed in the database. Don't you remember, Idiot?")
- elseif checkPlayer(newcomer) == false then
- chat.tell(newcomer,"Congratulations! Welcome to this great server, now you're listed in the database. Have fun, "..newcomer..".")
- setTable(newcomer)
- saveFile("numbers")
- saveFile("list1")
- saveFile("deathReasons")
- saveFile("killNumbers")
- else
- chat.say("Well this shouldn't happen, please report this error to "..serverAdmin.." or " ..infoboardAdmin..".")
- chat.say("No joke!")
- end
- end
- end
- --calculates kill/death ratio
- function ratio(player)
- if list[player]["deaths"] == 0 then
- list[player]["ratio"] = "-"
- else
- list[player]["ratio"] = tonumber(list[player]["kills"])/tonumber(list[player]["deaths"])
- end
- end
- function randomMessage(player)
- local case = math.random(1,29)
- if case == 1 then
- chat.tell(player,"So, how was dying?",20000)
- elseif case ==2 then
- chat.tell(player,"The South corporation would like to remind you that there is only one thing worse than respawning, and that is not respawning.",20000)
- elseif case == 3 then
- chat.tell(player,"South recommends swearing vengeance on the thing that killed you, unless it was an inanimate object such as a cliff.",20000)
- elseif case == 4 then
- chat.tell(player,"Byebye… Hello friend.",20000)
- elseif case == 5 then
- chat.tell(player,"Rise from your grave!",20000)
- elseif case == 6 then
- chat.tell(player,"The South corporation suggests: Live! LIIIIIIIIVVVVVVVVE!",20000)
- elseif case == 7 then
- chat.tell(player,"Aaaaaand RESPAWN!",20000)
- elseif case == 8 then
- chat.tell(player,"R-r-r-r-respawn!",20000)
- elseif case == 9 then
- chat.tell(player,"South recommends channeling your post-death frustration into pre-death vengeful anger!",20000)
- elseif case == 10 then
- chat.tell(player,"The South corporation would like to remind you that the afterlife is extremely boring, and not worth visiting.",20000)
- elseif case == 11 then
- chat.tell(player,"The South corporation is sure none of that was your fault.",20000)
- elseif case == 12 then
- chat.tell(player,"South recommends checking for any excess limbs before continuing your adventure.",20000)
- elseif case == 13 then
- chat.tell(player,"South says: back on your feet and show 'em what for!",20000)
- elseif case == 14 then
- chat.tell(player,"Anyone can live. Have the courage to die!",20000)
- elseif case == 15 then
- chat.tell(player,"So long as you believe in yourself, nothing can TRULY kill you! Except Creepers.",20000)
- elseif case == 16 then
- chat.tell(player,"Greetings, clone-of-the-recently-deceased! Good luck in your future endeavors!",20000)
- elseif case == 17 then
- chat.tell(player,"South suggests that you rejoice in your temporary death! A victory achieved without suffering is no victory at all!",20000)
- elseif case == 18 then
- chat.tell(player,"South hopes your death was a learning experience, but wouldn't mind if you made the same mistake just a few more times just to be sure.",20000)
- elseif case == 19 then
- chat.tell(player,"South says: afterlife, schmafterlife.",20000)
- elseif case == 20 then
- chat.tell(player,"The South corporation says: Welcome back.",20000)
- elseif case == 21 then
- chat.tell(player,"Dying is awesome! All of the cool kids are doing it!",20000)
- elseif case == 22 then
- chat.tell(player,"The South corporation welcomes you back from your visit to the undiscovered country.",20000)
- elseif case == 23 then
- chat.tell(player,"South asks: why die when you can respawn?",20000)
- elseif case == 24 then
- chat.tell(player,"Enjoy your new you!",20000)
- elseif case == 25 then
- chat.tell(player,"So, how are things?",20000)
- elseif case == 26 then
- chat.tell(player,"Oh, it's you again.",20000)
- elseif case == 27 then
- chat.tell(player,"So, how was hell?",20000)
- elseif case == 28 then
- chat.tell(player,"Death means nothing in this fantasy world!",20000)
- elseif case == 29 then
- chat.tell(player,"At least the game's not too easy, right?",20000)
- end
- end
- --calculates average messagelenght
- function average(player, message)
- list[player]["average"] = (tonumber(list[player]["average"]))*(tonumber(list[player]["messages"])-1)
- list[player]["average"] = (tonumber(list[player]["average"]) + string.len(message)) / (tonumber(list[player]["messages"]))
- end
- -----------
- --sorting--
- -----------
- --damn many sort functions
- function sortByDeathsH(x, y)
- return x.deaths > y.deaths
- end
- function sortByKillsH(x, y)
- return x.kills > y.kills
- end
- function sortByLoginsH(x, y)
- return x.logins > y.logins
- end
- function sortByMessagesH(x, y)
- return x.messages > y.messages
- end
- function sortByAverageH(x, y)
- return x.average > y.average
- end
- function sortByRatioH(x,y)
- return tostring(x.ratio) > tostring(y.ratio)
- end
- function sortByDeathsL(x, y)
- return x.deaths < y.deaths
- end
- function sortByKillsL(x, y)
- return x.kills < y.kills
- end
- function sortByLoginsL(x, y)
- return x.logins < y.logins
- end
- function sortByMessagesL(x, y)
- return x.messages < y.messages
- end
- function sortByAverageL(x, y)
- return x.average < y.average
- end
- function sortByRatioL(x,y)
- return tostring(x.ratio) < tostring(y.ratio)
- end
- function sortByReasons(x, y)
- return x > y
- end
- function sortAll (state)
- if state == "max1" then
- table.sort(listSorted,sortByKillsH)
- buttonAPI.toggleAll(" Max ")
- elseif state == "min1" then
- table.sort(listSorted,sortByKillsL)
- buttonAPI.toggleAll(" Min ")
- elseif state == "max2" then
- table.sort(listSorted,sortByDeathsH)
- buttonAPI.toggleAll("Max ")
- elseif state == "min2" then
- table.sort(listSorted,sortByDeathsL)
- buttonAPI.toggleAll("Min ")
- elseif state == "max3" then
- table.sort(listSorted,sortByRatioH)
- buttonAPI.toggleAll(" Max ")
- elseif state == "min3" then
- table.sort(listSorted,sortByRatioL)
- buttonAPI.toggleAll(" Min ")
- elseif state == "max4" then
- table.sort(listSorted,sortByMessagesH)
- buttonAPI.toggleAll("Max")
- elseif state == "min4" then
- table.sort(listSorted,sortByMessagesL)
- buttonAPI.toggleAll("Min")
- elseif state == "max5" then
- table.sort(listSorted,sortByAverageH)
- buttonAPI.toggleAll("Max ")
- elseif state == "min5" then
- table.sort(listSorted,sortByAverageL)
- buttonAPI.toggleAll("Min ")
- elseif state == "max6" then
- table.sort(listSorted,sortByLoginsH)
- buttonAPI.toggleAll("Max")
- elseif state == "min6" then
- table.sort(listSorted,sortByLoginsL)
- buttonAPI.toggleAll("Min")
- end
- refresh()
- end
- -----------
- --Monitor--
- -----------
- --refreshes the monitorscreen
- function refresh()
- mon.clear()
- mon2.clear()
- screen()
- buttonAPI.screen()
- end
- --creates labels
- function label(xpos,ypos, text)
- mon.setCursorPos(xpos, ypos)
- mon.write(text)
- end
- --prints everything on the monitor
- function printAll()
- mon2.clear()
- local y = 4
- if filled == "login" then
- label(2,2,"Player:")
- label(27,2, "Logins:")
- for k in pairs(listSorted) do
- mon.setCursorPos(3,y)
- mon.write(listSorted[k]["player"])
- mon.setCursorPos(29,y)
- mon.write(tostring(listSorted[k]["logins"]))
- y=y+1
- end
- elseif filled == "sortKill" then
- label(2,2,"Player:")
- label(19,2, "Kills:")
- label(34,2, "Deaths:")
- label(49,2, "Ratio:")
- for k in pairs(listSorted) do
- mon.setCursorPos(3,y)
- mon.write(listSorted[k]["player"])
- mon.setCursorPos(20,y)
- mon.write(tostring(listSorted[k]["kills"]))
- mon.setCursorPos(35,y)
- mon.write(tostring(listSorted[k]["deaths"]))
- mon.setCursorPos(50,y)
- mon.write(tostring(listSorted[k]["ratio"]))
- y=y+1
- end
- elseif filled == "sortMessage" then
- label(2,2,"Player:")
- label(22,2, "Messages:")
- label(37,2, "average Length:")
- for k in pairs(listSorted) do
- mon.setCursorPos(3,y)
- mon.write(listSorted[k]["player"])
- mon.setCursorPos(23,y)
- mon.write(tostring(listSorted[k]["messages"]))
- mon.setCursorPos(38,y)
- mon.write(tostring(listSorted[k]["average"]))
- y=y+1
- end
- elseif filled == "sortReasons" then
- local n = getNumber(showed)
- local total = 0
- label(2,2, tostring(showed))
- label(20,4, "Reasons:")
- label(45,4, "Deaths:")
- y=y+2
- if length(deathReasonsSorted[n]) ~= nil and length(deathReasonsSorted[n]) ~= 0 then
- local written = {}
- for k in pairs(deathReasonsSorted[n]) do
- total = total + tonumber(deathReasonsSorted[n][k])
- local i
- for i in pairs(deathReasons[n]) do
- if deathReasons[n][i] == deathReasonsSorted[n][k] then
- local j
- local bool = true
- for j in pairs(written) do
- if killNumbers[n][i] == written[j] then
- bool = false
- end
- end
- if bool then
- mon.setCursorPos(21,y)
- mon.write(tostring(killNumbers[n][i]))
- table.insert(written, killNumbers[n][i])
- break
- end
- end
- end
- mon.setCursorPos(44,y)
- mon.write(tostring(deathReasonsSorted[n][k]))
- y=y+1
- end
- if (listSorted[n]["deaths"]-total) ~= 0 then
- mon.setCursorPos(21,y)
- mon.write("Unknown Reasons")
- mon.setCursorPos(44,y)
- mon.write(tostring(listSorted[n]["deaths"]-total))
- end
- end
- end
- end
- function screen()
- if filled ~= "button" then
- printAll()
- end
- end
- function toggleScreen(change)
- buttonAPI.toggleAll(change)
- refresh()
- end
- function nextPage()
- if page+1 <= pages then
- page = page+1
- end
- fillReasons()
- end
- function prevPage()
- if page-1 >= 1 then
- page = page-1
- end
- fillReasons()
- end
- function nextPage2()
- if page+1 <= pages then
- page = page+1
- end
- fillCoords()
- end
- function prevPage2()
- if page-1 >= 1 then
- page = page-1
- end
- fillCoords()
- end
- function goBack()
- fillReasons()
- end
- --buttons in main-menu
- function fillButton()
- buttonAPI.clearTable()
- buttonAPI.setTable("Kill/Death", fillSortKill,"", 2, 15, 2, 4)
- buttonAPI.setTable("Death Reasons", fillReasons,"", 18, 34, 2, 4)
- buttonAPI.setTable("Messages", fillSortMessages,"", 37, 48, 2, 4)
- buttonAPI.setTable("Coords",fillCoords,"", 51, 59,2,4)
- filled = "button"
- refresh()
- end
- --button to choose player for deathreasons
- function fillReasons()
- buttonAPI.clearTable()
- mon.setTextScale(1.5)
- players = length(list)
- local npp = 3 --names per page
- local currLength = 24
- pages = math.ceil(players/npp)
- local currName = 0
- for k in pairs(numbers) do
- currName = currName + 1
- if currName > npp*(page-1) and currName < npp*page+1 then
- buttonAPI.setTable(numbers[k], fillSortReasons, numbers[k], currLength, currLength + string.len(numbers[k])+4 ,2 ,4)
- currLength = currLength + string.len(numbers[k])+8
- end
- end
- buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
- buttonAPI.setTable("Next Page", nextPage, "", 10, 20, 1, 2)
- buttonAPI.setTable("Prev Page", prevPage, "", 10, 20, 4, 5)
- refresh()
- buttonAPI.label(11,3, "Page: "..page.. "/"..pages)
- filled = "reasons"
- end
- --button to choose player for coord
- function fillCoords()
- buttonAPI.clearTable()
- mon.setTextScale(1.5)
- players = length(list)
- local npp = 3 --names per page
- local currLength = 24
- pages = math.ceil(players/npp)
- local currName = 0
- for k in pairs(numbers) do
- currName = currName + 1
- if currName > npp*(page-1) and currName < npp*page+1 then
- buttonAPI.setTable(numbers[k], coordsOptions, numbers[k], currLength, currLength + string.len(numbers[k])+4 ,2 ,4)
- currLength = currLength + string.len(numbers[k])+8
- end
- end
- buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
- buttonAPI.setTable("Next Page", nextPage2, "", 10, 20, 1, 2)
- buttonAPI.setTable("Prev Page", prevPage2, "", 10, 20, 4, 5)
- refresh()
- label(2,2,"Player:")
- label(18,2,"Place:")
- label(30,2,"Coordinates:")
- local y = 4
- for k in pairs(list) do
- mon.setCursorPos(3,y)
- mon.write(numbers[k])
- if coords[k] == nil or #coords[k] then
- y=y+1
- end
- for i in pairs(coords[k]) do
- mon.setCursorPos(20,y)
- mon.write(coords[k][i]["name"])
- mon.setCursorPos(32,y)
- mon.write(coords[k][i]["xCoord"])
- mon.setCursorPos(38,y)
- mon.write(coords[k][i]["yCoord"])
- mon.setCursorPos(44,y)
- mon.write(coords[k][i]["zCoord"])
- y=y+1
- end
- end
- buttonAPI.label(11,3, "Page: "..page.. "/"..pages)
- filled = "coords"
- end
- function goBack2()
- fillCoords()
- end
- function newCoords(player,name,x,y,z)
- local n = getNumber(player)
- local m = length(coords[n])+1
- chat.say("Please write 'NameofthePlace x-coords y-coords z-coords' .")
- chat.say("For example 'Base 12 85 943' .")
- event, player, message = os.pullEvent("chat")
- local string = message
- local x = 0
- for word in string.gmatch(string, "%w+") do
- if x == 0 then
- name = word
- elseif x == 1 then
- xCoord = word
- elseif x == 2 then
- yCoord= word
- elseif x == 3 then
- zCoord = word
- end
- x=x+1
- end
- coords[n][m] = {}
- coords[n][m]["name"] = name
- coords[n][m]["xCoord"] = xCoord
- coords[n][m]["yCoord"] = yCoord
- coords[n][m]["zCoord"] = zCoord
- saveFile("coords")
- end
- function deleteCoords(player)
- chat.say("Please write the number of the place you want to delete.")
- event, player2, message = os.pullEvent("chat")
- local n = getNumber(player)
- table.remove(coords[n], tonumber(message))
- saveFile("coords")
- end
- function coordsOptions(player)
- buttonAPI.clearTable()
- buttonAPI.setTable("Home", fillButton, player, 2, 7, 2, 4)
- buttonAPI.setTable("Back", goBack2, "", 9, 14, 2, 4)
- buttonAPI.setTable("New", newCoords,player,22,27,2,4)
- buttonAPI.setTable("Delete", deleteCoords,player,30,37,2,4)
- refresh()
- end
- --sorting buttons for kill-screen
- function fillSortKill()
- buttonAPI.clearTable()
- mon.setTextScale(1.5)
- buttonAPI.setTable(" Min ", sortAll, "min1", 22, 28, 4, 5)
- buttonAPI.setTable(" Max ", sortAll, "max1", 22, 28, 1, 2)
- buttonAPI.setTable("Min ", sortAll, "min2", 44, 50, 4, 5)
- buttonAPI.setTable("Max ", sortAll, "max2", 44, 50, 1, 2)
- buttonAPI.setTable(" Min ", sortAll, "min3", 66, 72, 4, 5)
- buttonAPI.setTable(" Max ", sortAll, "max3", 66, 72, 1, 2)
- buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
- filled = "sortKill"
- refresh()
- end
- --sorting buttons for deathreason-screen
- function fillSortReasons(display)
- buttonAPI.clearTable()
- showed = display
- buttonAPI.setTable("Back", goBack, "", 9, 14, 2, 4)
- buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
- filled = "sortReasons"
- refresh()
- end
- --sorting buttons for message-screen
- function fillSortMessages()
- mon.setTextScale(1.5)
- buttonAPI.clearTable()
- buttonAPI.setTable("Min",sortAll, "min4", 35, 41, 4, 5)
- buttonAPI.setTable("Max",sortAll, "max4", 35, 41, 1, 2)
- buttonAPI.setTable("Min ",sortAll, "min5", 60, 66, 4, 5)
- buttonAPI.setTable("Max ",sortAll, "max5", 60, 66, 1, 2)
- buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
- filled = "sortMessage"
- refresh()
- end
- --sorting buttons for login-screen
- function fillSortLogins()
- buttonAPI.clearTable()
- buttonAPI.setTable("Min",sortAll, "min6", 26, 32, 4, 5)
- buttonAPI.setTable("Max",sortAll, "max6", 26, 32, 1, 2)
- buttonAPI.setTable("Home", fillButton, "", 2, 7, 2, 4)
- filled = "sortLogins"
- refresh()
- end
- ------------------------
- --while true functions--
- ------------------------
- --counts deaths, kills and deathreasons
- function deathcount()
- while true do
- local event,dead,killer,cause = os.pullEvent("chat_death")
- if checkPlayer(dead) == false then
- setTable(dead)
- end
- local number1 = getNumber(dead)
- list[number1]["deaths"] = tonumber(list[number1]["deaths"])+1
- ratio(number1)
- if killer~=nil then
- for k in pairs(list) do
- if killer == list[k]["player"] then
- local number2 = getNumber(killer)
- list[number2]["kills"] = tonumber(list[number2]["kills"])+1
- ratio(number2)
- end
- end
- local x = 0
- if list[number1]["deaths"] == 1 then
- killNumbers[number1] = {}
- deathReasons[number1] = {}
- end
- for i=1, length(killNumbers[number1]), 1 do
- if tostring(killNumbers[number1][i]) == killer then
- deathReasons[number1][i] = deathReasons[number1][i]+1
- x = x+1
- end
- end
- if x == 0 then
- local n = length(killNumbers[number1])+1
- killNumbers[number1][n] = killer
- deathReasons[number1][n] = 1
- end
- end
- randomMessage(dead)
- chat.tell(dead, "You died " ..list[number1]["deaths"].. " times.",20000)
- saveFile("deathReasons")
- saveFile("killNumbers")
- saveFile("list1")
- saveFile("numbers")
- table.sort(deathReasonsSorted[number1], sortByReasons)
- end
- end
- --counts numbers of messages
- --includes maintenance-options
- function messagecount()
- while true do
- local event, player, message = os.pullEvent("chat")
- if checkPlayer(player) == false then --unregistered player would crash system
- setTable(player)
- end
- local number = getNumber(player)
- list[number]["messages"] = tonumber(list[number]["messages"])+1
- average(number,tostring(message))
- if player == boardAdmin and message == "createPlayer" then
- chat.tell(boardAdmin,"Waiting for information to create player: Name, Kills, Deaths, Ratio, Logins, Messages, Average")
- print("Waiting for information to create player: Name, Kills, Deaths, Ratio, Logins, Messages, Average")
- local event, player, message = os.pullEvent("chat")
- local string = message
- local x = 0
- for word in string.gmatch(string, "%w+") do
- if x == 0 then
- name = word
- print("Player: " ..word)
- elseif x == 1 then
- kills = tonumber(word)
- print("Kills: " ..word)
- elseif x == 2 then
- deaths = tonumber(word)
- print("Deaths: " ..word)
- elseif x == 3 then
- ratio = tonumber(word)
- print("Ratio: "..word)
- elseif x == 4 then
- logins = tonumber(word)
- print("Logins: " ..word)
- elseif x == 5 then
- messages = tonumber(word)
- print("Messages: " ..word)
- elseif x == 6 then
- average = tonumber(word)
- print("Average Lenght: " ..word)
- else
- print("Error: messagecount: createPlayer: String-message not matching")
- end
- x=x+1
- end
- setTable(name,deaths,kills,ratio,logins,messages,average)
- elseif player == boardAdmin and message == "deletePlayer"then
- chat.tell(boardAdmin,"Waiting for information to delete player: Name")
- print("Waiting for information to delete player: Name")
- event, player, message = os.pullEvent("chat")
- table.removePlayer(tostring(message))
- end
- saveFile("list1")
- saveFile("numbers")
- saveFile("deathReasons")
- saveFile("killNumbers")
- end
- end
- --checks for monitortouch
- function getClick()
- while true do
- local event,side,x,y = os.pullEvent("monitor_touch")
- if side == "top" then
- buttonAPI.checkxy(x,y)
- end
- end
- end
- function time()
- while true do
- local day = os.day()
- if filled == "button" then
- local time = textutils.formatTime(os.time(), true)
- mon.clear()
- mon.setTextScale(5)
- mon.setCursorPos(3,3)
- mon.write("Day: " ..day)
- mon.setCursorPos(3,4)
- mon.write("Time: " ..time)
- end
- sleep(5)
- if day%100 == 0 then
- chat.say("The South corporation enjoys to say that it's time to celebrate the " ..day.. ". jubilee of the World a27Dci85sg-3. Have a nice day!",20000)
- end
- end
- end
- --function with all pullEvents
- function mainProcess()
- parallel.waitForAny(deathcount, messagecount, addPlayer, getClick, time)
- end
- -----------
- --Process--
- -----------
- --lifeControl()
- checkFile("list1")
- checkFile("numbers")
- checkFile("deathReasons")
- checkFile("killNumbers")
- list = loadFile("list1")
- numbers = loadFile("numbers")
- deathReasons = loadFile("deathReasons")
- killNumbers = loadFile("killNumbers")
- listSorted = table.copy(list)
- numbersSorted = table.copy(numbers)
- deathReasonsSorted = table.copy(deathReasons)
- killNumbersSorted = table.copy(killNumbers)
- coords = loadFile("coords")
- fillButton()
- dummy()
- refresh()
- mainProcess()
Advertisement
Add Comment
Please, Sign In to add comment