Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local c = require("component")
- local r = require("robot")
- local pc = require("computer")
- local sh = require("shell")
- local ic = c.inventory_controller
- length = 160
- torchLen = 9
- minEnergy = 10000
- invSize = r.inventorySize()
- function suckAll()
- while c.tractor_beam.suck() do
- end
- end
- function move()
- bE,sE = r.detect()
- while sE ~= "air" do
- os.sleep(1)
- bE, sE = r.detect()
- end
- r.forward()
- end
- function printInfo(i)
- sh.execute("clear")
- print(i)
- end
- function pushToInventory()
- for j=1, invSize-3 do
- r.select(j)
- r.drop()
- end
- end
- function digUp()
- if not r.swingUp() then
- r.select(invSize-2)
- ic.equip()
- r.swingUp()
- ic.equip()
- end
- end
- function dig()
- if not r.swing() then
- r.select(invSize-2)
- ic.equip()
- r.swing()
- ic.equip()
- end
- end
- function digDown()
- if not r.swingDown() then
- r.select(invSize-2)
- ic.equip()
- r.swingDown()
- ic.equip()
- end
- end
- function craftPickAndCharge(lenFromHome)
- r.turnAround()
- r.down()
- for k=1, lenFromHome do
- if not r.detectDown() then
- r.select(invSize-1)
- r.placeDown()
- end
- move()
- end
- r.turnRight()
- pushToInventory()
- while pc.energy() < minEnergy do
- os.sleep(5)
- end
- for k = 1, 3 do
- r.select(k)
- ic.suckFromSlot(3, 1, 1)
- end
- r.select(6)
- ic.suckFromSlot(3,2,1)
- r.select(10)
- ic.suckFromSlot(3,2,1)
- c.crafting.craft(1)
- r.select(9)
- ic.equip()
- c.crafting.craft(1)
- ic.equip()
- r.turnRight()
- for k=1, lenFromHome do
- move()
- end
- r.up()
- end
- function digTD()
- dig()
- move()
- digUp()
- digDown()
- end
- r.up()
- for i=1, length do
- printInfo(i)
- bB, sB = r.detect()
- if sB == "solid" then
- digTD()
- r.turnLeft()
- digTD()
- if i%torchLen == 0 then
- r.select(invSize)
- r.placeUp(3, false)
- end
- r.turnAround()
- move()
- digTD()
- r.turnAround()
- move()
- r.turnRight()
- if r.durability() < 0.12 then
- craftPickAndCharge(i)
- end
- else
- move()
- end
- end
- r.turnAround()
- for i=1, length do
- move()
- end
- r.down()
- r.turnRight()
- pushToInventory()
- r.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement