psicubed

Untitled

May 5th, 2024
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. function clear( ... )
  2. shell.run("clear")
  3. end
  4. function cWrite(text,y)
  5. x = math.floor(#text/2)
  6. term.setCursorPos(x,y)
  7. term.write()
  8. end
  9. local function getFromHttp(url,path)
  10. local file = http.get(url)
  11. if file then
  12. file = file.readAll()
  13. h=fs.open(path,"w")
  14. h.write(file)
  15. h.close()
  16. else
  17. error("Github server is not aviable.")
  18. end
  19. end
  20. selected = false
  21. local c = 1
  22. xt,yt = term.getSize()
  23. xc = xt/2
  24. yc = yt/2
  25. function Cprint(txt,y)
  26. xt,yt = term.getSize()
  27. term.setCursorPos(xt / 2 - #txt / 2,tonumber(y))
  28. print(txt)
  29. end
  30. function slect1( ... )
  31. term.setBackgroundColor(colors.lightGray)
  32. term.setTextColor(colors.white)
  33. Cprint("Install sender",yc-2)
  34. term.setBackgroundColor(colors.white)
  35. term.setTextColor(colors.black)
  36. end
  37. function slect2( ... )
  38. term.setBackgroundColor(colors.lightGray)
  39. term.setTextColor(colors.white)
  40. Cprint("Install receiver",yc)
  41. term.setBackgroundColor(colors.white)
  42. term.setTextColor(colors.black)
  43. end
  44. function slect3( ... )
  45. term.setBackgroundColor(colors.lightGray)
  46. term.setTextColor(colors.white)
  47. Cprint(" Exit ",yc+2)
  48. term.setBackgroundColor(colors.white)
  49. term.setTextColor(colors.black)
  50. end
  51. function unsall( ... )
  52. term.setTextColor(colors.gray)
  53. Cprint("Install sender",yc-2)
  54. Cprint("Install receiver",yc)
  55. Cprint(" Exit ",yc+2)
  56. end
  57. function InstSender( ... )
  58. clear()
  59. Cprint("Installing wr_connect...",yc)
  60. getFromHttp("https://raw.githubusercontent.com/JustGekto/CC-wireless-monitor/master/wr_connect","wr_connect")
  61. getFromHttp("https://raw.githubusercontent.com/JustGekto/CC-wireless-monitor/master/wr_monitor","wr_monitor")
  62. term.clear()
  63. Cprint("Installed wr_conect!",yc)
  64. os.pullEvent("char")
  65. term.setBackgroundColor(colors.black)
  66. term.setCursorPos(1,1)
  67. term.clear()
  68. selected = true
  69. return
  70. end
  71. function InstReceiver( ... )
  72. clear()
  73. Cprint("Installing wr_receiver...",yc)
  74. getFromHttp("https://raw.githubusercontent.com/JustGekto/CC-wireless-monitor/master/wr_receiver","wr_receiver")
  75. term.clear()
  76. Cprint("Installed wr_receiver!",yc)
  77. os.pullEvent("char")
  78. term.setBackgroundColor(colors.black)
  79. term.setCursorPos(1,1)
  80. term.clear()
  81. selected = true
  82. return
  83. end
  84. term.setBackgroundColor(colors.white)
  85. term.clear()
  86. term.setTextColor(colors.black)
  87. Cprint("Wireless monitor installer",yc-5)
  88. term.setTextColor(colors.gray)
  89. Cprint("Install sender",yc-2)
  90. Cprint("Install receiver",yc)
  91. Cprint(" Exit ",yc+2)
  92. slect1()
  93. while not selected do
  94. local event, code = os.pullEvent("key")
  95. if code == 208 then --down
  96. if c == 3 then
  97. c = 1
  98. else
  99. c = c+1
  100. end
  101. end
  102. if code == 200 then --up
  103. if c == 1 then
  104. c = 3
  105. else
  106. c = c-1
  107. end
  108. end
  109. if code == 28 then
  110. if c == 1 then
  111. InstSender()
  112. elseif c == 2 then
  113. InstReceiver()
  114. elseif c == 3 then
  115. term.setBackgroundColor(colors.black)
  116. term.setCursorPos(1,1)
  117. term.clear()
  118. return
  119. end
  120. end
  121. if c == 1 and not selected then
  122. unsall()
  123. slect1()
  124. end
  125. if c == 2 and not selected then
  126. unsall()
  127. slect2()
  128. end
  129. if c == 3 and not selected then
  130. unsall()
  131. slect3()
  132. end
  133. end
  134.  
Advertisement
Add Comment
Please, Sign In to add comment