Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local computer = require("computer")
- local shell = require("shell")
- function buildLayer()
- place3()
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- robot.back()
- place3()
- robot.turnLeft()
- robot.forward()
- robot.turnLeft()
- robot.back()
- place3()
- end
- function place3()
- for i = 0, 2, 1 do
- robot.forward()
- robot.placeDown()
- end
- end
- function buildRedstoneLayer()
- place3()
- robot.turnRight()
- robot.forward()
- robot.turnRight()
- robot.placeDown()
- robot.forward()
- robot.select(2)
- robot.placeDown()
- robot.select(1)
- robot.forward()
- robot.placeDown()
- robot.turnLeft()
- robot.forward()
- robot.turnLeft()
- robot.back()
- place3()
- end
- function returnToStart()
- for i = 0, 3, 1 do
- robot.back()
- end
- for i = 0, 2, 1 do
- robot.down()
- end
- robot.turnLeft()
- robot.forward()
- robot.forward()
- robot.turnRight()
- end
- function dropRedstone()
- robot.select(3)
- robot.drop(1)
- robot.select(1)
- end
- function reload()
- robot.up()
- robot.turnRight()
- robot.forward()
- robot.forward()
- robot.turnRight()
- robot.select(1)
- robot.suck(26)
- robot.turnLeft()
- robot.forward()
- robot.turnRight()
- robot.select(2)
- robot.suck(1)
- robot.turnLeft()
- robot.forward()
- robot.turnRight()
- robot.select(3)
- robot.suck(1)
- robot.turnRight()
- robot.down()
- for i = 0, 3, 1 do
- robot.forward()
- end
- robot.turnRight()
- robot.select(1)
- end
- function checkPower()
- return computer.energy() / computer.maxEnergy() < 0.3
- end
- local args, ops = shell.parse(...)
- for i = 0, args[1] - 1 , 1 do
- reload()
- robot.forward()
- if checkPower() then
- shell.execute('recharge')
- end
- robot.up()
- buildLayer()
- robot.up()
- robot.turnLeft()
- robot.turnLeft()
- robot.back()
- buildRedstoneLayer()
- robot.up()
- robot.turnLeft()
- robot.turnLeft()
- robot.back()
- buildLayer()
- returnToStart()
- dropRedstone()
- os.sleep(10)
- end
Add Comment
Please, Sign In to add comment