Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require("robot")
- local com = require("component")
- local sides = require("sides")
- local comp = require("computer")
- local os = require("os")
- local craft = com.crafting
- bat = comp.energy()
- slots = {1, 2, 5, 6}
- home = {0, 5, 10}
- function goHome()
- cleanUp()
- robot.up()
- robot.up()
- robot.turnRight()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.turnRight()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.turnRight()
- robot.turnRight()
- robot.down()
- robot.down()
- robot.down()
- end
- function pullStone(i)
- robot.select(i)
- return robot.suck(16)
- end
- function cleanUp()
- for i, slot in ipairs(slots) do
- robot.select(slot)
- robot.drop()
- end
- end
- function charge()
- com.redstone.setOutput(sides.back, 15)
- while(bat < 19800) do
- print("battery: ", bat)
- bat = comp.energy()
- end
- com.redstone.setOutput(sides.back, 0)
- end
- function work()
- robot.up()
- robot.up()
- robot.up()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.turnLeft()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.forward()
- robot.down()
- robot.down()
- robot.turnRight()
- end
- charge()
- work()
- while(true) do
- valid = true
- bat = comp.energy()
- if(bat < 10000 ) then
- os.execute("cls")
- goHome()
- charge()
- work()
- end
- red = com.redstone.getInput(sides.back)
- if(red > 1 ) then
- goHome()
- os.exit()
- end
- for i, slot in ipairs(slots) do
- if (pullStone(slot) ~= 16) then
- cleanUp()
- goHome()
- os.execute("cls")
- os.sleep(60)
- work()
- valid = false
- break
- end
- end
- if (valid) then
- robot.select(4)
- craft.craft(64)
- robot.dropDown()
- end
- end
Add Comment
Please, Sign In to add comment