Guest User

Untitled

a guest
Feb 6th, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. devmode = true
  2. newuserdev = false
  3. --first we set ye color values
  4. glcolors = {}
  5. glcolors.red = 0xff3333
  6. glcolors.blue = 0x7dd2e4
  7. glcolors.yellow = 0xffff4d
  8. glcolors.green = 0x4dff4d
  9. glcolors.gray = 0xe0e0e0
  10. glcolors.textGray = 0x676767
  11. glcolors.text = 0x5a5a5
  12. glcolors.otherBlue = 0x2e679f
  13. glcolors.black = 0x000000
  14. --second, we ensure the user isn't wasting an advanced cpu
  15. if term.isColor() == true and devmode == false then
  16. print("Error: You are on an advanced computer. This program will not allow other programs to be ran. Do you wish to continue anyway?(y/n, caps count)")
  17. answer = read()
  18. if answer == "n" then
  19. error("User opted out")
  20. end
  21. end
  22. function getSide()
  23. print("Which side is the Terminal Glasses Bridge on?(top bottom left right back, caps count) ")
  24. side = read()
  25. sw = fs.open("glassside", "w")
  26. sw.writeLine(side)
  27. sw.close()
  28. print("What is your desired username?")
  29. username = read()
  30. sw = fs.open("username", "w")
  31. sw.writeLine(username)
  32. sw.close()
  33. print("Now, if you havn't already, take the terminal glasses you're going to use and right-click the terminal bridge.")
  34. end
  35. function load()
  36. dir = "CCGlass/"
  37. --note that this still runs on first time
  38. on = true
  39. gs = fs.open("glassside", "r")
  40. side = gs.readLine()
  41. gs.close()
  42. glass = peripheral.wrap(side)
  43. gs = fs.open("username", "r")
  44. username = gs.readLine()
  45. gs.close()
  46. end
  47. --Ye first thing where we draw stuff
  48. function firstDraw()
  49. oneText= glass.addText(10, 27.9, " ", glcolors.green)
  50. twoText= glass.addText(10, 27.9, " ", glcolors.green)
  51. threeText= glass.addText(10, 27.9, " ", glcolors.green)
  52. fourText= glass.addText(10, 27.9, " ", glcolors.green)
  53. fiveText= glass.addText(10, 27.9, " ", glcolors.green)
  54. midText= glass.addText(29, 27.9, " ", glcolors.green)
  55. highText= glass.addText(29, 27.9, " ", glcolors.red)
  56. lowText= glass.addText(29, 27.9, " ", glcolors.otherBlue)
  57. leftBox = glass.addBox(5, 0, 5, 60, glcolors.blue, 0.75)
  58. bigBox = glass.addBox(10, 5, 48, 50, glcolors.gray, 0.75)
  59. for bigWidth = 1, 20 do
  60. bigBox.setWidth(bigWidth * 7.5)
  61. sleep(0.01)
  62. end
  63. leftBox = glass.addBox(160, 0, 5, 60, glcolors.blue, 0.75)
  64. --Putting default text
  65. end
  66. --The way the OS prints stuffs to the screen
  67. function midPrint(text)
  68. midText.setText(text)
  69. midText.setScale(2)
  70. midText.setZIndex(1)
  71. w = bigBox.getWidth()
  72. tw = midText.getWidth()
  73. tw = tw*2
  74. posx = math.floor(w-tw)/2, 2
  75. posx = posx +10
  76. midText.setX(posx)
  77. posy = 20
  78. midText.setY(posy)
  79. end
  80. function highPrint(text)
  81. highText.setZIndex(1)
  82. local w = bigBox.getWidth() --=150
  83. highText.setText(text)
  84. tw = highText.getWidth()
  85. hposx = math.floor(w-tw)/2, 2
  86. hposx = hposx+10
  87. highText.setX(hposx)
  88. posy = 10
  89. highText.setY(posy)
  90. end
  91. function lowPrint(text)
  92. local w = bigBox.getWidth()
  93. lowText.setText(text)
  94. lowText.setZIndex(1)
  95. tw = lowText.getWidth()
  96. posx = math.floor(w-tw)/2, 2
  97. posx = posx +10
  98. lowText.setX(posx)
  99. lowText.setY(40)
  100. end
  101. --now we define print functions for books and such
  102. function tinyPrint(text, line, color)
  103. local w = bigBox.getWidth()
  104. if line == 1 then
  105. oneText.setY(5)
  106. oneText.setColor(color)
  107. oneText.setZIndex(1)
  108. oneText.setText(text)
  109. elseif line == 2 then
  110. twoText.setY(15)
  111. twoText.setColor(color)
  112. twoText.setZIndex(1)
  113. twoText.setText(text)
  114. elseif line == 3 then
  115. threeText.setY(25)
  116. threeText.setColor(color)
  117. threeText.setZIndex(1)
  118. threeText.setText(text)
  119. elseif line == 4 then
  120. fourText.setY(35)
  121. fourText.setColor(color)
  122. fourText.setZIndex(1)
  123. fourText.setText(text)
  124. elseif line == 5 then
  125. fiveText.setY(45)
  126. fiveText.setColor(color)
  127. fiveText.setZIndex(1)
  128. fiveText.setText(text)
  129. end
  130. end
  131. function tinyClear()
  132. tinyPrint(" ", 1, glcolors.red)
  133. tinyPrint(" ", 2, glcolors.red)
  134. tinyPrint(" ", 3, glcolors.red)
  135. tinyPrint(" ", 4, glcolors.red)
  136. tinyPrint(" ", 5, glcolors.red)
  137. end
  138. function bigClear()
  139. highPrint(" ")
  140. midPrint(" ")
  141. lowPrint(" ")
  142. end
  143. --now we launch apps based on what the user inputs
  144. function homeScreenLaunch()
  145. tinyClear()
  146. evt, cmd = os.pullEvent("chat_command")
  147. if cmd == "apps" then
  148. launchApps()
  149. elseif cmd == "shutdown" then
  150. on = false
  151. elseif cmd == "help" then
  152. shell.run('CCGlass/ccghelp')
  153. elseif cmd == "easteregg" then
  154. username = "You have found the easter egg that breaks glass. Congratulations on your find!"
  155. else
  156. reprintHome()
  157. end
  158. reprintHome()
  159. end
  160. --now we launch 3rd party and default apps
  161. function launchApps()
  162. tinyClear()
  163. highPrint("Launcher v0.001")
  164. midPrint(" ")
  165. lowPrint("Usage: $$appname")
  166. evt, cmd = os.pullEvent("chat_command")
  167. ok, error = pcall(shell.run("CCGlass/"..cmd.." "))
  168. reprintHome()
  169. end
  170. --now we can reprint the homescreen
  171. function reprintHome()
  172. tinyClear()
  173. highPrint("Welcome, "..username.."!")
  174. midPrint("V0.0001")
  175. lowPrint("Do $$help for help.")
  176. end
  177. --firsttime?
  178. if fs.exists("glassside") == false or newuserdev == true then
  179. getSide()
  180. end
  181. --here comes the advanced print function
  182. function bookprint()
  183. end
  184. --[[begin execution]]
  185. load()
  186. firstDraw()
  187. reprintHome()
  188. while on == true do
  189. homeScreenLaunch()
  190. end
  191. shell.run('clear')
Advertisement
Add Comment
Please, Sign In to add comment