Guest User

startup

a guest
Mar 27th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3.  
  4. local version = "0.1"
  5.  
  6. --Color Set Functions--
  7. function white()
  8. term.setTextColor(1)
  9. end
  10. function yellow()
  11. term.setTextColor(16)
  12. end
  13. function blue()
  14. term.setTextColor(2048)
  15. end
  16. function green()
  17. term.setTextColor(8192)
  18. end
  19. function red()
  20. term.setTextColor(16384)
  21. end
  22. function black()
  23. term.setTextColor(32768)
  24. end
  25.  
  26. --Text Functions
  27.  
  28. function drawLine()
  29. print("---------------------------------------------------")
  30. end
  31. function centerText(text)
  32. local x,y = term.getSize()
  33. local x2,y2 = term.getCursorPos()
  34. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  35. write(text)
  36. end
  37.  
  38. function drawLogo(text)
  39. red()
  40. drawLine()
  41. white()
  42. centerText(text)
  43. red()
  44. drawLine()
  45. white()
  46. end
  47.  
  48. function drawSubLogo(text)
  49. centerText(text)
  50. red()
  51. drawLine()
  52. white()
  53. end
  54.  
  55. function clear()
  56. term.clear()
  57. term.setCursorPos(1,1)
  58. end
  59.  
  60. function press()
  61. red()
  62. centerText("~")
  63. yellow()
  64. centerText("Press anything to continue!")
  65. white()
  66. os.pullEvent("key")
  67. end
  68.  
  69. --Main Programs
  70. function drawMain()
  71. clear()
  72. drawLogo("StriteOS")
  73. drawSubLogo("~Version "..version.."!~")
  74. print()
  75. yellow()
  76. write("> ")
  77. white()
  78. local com = read()
  79.   if com == "Redstone" or "redstone" or "rs" then
  80.   redstone()
  81.   elseif com == "Exit" or "exit" or "Out" or "out" then
  82.   exit()
  83.   end
  84. end
  85.  
  86. function redstone()
  87. print ("Function not done, try again later!")
  88. print ()
  89. press()
  90. drawMain()
  91. end
  92.  
  93. function exit()
  94. term.clear()
  95. term.setCursorPos(1,1)
  96. drawLogo("StriteOS")
  97. drawSubLogo("Are you sure you want to exit StriteOS? (y/n)")
  98. print()
  99. yellow()
  100. write("> ")
  101. white()
  102. local exitYN = read()
  103.   if exitYN == "y" or "Y" or "yes" or "YES" or "Yes" then
  104.   term.clear()
  105.   term.setCursorPos(1,1)
  106.   drawLogo("StriteOS")
  107.   drawSubLogo("Exiting StriteOS...")
  108.   sleep(0.8)
  109.   shell.run("reboot")
  110.   elseif exitYN == "n" or "N" or "No" or "NO" or "No" then
  111.   term.clear()
  112.   term.setCursorPos(1,1)
  113.   drawLogo("StriteOS")
  114.   drawSubLogo("Going back to Desktop...")
  115.   sleep(0.8)
  116.   drawMain()
  117.   end
  118. end
  119.  
  120. --Main
  121. drawMain()
Advertisement
Add Comment
Please, Sign In to add comment