Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local branchLength = 32
- local turnRight = true
- local robot = require("robot");
- local component = require("component")
- local inv = component.inventory_controller
- function turnInBranchDir()
- if turnRight then
- robot.turnRight()
- else
- robot.turnLeft()
- end
- end
- function swingIfTool()
- if robot.durability() == nil then
- error('ERROR: no tool')
- end
- robot.swing()
- raiseIfInventoryFull()
- end
- function swingUpIfTool()
- if robot.durability() == nil then
- error('ERROR: no tool')
- end
- robot.swingUp()
- raiseIfInventoryFull()
- end
- function swingDownIfTool()
- if robot.durability() == nil then
- error('ERROR: no tool')
- end
- robot.swingDown()
- raiseIfInventoryFull()
- end
- function raiseIfInventoryFull()
- local allFull = true
- for i = 1, robot.inventorySize(), 1 do
- if inv.getStackInInternalSlot(i) == nil then
- allFull = false
- end
- end
- if allFull then
- error('ERROR: inventory full')
- end
- end
- function grabTool()
- end
- function mineForward()
- swingIfTool()
- robot.forward()
- swingUpIfTool()
- if not robot.detectDown() then
- robot.placeDown()
- end
- if not robot.detectDown() then
- error("ERROR: place failed!")
- end
- end
- function branch()
- turnInBranchDir()
- for i = 1, branchLength, 1 do
- mineForward()
- end
- robot.turnAround()
- for i = 1, branchLength, 1 do
- robot.forward()
- end
- turnInBranchDir()
- end
- -- while true do
- -- for i = 1, 4, 1 do
- -- mineForward()
- -- end
- -- branch()
- -- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement