Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local term = require("term")
- local computer = require("computer")
- local component = require("component")
- local sides = require("sides")
- local keyboard = require("keyboard")
- local function Sleepy()
- while computer.energy() < 20000 do
- os.sleep(20)
- end
- end
- local function DumpAll()
- for i = 1, robot.inventorySize() do
- robot.select(i)
- robot.drop()
- end
- robot.select(1);
- Sleepy()
- end
- local function safeForward(x)
- if (x ~= 0) then
- for i = 1, x do
- local canmoveF = nil
- while (canmoveF == nil) do
- canmoveF = robot.forward()
- end
- end
- end
- end
- local function safeUp(x)
- if (x ~= 0) then
- for i = 1, x do
- local canmoveU = nil
- while (canmoveU == nil) do
- canmoveU = robot.up()
- end
- end
- end
- end
- local function safeDown(x)
- if (x ~= 0) then
- for i = 1, x do
- local canmoveD = nil
- while (canmoveD == nil) do
- canmoveD = robot.down()
- end
- end
- end
- end
- local function driveHandler(highX, wideX, driveX, backX)
- robot.turnLeft()
- drivePresent = false
- component.sign.setValue("High: " .. highX + 1 .. "\nWide: " .. wideX + 1 .. "\nDrive: " .. driveX + 1 .. "\nTime: " .. os.clock())
- safeUp(2)
- robot.turnLeft()
- safeUp(highX)
- safeForward(wideX)
- robot.turnLeft()
- if (backX == false) then
- drivePresent = component.inventory_controller.suckFromSlot(3, driveX + 1)
- if (drivePresent == 1) then
- component.inventory_controller.equip()
- end
- end
- if (backX == true) then
- component.inventory_controller.equip()
- component.inventory_controller.dropIntoSlot(3, driveX + 1)
- end
- robot.turnLeft()
- safeForward(wideX)
- safeDown(highX)
- safeDown(1)
- if (backX == false) then
- if (drivePresent == 1) then
- component.inventory_controller.equip()
- component.inventory_controller.dropIntoSlot(3, 1)
- end
- end
- safeDown(1)
- if (drivePresent == 1) then
- return true
- end
- if (drivePresent ~= 1) then
- return false
- end
- end
- -- init
- robot.select(1);
- -- find startposition
- local canmove = true
- local infront = true
- local useless = true
- local high = 1
- local wide = 1
- local drive = 1
- local back = false
- local drivePresentInRobot = false
- while (canmove == true) do
- canmove = robot.down()
- end
- while (infront ~= "passable") do
- useless, infront = robot.detect()
- canmove = true
- while (canmove == true) do
- canmove = robot.forward()
- end
- robot.turnLeft()
- useless, infront = robot.detect()
- end
- component.sign.setValue("\nBooting Up")
- robot.turnLeft()
- safeForward(3)
- safeUp(2)
- DumpAll()
- component.inventory_controller.equip()
- DumpAll()
- robot.turnAround()
- safeDown(2)
- safeForward(3)
- --do loop
- while true do
- for high = 1, 8 do
- for wide = 1, 4 do
- for drive = 1, 10 do
- os.sleep(1)
- drivePresentInRobot = false
- drivePresentInRobot = driveHandler(high - 1, wide - 1, drive - 1, false)
- if (drivePresentInRobot == true) then
- local finished = false
- while (finished == false) do
- finished = component.inventory_controller.suckFromSlot(3,1)
- os.sleep(1)
- end
- component.inventory_controller.equip()
- driveHandler(high - 1, wide - 1, drive - 1, true)
- end
- end
- end
- end
- robot.turnLeft()
- for sleeep = 1, 60 do
- component.sign.setValue("Sleeping ...\n" .. sleeep .. "/60")
- os.sleep(60)
- end
- robot.turnRight()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement