Advertisement
Jeyjey0

Untitled

Sep 7th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. rednet.open("top")
  2. if not fs.exists("webeditor") then
  3. shell.run("pastebin get qXeRRLxU webeditor")
  4. end
  5. term.clear()
  6. term.setCursorPos(1, 1)
  7. print("Server ")
  8. term.setTextColor( colors.lime )
  9. term.setCursorPos(8,1)
  10. print("online")
  11. term.setTextColor( colors.red )
  12. print("Press s for change mode")
  13. function loader()
  14. while true do
  15. local id, message = rednet.receive()
  16. print("connecting")
  17. local filePath = "ids"
  18. local fileHandle = fs.open (filePath, 'w')
  19. fileHandle.write (textutils.serialize (id))
  20. fileHandle.close()
  21. if fs.exists(tostring(message)) then
  22. shell.run(message)
  23. local filePath = "messages"
  24. local fileHandle = fs.open (filePath, 'w')
  25. fileHandle.write (textutils.serialize (message))
  26. fileHandle.close()
  27. elseif not fs.exists(tostring(message)) then
  28. rednet.send(id,"Wbn")
  29. end
  30. end
  31. end
  32. function buttonpress()
  33. onoff = 1
  34. while true do
  35. local event, param = os.pullEvent()
  36. if event == "key" and param == 31 then -- key 28 is the 'enter' key
  37. onoff = onoff + 1
  38. if onoff == 1 then
  39. term.clear()
  40. term.setCursorPos(1, 1)
  41. print("Server ")
  42. term.setTextColor( colors.lime )
  43. term.setCursorPos(8,1)
  44. print("online")
  45. rednet.open("top")
  46. elseif onoff == 2 then
  47. term.clear()
  48. term.setCursorPos(1, 1)
  49. term.setTextColor( colors.white )
  50. print("Server ")
  51. term.setTextColor( colors.red )
  52. term.setCursorPos(8,1)
  53. print("offline")
  54. rednet.close("top")
  55. elseif onoff > 2 then
  56. onoff = 1
  57. rednet.open("top")
  58. term.clear()
  59. term.setCursorPos(1, 1)
  60. term.setTextColor( colors.white )
  61. print("Server ")
  62. term.setTextColor( colors.lime )
  63. term.setCursorPos(8,1)
  64. print("online")
  65. end
  66. end
  67. end
  68. end
  69. parallel.waitForAll(loader,buttonpress)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement