Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local robot = require('robot')
- local api = {}
- local chest_robot = 16
- function api.forward()
- while true do
- if robot.forward() then break else robot.swing() end
- end
- end
- function api.kop()
- for i = 1, 16 do
- if robot.detectUp() then robot.swingUp() end
- if robot.detect() and i ~=16 then robot.swing()end
- if robot.detectDown() then robot.swingDown() end
- if i ~= 16 then
- api.forward()
- end
- end
- end
- function api.down()
- for i = 1, 3 do
- if robot.detectDown() then robot.swingDown() end
- robot.down()
- if i ~= 3 then robot.turnLeft() end
- end
- end
- function api.turn(info, n)
- if info == n then
- robot.turnRight()
- if robot.detect() then api.forward() end
- robot.forward()
- robot.turnRight()
- else
- robot.turnLeft()
- if robot.detect() then api.forward() end
- robot.forward()
- robot.turnLeft()
- end
- end
- function api.drop()
- robot.select(chest_robot)
- if robot.count() ~= 0 then
- robot.select(1)
- robot.swing()
- robot.up()
- robot.swing()
- robot.down()
- if robot.place(1) then
- for i = 2, chest_robot do
- robot.select(i)
- robot.drop()
- end
- end
- end
- robot.select(1)
- end
- function api.mine(y)
- local n = 0,5
- for i = 1, y / 3 do
- for j = 1, 16 do
- api.kop()
- api.drop()
- _, info = math.modf(j / 2)
- if j ~= 16 then api.turn(info, n) end
- end
- if n == 0.5 then n = 0 else n = 0.5 end
- api.down()
- end
- end
- return api
Advertisement
Add Comment
Please, Sign In to add comment