Muzze77

Bank2.0Timer

Mar 21st, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.72 KB | None | 0 0
  1. shell.run("clear")
  2. rednet.open("top")
  3. if fs.exists("time") == false then
  4.   cFile = fs.open("time","w")
  5.   cFile.writeLine(math.floor(0))
  6.   cFile.close()
  7.   curTime = 0
  8. else
  9.   rFile = fs.open("time","r")
  10.   curTime = rFile.readLine()
  11.   rFile.close()
  12.   curTime = math.floor(curTime)
  13.  
  14. end
  15.  
  16. function saveTime(n)
  17. sFile = fs.open("time","w")
  18. sFile.writeLine(math.floor(n))
  19. sFile.close()
  20. end
  21.  
  22. function sendTime(sTime)
  23. tempTable = {["Key"] = "Timer",["Time"] = sTime}
  24. print(textutils.serialize(tempTable))
  25. rednet.broadcast(textutils.serialize(tempTable))
  26. end
  27.  
  28. while true do
  29.  
  30.   shell.run("clear")
  31.  
  32.   print("TIME: " .. curTime)
  33.   saveTime(curTime)
  34.   sendTime(curTime)
  35.   curTime = curTime + 10
  36.   sleep(10)
  37. end
Add Comment
Please, Sign In to add comment