Advertisement
systox

Monitor

May 24th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. function Bar()
  2. local w,h = term.getSize()
  3. local Lstart = 1 --                                                                                 Start X von Loadingbar
  4. local Lende = 50 --                                                                                 Ende X von Loadingbar
  5. local Lzeichen = "X" --                                                                             Zeichen was verwendet wird in Loadingbar
  6. local Lzeit = 0.2 --                                                                                    Zeit die gebraucht wird
  7. local Lrstart = 1.0 --                                                                              Random zeit min
  8. local Lrende = 5.0 --                                                                               Random zeit max
  9. local mon = peripheral.wrap("right")
  10.  
  11. function printCentred( y, s )
  12.     local x = math.floor((w - string.len(s)) / 2)
  13.     term.setCursorPos(x,y)
  14.     term.clearLine()
  15.     term.write( s )
  16. end
  17.  
  18. function HorzLoadBar(sx, fx, sym, zeit, st, en)
  19.  
  20. x,y = term.getCursorPos()
  21. if y >= 18 then
  22. term.clear()
  23. term.setCursorPos(sx,1)
  24. x,y = sx,1
  25. end
  26. term.setCursorPos(sx,y)
  27.  
  28. write("[")
  29. term.setCursorPos(sx,y)
  30.  
  31. term.setCursorPos(fx-1,y)
  32. write("]")
  33.  
  34. mdp = math.floor((sx + fx)/2) - 5
  35.  
  36. for i = (sx+1),(fx-2) do
  37. term.setCursorPos(i,y)
  38. write(sym)
  39. sleep(zeit-math.random(st,en)) -- random zeit
  40. term.setCursorPos(mdp,y+1)
  41.         write(string.format("%d",i/(fx-2) * 100))
  42. write("%")
  43. end
  44. term.setCursorPos(1,y+2)
  45.  
  46. end
  47. HorzLoadBar(Lstart, Lende, Lzeichen, Lzeit, Lrstart, Lrende)
  48. end
  49.  
  50. function getfile()
  51. rednet.open("left")
  52.  
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. print("Getting Files..")
  56.  
  57. while true do
  58.   id,msg = rednet.receive()
  59.   if msg == "RECEIVE" then
  60.     id2,msg2 = rednet.receive()
  61.     if fs.exists(msg2) then
  62.     fs.delete(msg2)
  63.     else
  64.     f = fs.open(msg2, "w")
  65.     id3,msg3 = rednet.receive()
  66.     f.write(msg3)
  67.     f.close()
  68.     print("File "..msg2.." received!")
  69.    
  70.     file = fs.open("file", "r")
  71.     mon.write(file.readAll())
  72.     file.close()
  73.    
  74.     end
  75.   end
  76. end
  77.  
  78. term.clear()
  79. term.setCursorPos(1,1)
  80. print("Got da file")
  81. sleep(5)
  82. shell.run("startup")
  83. end
  84.  
  85. function c()
  86. term.clear()
  87. term.setCursorPos(1,1)
  88. end
  89.  
  90. function start()
  91. c()
  92. print("Booting up!")
  93. Bar()
  94. getfile()
  95. end
  96.  
  97. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement