Guest User

striteos

a guest
Mar 27th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.02 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. local version = "0.2"
  5.  
  6. local programs = {"help", "redstone", "edit", "exit"}
  7.  
  8.  
  9. --Color Set Functions--
  10. function white()
  11. term.setTextColor(1)
  12. end
  13. function yellow()
  14. term.setTextColor(16)
  15. end
  16. function blue()
  17. term.setTextColor(2048)
  18. end
  19. function green()
  20. term.setTextColor(8192)
  21. end
  22. function red()
  23. term.setTextColor(16384)
  24. end
  25. function black()
  26. term.setTextColor(32768)
  27. end
  28.  
  29. --Text Functions
  30.  
  31. function drawLine()
  32. print("---------------------------------------------------")
  33. end
  34. function centerText(text)
  35. local x,y = term.getSize()
  36. local x2,y2 = term.getCursorPos()
  37. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  38. write(text)
  39. end
  40.  
  41. function drawLogo(text)
  42. red()
  43. drawLine()
  44. white()
  45. centerText(text)
  46. red()
  47. drawLine()
  48. white()
  49. end
  50.  
  51. function drawSubLogo(text)
  52. centerText(text)
  53. red()
  54. drawLine()
  55. white()
  56. end
  57.  
  58. function drawTopLogo(text)
  59. red()
  60. drawLine()
  61. white()
  62. centerText(text)
  63. end
  64.  
  65. function clear()
  66. term.clear()
  67. term.setCursorPos(1,1)
  68. end
  69.  
  70. function press()
  71. red()
  72. centerText("~")
  73. yellow()
  74. centerText("Press anything to continue!")
  75. white()
  76. os.pullEvent("key")
  77. sleep(0.1)
  78. end
  79.  
  80. --Main Programs
  81. function drawMain()
  82. clear()
  83. drawLogo("StriteOS")
  84. drawSubLogo("~Version "..version.."!~")
  85. print()
  86. red()
  87. write("> ")
  88. white()
  89. local com = string.lower(read())
  90.   if com == "redstone" or com == "rs" then
  91.   redstone()
  92.   elseif com == "exit" or com == "out" then
  93.   exit()
  94.   elseif com == "help" or com == "programs" then
  95.   help()
  96.   elseif com == "edit" then
  97.   edit()
  98.   else
  99.   print()
  100.   centerText("Unknown command, please try again!")
  101.   print()
  102.   press()
  103.   drawMain()
  104.   end
  105. end
  106.  
  107. function rsC(side, colorName, colorNumber)
  108. term.setTextColor(colorNumber)
  109. local rsOnorOff = rs.testBundledInput(side, colorNumber)
  110.   if rsOnorOff == true then
  111.   centerText(colorName.." Cable Online!")
  112.   elseif rsOnorOff == false then
  113.   centerText(colorName.." Cable Offline!")
  114.   white()
  115.   end
  116. print()
  117. end
  118.  
  119. function rsCI()
  120. white true do
  121. local event, param = os.pullEvent()
  122.   if event == "key" then
  123.   break
  124.   else
  125.   rsC("bottom", "White", 1)
  126.   rsC("bottom", "Orange", 2)
  127.   rsC("bottom", "Magenta", 4)
  128.   rsC("bottom", "Light Blue", 8)
  129.   rsC("bottom", "Yellow", 16)
  130.   rsC("bottom", "Lime", 32)
  131.   end
  132. end
  133.  
  134. function redstone()
  135. local cablesNum = 6
  136. clear()
  137. drawLogo("StriteOS")
  138. drawSubLogo("Redstone Panel Tab!")
  139. print()
  140. centerText("-Available Cables-")
  141. print()
  142. rsCI()
  143. print()
  144. press()
  145. end
  146.  
  147. function help()
  148. clear()
  149. drawLogo("StriteOS")
  150. drawSubLogo("Help Tab!")
  151. centerText("Programs available:")
  152. print()
  153.   for i=1,#programs do
  154.   centerText("-"..programs[i].."-")
  155.   print()
  156.   end
  157. press()
  158. drawMain()
  159. end
  160.  
  161. function edit()
  162. clear()
  163. drawLogo("StriteOS")
  164. drawSubLogo("Editing Files Tab!")
  165. print()
  166. red()
  167. write("File's Name:> ")
  168. white()
  169. local fname = read()
  170.   if fname == "exit" or fname == "Exit" or fname == "leave" or fname == "Leave" then
  171.   print()
  172.   centerText("Exiting...")
  173.   press()
  174.   drawMain()
  175.   else
  176.     if fs.exists(fname) then
  177.     clear()
  178.     drawLogo("StriteOS")
  179.     drawSubLogo("Opening "..fname.."!")
  180.     sleep(0.6)
  181.     shell.run("edit "..fname)
  182.     else
  183.     print()
  184.     centerText("Sorry, that file does not exist.")
  185.     print()
  186.     sleep(0.2)
  187.     centerText("You should try the 'create' command!")
  188.     print()
  189.     sleep(0.2)
  190.     centerText("Type 'exit' to get back to the Desktop!")
  191.     print()
  192.     press()
  193.     sleep(0.2)
  194.     edit()
  195.     end
  196.   end
  197. end
  198.  
  199. function exit()
  200. clear()
  201. drawLogo("StriteOS")
  202. drawSubLogo("Are you sure you want to exit StriteOS? (y/n)")
  203. print()
  204. red()
  205. write("> ")
  206. white()
  207. local eyn = string.lower(read())
  208.   if eyn == "y" or eyn == "yes" then
  209.   term.clear()
  210.   term.setCursorPos(1,1)
  211.   drawLogo("StriteOS")
  212.   drawSubLogo("Exiting StriteOS.")
  213.   sleep(0.8)
  214.   shell.run("reboot")
  215.   elseif eyn == "n" or eyn == "no" then
  216.   term.clear()
  217.   term.setCursorPos(1,1)
  218.   drawLogo("StriteOS")
  219.   drawSubLogo("Returning to Desktop.")
  220.   sleep(0.8)
  221.   drawMain()
  222.   end
  223. end
  224.  
  225. --Main
  226. drawMain()
Advertisement
Add Comment
Please, Sign In to add comment