Advertisement
LazerAio

startup.lua

Apr 5th, 2022
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. term.setBackgroundColor(colors.purple)
  2. term.clear()
  3. UsrPin = "1"
  4. if peripheral.isPresent("left","speaker") then
  5. SPEAKER = peripheral.wrap("left")
  6. elseif peripheral.isPresent("right","speaker") then
  7. SPEAKER = peripheral.wrap("right")
  8. elseif peripheral.isPresent("top","speaker") then
  9. SPEAKER = peripheral.wrap("top")
  10. elseif peripheral.isPresent("bottom","speaker") then
  11. SPEAKER = peripheral.wrap("bottom")
  12. end
  13. if SPEAKER == nil then
  14. print("No speaker found")
  15. SPEAKERPRESENT = false
  16. else
  17. print("Found speaker")
  18. SPEAKERPRESENT = true
  19. SPEAKER.playNote("bell",50,1)
  20. sleep(0.1)
  21. SPEAKER.playNote("bell",50,2)
  22. sleep(0.1)
  23. SPEAKER.playNote("bell",50,1)
  24. sleep(0.2)
  25. SPEAKER.playNote("bell",50,5)
  26. end
  27. shell.run("dj")
  28. print("WAIT")
  29. sleep(0)
  30. function ErrorLog(E)
  31. if SPEAKERPRESENT == true then
  32. SPEAKER.playNote("banjo",5,0)
  33. end
  34. if LOG == nil then
  35. LOG = {}
  36. end
  37. LOG[#LOG+1] = E
  38. end
  39. function PANIC(E)
  40. if SPEAKERPRESENT == true then
  41. SPEAKER.playNote("banjo",20,0)
  42. sleep(0.1)
  43. SPEAKER.playNote("banjo",20,0)
  44. end
  45. ErrorLog(E)
  46. term.setCursorPos(1,1)
  47. term.setBackgroundColor(colors.black)
  48. term.setTextColor(colors.white)
  49. print("A CRITICAL ERROR OCURRED")
  50. print("YOUR COMPUTER HAS BEEN PAUSED WITH THE ERROR:")
  51. print(E)
  52. print("THE COMPUTER WILL ATTEMPT TO CONTINUE SHORTLY")
  53. sleep(10)
  54. end
  55. function DrawIMG(File,X,Y)
  56. OX,OY = term.getCursorPos()
  57. if fs.exists(File) then
  58. local I = (paintutils.loadImage(File))
  59. paintutils.drawImage(I,X,Y)
  60. else
  61. ErrorLog("Cant draw file,"..File.." does not exist")
  62. end
  63. end
  64. function DrawBG()
  65. OX,OY = term.getCursorPos()
  66. term.setCursorPos(1,1)
  67. if fs.exists("AIOS/.EXPLORER/BG.nfp") then
  68. local I = paintutils.loadImage("AIOS/.EXPLORER/BG.nfp")
  69. paintutils.drawImage(I,1,1)
  70. else
  71. term.setBackgroundColor(colors.purple)
  72. term.clear()
  73. ErrorLog("BG.nfp not found")
  74. end
  75. end
  76. function MainMenu()
  77. if fs.exists("AIOS/") then
  78. if fs.exists("AIOS/.EXPLORER/BG.nfp") then
  79. DrawBG()
  80. else
  81. ErrorLog("BG.nfp not found")
  82. end
  83. if fs.exists("AIOS/.EXPLORER/") then
  84. while true do
  85. sleep(0.1)
  86. DrawBG()
  87. W,H = term.getSize()
  88. DrawIMG("AIOS/.EXPLORER/ICONS/WEB",7,1)
  89. App_WEB_X = 7
  90. App_WEB_Y = 1
  91. DrawIMG("AIOS/.EXPLORER/ICONS/RECYCLE",1,7)
  92. App_RECYCLE_X = 1
  93. App_RECYCLE_Y = 7
  94. DrawIMG("AIOS/.EXPLORER/ICONS/SHOP",7,7)
  95. App_SHOP_X = 7
  96. App_SHOP_Y = 7
  97. DrawIMG("AIOS/.EXPLORER/ICONS/EXPLORER",1,1)
  98. App_EXPLORER_X = 1
  99. App_EXPLORER_Y = 1
  100. DrawIMG("AIOS/.EXPLORER/ICONS/START",1,H-1)
  101. E,K,X,Y = os.pullEvent()
  102. EVENT = E
  103. if EVENT == "mouse_click" then
  104. term.setCursorPos(1,1)
  105. sleep(0)
  106. if X == App_WEB_X and Y == App_WEB_Y then
  107. if fs.exists("ARE.lua") then
  108. shell.run("ARE")
  109. else
  110. ErrorLog("ARE.lua NOT FOUND")
  111. end
  112. elseif X == App_EXPLORER_X and Y == App_EXPLORER_Y then
  113. if fs.exists("FM2.lua") or fs.exists("FM2") then
  114. shell.run("FM2")
  115. shell.run("fg ls")
  116. shell.run("cd ..")
  117. else
  118. ErrorLog("EXPLORER.lua NOT FOUND")
  119. end
  120. elseif X == App_SHOP_X and Y == App_SHOP_Y then
  121. if fs.exists("APM.lua") or fs.exists("APM") then
  122. term.clear()
  123. shell.run("APM list")
  124. print("select package to install or type exit to exit")
  125. local INP = read()
  126. if INP == "exit" then
  127. else
  128. shell.run("APM install",INP)
  129. end
  130. else
  131. ErrorLog("APM NOT FOUND")
  132. end
  133. elseif X == App_RECYCLE_X and Y == App_RECYCLE_Y then
  134. if fs.exists("AIOS/RECYCLE/") then
  135. if fs.exists("FM2.lua") then
  136. shell.run("FM2.lua","AIOS/RECYCLE")
  137. shell.run("fg ls")
  138. shell.run("cd ..")
  139. else
  140. ErrorLog("EXPLORER.lua NOT FOUND")
  141. end
  142. else
  143. ErrorLog("DIR RECYCLE NOT FOUND")
  144. end
  145. end
  146. elseif E == "key" then
  147. if K == string.byte("S") then
  148. shell.run("fg")
  149. end
  150. end
  151. end
  152. else
  153. PANIC("EXPLORER NOT FOUND!")
  154. shell.run("fg")
  155. end
  156. end
  157. end
  158. MainMenu()
  159. sleep(1)
  160. PANIC("SYSTEM PROGRAM STACK END REACHED!")
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement