Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local repairDrone = -1
- local status = {}
- term.setCursorPos(1,1)
- term.clear()
- print("Repair Drone Command Terminal V1.3")
- print("(C) 1989 KillaVanilla Industries")
- print("Subcomponents initalizing...")
- textutils.slowWrite("Checking: Redstone-Based Communications...")
- os.sleep(1)
- local modems = 0
- for i,v in ipairs(rs.getSides()) do
- if peripheral.getType(v) == "modem" then
- rednet.open(v)
- modems = modems+1
- end
- end
- if modems > 0 then
- term.setTextColor(colors.lime)
- print("good")
- else
- term.setTextColor(colors.red)
- print("failed")
- term.setTextColor(colors.white)
- print("System check failed: No modem found.")
- return
- end
- term.setTextColor(colors.white)
- textutils.slowPrint("Enter the ID of the drone you wish to control: ")
- textutils.slowWrite(">")
- while true do
- local input = tonumber(read())
- if input then
- repairDrone = input
- break
- end
- end
- term.setTextColor(colors.white)
- textutils.slowWrite("Checking: Remote Repair Unit...")
- os.sleep(1)
- rednet.send(repairDrone, "PING")
- local id, msg = rednet.receive(5)
- if id == nil then
- term.setTextColor(colors.red)
- print("failed")
- term.setTextColor(colors.white)
- print("System check failed: Could not contact drone.")
- os.reboot()
- else
- status = textutils.unserialize(msg)
- term.setTextColor(colors.lime)
- print("good")
- end
- term.setTextColor(colors.white)
- textutils.slowWrite("Checking: Robotics Supply Unit...")
- os.sleep(1)
- if (status[1] == "unlimited" or status[1] > 0) and (status[2] > 0) then
- term.setTextColor(colors.lime)
- print("good")
- else
- term.setTextColor(colors.red)
- print("failed")
- term.setTextColor(colors.white)
- print("System check failed: Not enough materials/fuel.")
- return
- end
- term.setTextColor(colors.white)
- os.sleep(1)
- textutils.slowWrite("Checking: Robotics Interpreter Unit...")
- os.sleep(1)
- term.setTextColor(colors.lime)
- print("good")
- term.setTextColor(colors.white)
- textutils.slowWrite("Checking: Secondary Communications Link...")
- os.sleep(1)
- term.setTextColor(colors.lime)
- print("good")
- term.setTextColor(colors.white)
- textutils.slowWrite("Beginning communications...")
- os.sleep(1)
- print("Ready.")
- os.sleep(2)
- local cmdHistory = {}
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("DRONE CONTROL UNIT:")
- write("Connected to repair drone ")
- term.setTextColor(colors.lime)
- write(repairDrone)
- term.setTextColor(colors.white)
- print(".")
- write("Fuel Level: ")
- term.setTextColor(colors.lime)
- print(status[1])
- term.setTextColor(colors.white)
- write("Materials Level: ")
- term.setTextColor(colors.lime)
- print(status[2])
- term.setTextColor(colors.white)
- write("drone"..repairDrone..">")
- local cmd = read(nil, cmdHistory)
- if string.lower(cmd) == "help" then
- term.clear()
- term.setCursorPos(1,1)
- print("Commands:")
- print("forward - Moves the drone forward 1 meter.")
- print("back - Moves the drone back 1 meter.")
- print("turnleft - Turns the drone to the left.")
- print("turnright - Turns the drone to the right.")
- print("up - Moves the drone up 1 meter.")
- print("down - Moves the drone down 1 meter.")
- print("place - Places materials directly beneath the drone.")
- os.pullEvent("key")
- else
- table.insert(cmdHistory, cmd)
- cmd = string.upper(cmd)
- os.sleep(0.5)
- rednet.send(repairDrone, cmd)
- local id, msg = rednet.receive(5)
- if id ~= nil then
- status = textutils.unserialize(msg)
- else
- printError("Error: Communications timeout.")
- return
- end
- if status[1] ~= "unlimited" then
- if status[1] == 0 then
- printError("Error: Drone is entering low-fuel mode...")
- return
- end
- end
- if status[2] == 0 then
- printError("Warning: Drone is out of repair materials!")
- end
- os.sleep(0.5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement