Advertisement
Guest User

wb

a guest
Mar 31st, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. local c = require("component")
  2. local r = require("robot")
  3. local pc = require("computer")
  4. local sh = require("shell")
  5. local ic = c.inventory_controller
  6. length = 160
  7. torchLen = 9
  8. minEnergy = 10000
  9. invSize = r.inventorySize()
  10.  
  11. function suckAll()
  12.   while c.tractor_beam.suck() do
  13.   end
  14. end
  15.  
  16. function move()
  17.   bE,sE = r.detect()
  18.   while sE ~= "air" do
  19.     os.sleep(1)
  20.     bE, sE = r.detect()
  21.   end
  22.   r.forward()
  23. end
  24.  
  25. function printInfo(i)
  26.   sh.execute("clear")
  27.   print(i)
  28. end
  29.  
  30. function pushToInventory()
  31.   for j=1, invSize-3 do
  32.     r.select(j)
  33.     r.drop()
  34.   end
  35. end
  36.  
  37. function digUp()
  38.   if not r.swingUp() then
  39.     r.select(invSize-2)
  40.     ic.equip()
  41.     r.swingUp()
  42.     ic.equip()
  43.   end
  44. end
  45. function dig()
  46.   if not r.swing() then
  47.     r.select(invSize-2)
  48.     ic.equip()
  49.     r.swing()
  50.     ic.equip()
  51.   end
  52. end
  53. function digDown()
  54.   if not r.swingDown() then
  55.     r.select(invSize-2)
  56.     ic.equip()
  57.     r.swingDown()
  58.     ic.equip()
  59.   end
  60. end
  61.  
  62. function craftPickAndCharge(lenFromHome)
  63.   r.turnAround()
  64.   r.down()
  65.   for k=1, lenFromHome do
  66.     if not r.detectDown() then
  67.       r.select(invSize-1)
  68.       r.placeDown()
  69.     end
  70.     move()
  71.   end
  72.   r.turnRight()
  73.   pushToInventory()
  74.   while pc.energy() < minEnergy do
  75.     os.sleep(5)
  76.   end
  77.   for k = 1, 3 do
  78.     r.select(k)
  79.     ic.suckFromSlot(3, 1, 1)
  80.   end
  81.   r.select(6)
  82.   ic.suckFromSlot(3,2,1)
  83.   r.select(10)
  84.   ic.suckFromSlot(3,2,1)
  85.   c.crafting.craft(1)
  86.   r.select(9)
  87.   ic.equip()
  88.   c.crafting.craft(1)
  89.   ic.equip()
  90.   r.turnRight()
  91.   for k=1, lenFromHome do
  92.     move()
  93.   end
  94.   r.up()
  95. end
  96.  
  97. function digTD()
  98.   dig()
  99.   move()
  100.   digUp()
  101.   digDown()
  102. end
  103.  
  104. r.up()
  105. for i=1, length do
  106.   printInfo(i)  
  107.   bB, sB = r.detect()
  108.   if sB == "solid" then
  109.     digTD()
  110.     r.turnLeft()
  111.     digTD()
  112.     if i%torchLen == 0 then
  113.       r.select(invSize)
  114.       r.placeUp(3, false)
  115.     end
  116.     r.turnAround()
  117.     move()
  118.     digTD()
  119.     r.turnAround()
  120.     move()
  121.     r.turnRight()
  122.     if r.durability() < 0.12 then
  123.       craftPickAndCharge(i)
  124.     end  
  125.   else
  126.     move()
  127.   end
  128. end
  129. r.turnAround()
  130. for i=1, length do
  131.   move()
  132. end
  133. r.down()
  134. r.turnRight()
  135. pushToInventory()
  136. r.turnRight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement