Advertisement
jamawie

123

Nov 30th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.90 KB | None | 0 0
  1. local mon1 = term
  2. local mon2 = term
  3. --local mon1 = peripheral.wrap("front")
  4. --local mon2 = peripheral.wrap("back")
  5. local x, y = mon1.getSize()
  6. local text = ""
  7. local tpsNo = 20
  8.  
  9. --### useful functions ###--
  10. function getSeconds()
  11.   text=http.get("http://www.simmi.ovh/date.txt").readAll()
  12.   local seconds = tonumber(string.sub(text,7,8))
  13.   print("Time get: "..text)
  14.   print("Seconds:  "..seconds)
  15.   return seconds
  16. end
  17.  
  18. function monitorWrite(xPos, yPos, fColor, bColor, text)
  19.   mon1.setCursorPos(xPos,yPos)
  20.   mon1.setTextColor(fColor)
  21.   mon1.setBackgroundColor(bColor)
  22.   mon1.write(text)
  23.   mon2.setCursorPos(xPos,yPos)
  24.   mon2.setTextColor(fColor)
  25.   mon2.setBackgroundColor(bColor)
  26.   mon2.write(text)
  27. end
  28.  
  29. function drawBackground()
  30.   mon.setBackgroundColor(colors.lightGray)
  31.   for i=1,y do
  32.     mon.setCursorPos(1,i)
  33.     for j=1,x do
  34.       mon.write(" ")
  35.     end
  36.   end
  37. end
  38. --### time function ### --
  39. function time()
  40.   while true do
  41.     monitorWrite(math.floor(x/2)-math.floor(9/2), 1, colors.yellow, colors.blue, "TPS-o-Mat")
  42.     getSeconds()
  43.     monitorWrite(3, 3, colors.blue, colors.lightGray, "Time: ")
  44.     monitorWrite(x-#text, 3, colors.blue, colors.lightGray, text)
  45.     monitorWrite(3, 5, colors.blue, colors.lightGray, "TPS: ")
  46.     local color, position
  47.     if tpsNo<10 then color = colors.red elseif tpsNo<15 then color = colors.orange else color = colors.green end
  48.     if tpsNo<10 then position = x-1 else position = x-2 end
  49.     monitorWrite(x-#tpsNp, 3, color, colors.lightGray, text)
  50.     sleep(1)
  51.    
  52.     print("TPS: "..tpsNo)
  53.   end
  54. end
  55.  
  56. --### tps function ### --
  57. function tps()
  58.   while true do
  59.     local vorher = getSeconds()
  60.     sleep(10)
  61.     local nachher = getSeconds()
  62.     local timeChange = 0
  63.     if nachher<vorher then timeChange = nachher-vorher+60 else timeChange = nachher-vorher end
  64.     tpsNo = 20.5*(10/timeChange)
  65.   end
  66. end
  67.  
  68. parallel.waitForAll(tps(),time())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement