JoonBug03

buggy_program

Aug 14th, 2026 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.84 KB | None | 0 0
  1. local drive = peripheral.find("drive")
  2. local monitor = peripheral.find("monitor")
  3. local k = 0
  4. local diskName = ""
  5.  
  6. if monitor then
  7. local w, h = monitor.getSize()
  8. if w < 30 or h < 10 then
  9. monitor.setTextScale(0.5)
  10. end
  11. term.redirect(monitor)
  12. end
  13.  
  14. if not drive then
  15. print("Disk drive not found. Aborting...")
  16. return
  17. end
  18.  
  19. if not drive.isDiskPresent() then
  20. print("Disk not found. Please insert disk into drive.")
  21. while k == 0 do
  22. if os.pullEvent("disk") then
  23. print("Disk inserted. Continuing...")
  24. k = 1
  25. end
  26. end
  27. end
  28.  
  29. print("Please do not remove disk while the program is running.")
  30. sleep(3)
  31.  
  32. repeat
  33. term.clear()
  34. term.setCursorPos(1,1)
  35.  
  36. print("Would you like to change the Label of the disk currently in the drive? (Y/N)")
  37. local ans = read()
  38. if ans == "Y" or ans == "y" then
  39. repeat
  40. term.clear()
  41. term.setCursorPos(1,1)
  42. print("Would you like to write in a Custom Label? (Y/N)")
  43. ans = read()
  44. if ans == "Y" or ans == "y" then
  45. repeat
  46. term.clear()
  47. term.setCursorPos(1,1)
  48. write("Cutom Label: ")
  49. diskName = read()
  50. term.clear()
  51. term.setCursorPos(1,1)
  52. print("Disk will be labeled: " .. diskName)
  53. print("Confirm. (Y/N)")
  54. ans = read()
  55. if ans == "Y" or ans == "y" or ans == "N" or ans == "n" then
  56. else
  57. print("Invalid Argument.")
  58. sleep(1)
  59. end
  60. until ans == "Y" or ans == "y"
  61. elseif ans == "N" or ans == "n" then
  62. print("Disk will be named: Buggy Program")
  63. diskName = "Buggy Program"
  64. else
  65. print("Invalid argument.")
  66. sleep(1)
  67. end
  68. until ans == "Y" or ans == "y" or ans == "N" or ans == "n"
  69. elseif ans == "N" or ans == "n" then
  70. else
  71. print("Invalid argument.")
  72. sleep(1)
  73. end
  74. until ans == "Y" or ans == "y" or ans == "N" or ans == "n"
  75.  
  76. term.clear()
  77. term.setCursorPos(1,1)
  78.  
  79. write("Welcome to the Rotating Buggy Programmer!\nPlease enter the amount of activation Nodes your ride has: ")
  80.  
  81. repeat
  82. nRaw = read()
  83.  
  84. if not tonumber(nRaw) then
  85. print("Entered character is not valid.")
  86. write("Please enter the amount of activation Nodes your ride has: ")
  87. end
  88. until tonumber(nRaw)
  89.  
  90. local nodes = tonumber(nRaw)
  91. print("You have selected " .. nodes .. " nodes.")
  92. print("Generating execution files...")
  93. shell.run("pastebin", "get", "wvjtgrwe", "/disk/buggy_rotate")
  94. shell.run("pastebin", "get", "5F9aFUJ9", "/disk/buggy_trigger")
  95. local filePath = "/disk/buggy_startup"
  96. local file = fs.open(filePath, "w")
  97. if file then
  98. file.writeLine('shell.run("buggy_trigger",' .. nodes .. ')')
  99. else
  100. print("Error when creating buggy_startup. Aborting...")
  101. return
  102. end
  103.  
  104. filePath = "/disk/startup"
  105. file = fs.open(filePath, "w")
  106.  
  107. if file then
  108. file.writeLine('fs.copy("/disk/buggy_trigger", "buggy_trigger")')
  109. file.writeLine('fs.copy("/disk/buggy_rotate", "buggy_rotate")')
  110. file.writeLine('fs.copy("/disk/buggy_startup", "startup")')
  111. file.writeLine('fs.copy("/disk/nodes/", "/nodes/")')
  112. file.writeLine('local drive = peripheral.find("drive")')
  113. file.writeLine('drive.ejectDisk()')
  114. else
  115. print("Error when creating startup. Aborting...")
  116. return
  117. end
  118. if not diskName == "" then
  119. drive.setDiskLabel(diskName)
  120. end
  121.  
  122. print("Execution Files created. Moving to create node files.")
  123.  
  124. sleep(2)
  125.  
  126. for x = 1, nodes do
  127. filePath = "/disk/nodes/node" .. x
  128. file = fs.open(filePath, "w")
  129.  
  130. term.clear()
  131. term.setCursorPos(1,1)
  132.  
  133. if file then
  134. print("Creating file: " .. filePath)
  135. sleep(1)
  136. print("Set Rotate degrees and speed/direction for Node " .. x)
  137. print("(Degrees are an integer from 1-360)")
  138. write("Node ".. x .. "> Enter turn degrees: ")
  139. local deg = tonumber(read())
  140.  
  141. while not deg or deg < 1 or deg > 360 do
  142. print("Invalid entry. Retry.")
  143. print("(Degrees are an integer from 1-360)")
  144. write("Node ".. x .. "> Enter turn degrees: ")
  145. deg = tonumber(read())
  146. end
  147.  
  148.  
  149. print("Node " .. x .. "> Degrees set.")
  150. sleep(1)
  151. print("(2 = CW 2x Speed | 1 = CW 1x Speed | -1 = CCW 1x Speed | -2 = CCW 2x Speed)")
  152. write("Node ".. x .. "> Enter speed/direction: ")
  153. local speed = tonumber(read())
  154.  
  155. while speed ~= -2 and speed ~= -1 and speed ~= 1 and speed ~= 2 do
  156. print("Invalid entry. Retry.")
  157. print("(2 = CW 2x Speed| 1 = CW 1x Speed | -1 = CCW 1x Speed | -2 = CCW 2x Speed)")
  158. write("Node ".. x .. "> Enter speed/direction: ")
  159. speed = tonumber(read())
  160. end
  161.  
  162. print("Node " .. x .. "> Speed/Direction set.")
  163. sleep(1)
  164.  
  165.  
  166. file.writeLine('local gearshift = peripheral.find("Create_SequencedGearshift")')
  167. file.writeLine('gearshift.setInstructions( { {speed_modifier = ' .. speed .. ', type = "turn_angle", value = ' .. deg .. '},{ speed_modifier = 1, type = "end", value = 1} } )')
  168. file.writeLine('gearshift.start()')
  169. end
  170. end
  171.  
  172. term.clear()
  173. term.setCursorPos(1,1)
  174.  
  175. print("All Node Files Created.")
  176. print("Finishing disk...")
  177.  
  178. print("Please wait...")
  179. sleep(3)
  180.  
  181. term.clear()
  182. term.setCursorPos(1,1)
  183.  
  184. print("Finished! Disk will eject itself when ready.")
  185. sleep(1)
  186. print("Disk will now boot Buggy Program on attached Computer Startup.")
  187. sleep(1)
  188. print("Goodbye.")
  189. drive.ejectDisk()
Advertisement
Add Comment
Please, Sign In to add comment