Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drive = peripheral.find("drive")
- local monitor = peripheral.find("monitor")
- local k = 0
- local diskName = ""
- if monitor then
- local w, h = monitor.getSize()
- if w < 30 or h < 10 then
- monitor.setTextScale(0.5)
- end
- term.redirect(monitor)
- end
- if not drive then
- print("Disk drive not found. Aborting...")
- return
- end
- if not drive.isDiskPresent() then
- print("Disk not found. Please insert disk into drive.")
- while k == 0 do
- if os.pullEvent("disk") then
- print("Disk inserted. Continuing...")
- k = 1
- end
- end
- end
- print("Please do not remove disk while the program is running.")
- sleep(3)
- repeat
- term.clear()
- term.setCursorPos(1,1)
- print("Would you like to change the Label of the disk currently in the drive? (Y/N)")
- local ans = read()
- if ans == "Y" or ans == "y" then
- repeat
- term.clear()
- term.setCursorPos(1,1)
- print("Would you like to write in a Custom Label? (Y/N)")
- ans = read()
- if ans == "Y" or ans == "y" then
- repeat
- term.clear()
- term.setCursorPos(1,1)
- write("Cutom Label: ")
- diskName = read()
- term.clear()
- term.setCursorPos(1,1)
- print("Disk will be labeled: " .. diskName)
- print("Confirm. (Y/N)")
- ans = read()
- if ans == "Y" or ans == "y" or ans == "N" or ans == "n" then
- else
- print("Invalid Argument.")
- sleep(1)
- end
- until ans == "Y" or ans == "y"
- elseif ans == "N" or ans == "n" then
- print("Disk will be named: Buggy Program")
- diskName = "Buggy Program"
- else
- print("Invalid argument.")
- sleep(1)
- end
- until ans == "Y" or ans == "y" or ans == "N" or ans == "n"
- elseif ans == "N" or ans == "n" then
- else
- print("Invalid argument.")
- sleep(1)
- end
- until ans == "Y" or ans == "y" or ans == "N" or ans == "n"
- term.clear()
- term.setCursorPos(1,1)
- write("Welcome to the Rotating Buggy Programmer!\nPlease enter the amount of activation Nodes your ride has: ")
- repeat
- nRaw = read()
- if not tonumber(nRaw) then
- print("Entered character is not valid.")
- write("Please enter the amount of activation Nodes your ride has: ")
- end
- until tonumber(nRaw)
- local nodes = tonumber(nRaw)
- print("You have selected " .. nodes .. " nodes.")
- print("Generating execution files...")
- shell.run("pastebin", "get", "wvjtgrwe", "/disk/buggy_rotate")
- shell.run("pastebin", "get", "5F9aFUJ9", "/disk/buggy_trigger")
- local filePath = "/disk/buggy_startup"
- local file = fs.open(filePath, "w")
- if file then
- file.writeLine('shell.run("buggy_trigger",' .. nodes .. ')')
- else
- print("Error when creating buggy_startup. Aborting...")
- return
- end
- filePath = "/disk/startup"
- file = fs.open(filePath, "w")
- if file then
- file.writeLine('fs.copy("/disk/buggy_trigger", "buggy_trigger")')
- file.writeLine('fs.copy("/disk/buggy_rotate", "buggy_rotate")')
- file.writeLine('fs.copy("/disk/buggy_startup", "startup")')
- file.writeLine('fs.copy("/disk/nodes/", "/nodes/")')
- file.writeLine('local drive = peripheral.find("drive")')
- file.writeLine('drive.ejectDisk()')
- else
- print("Error when creating startup. Aborting...")
- return
- end
- if not diskName == "" then
- drive.setDiskLabel(diskName)
- end
- print("Execution Files created. Moving to create node files.")
- sleep(2)
- for x = 1, nodes do
- filePath = "/disk/nodes/node" .. x
- file = fs.open(filePath, "w")
- term.clear()
- term.setCursorPos(1,1)
- if file then
- print("Creating file: " .. filePath)
- sleep(1)
- print("Set Rotate degrees and speed/direction for Node " .. x)
- print("(Degrees are an integer from 1-360)")
- write("Node ".. x .. "> Enter turn degrees: ")
- local deg = tonumber(read())
- while not deg or deg < 1 or deg > 360 do
- print("Invalid entry. Retry.")
- print("(Degrees are an integer from 1-360)")
- write("Node ".. x .. "> Enter turn degrees: ")
- deg = tonumber(read())
- end
- print("Node " .. x .. "> Degrees set.")
- sleep(1)
- print("(2 = CW 2x Speed | 1 = CW 1x Speed | -1 = CCW 1x Speed | -2 = CCW 2x Speed)")
- write("Node ".. x .. "> Enter speed/direction: ")
- local speed = tonumber(read())
- while speed ~= -2 and speed ~= -1 and speed ~= 1 and speed ~= 2 do
- print("Invalid entry. Retry.")
- print("(2 = CW 2x Speed| 1 = CW 1x Speed | -1 = CCW 1x Speed | -2 = CCW 2x Speed)")
- write("Node ".. x .. "> Enter speed/direction: ")
- speed = tonumber(read())
- end
- print("Node " .. x .. "> Speed/Direction set.")
- sleep(1)
- file.writeLine('local gearshift = peripheral.find("Create_SequencedGearshift")')
- file.writeLine('gearshift.setInstructions( { {speed_modifier = ' .. speed .. ', type = "turn_angle", value = ' .. deg .. '},{ speed_modifier = 1, type = "end", value = 1} } )')
- file.writeLine('gearshift.start()')
- end
- end
- term.clear()
- term.setCursorPos(1,1)
- print("All Node Files Created.")
- print("Finishing disk...")
- print("Please wait...")
- sleep(3)
- term.clear()
- term.setCursorPos(1,1)
- print("Finished! Disk will eject itself when ready.")
- sleep(1)
- print("Disk will now boot Buggy Program on attached Computer Startup.")
- sleep(1)
- print("Goodbye.")
- drive.ejectDisk()
Advertisement
Add Comment
Please, Sign In to add comment