Advertisement
Guest User

Farlander

a guest
Oct 22nd, 2015
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. --made by Lenscas
  2. local dig=peripheral.wrap("left")
  3.  
  4. local chestName="EnderStorage:enderChest"
  5. function editColors(become)
  6.     local colors={send={colors.orange,colors.orange,colors.orange},fuel={colors.gray,colors.gray,colors.gray}}
  7.     peripheral.call("top","setColours",colors[become][1],colors[become][2],colors[become][3])
  8. end
  9. function refuel()
  10.     print(turtle.getFuelLevel())
  11.     editColors("fuel")
  12.     if turtle.getFuelLevel()<200 then
  13.         turtle.select(15)
  14.         turtle.suckUp()
  15.         turtle.refuel()
  16.         if turtle.getItemCount() >0 then
  17.             turtle.dropUp()
  18.         end
  19.     end
  20.     print(turtle.getFuelLevel())
  21.     turtle.select(16)
  22.    
  23. end
  24. function sendItems()
  25.      peripheral.call("top","condenseItems")
  26.     local items = peripheral.call("top","getAllStacks",false)
  27.     editColors("send")
  28.     while #items> 0 do
  29.         sleep(#items)
  30.         peripheral.call("top","condenseItems")
  31.         items   = peripheral.call("top","getAllStacks",false)
  32.     end
  33.     for slot=1,16 do
  34.         turtle.select(slot)
  35.         turtle.dropUp()
  36.     end
  37. end
  38. function startup()
  39.     local sucess, itemData=nil
  40.     turtle.select(16)
  41.     if turtle.getItemCount()>0 then
  42.         itemData=turtle.getItemDetail()
  43.         if itemData['name']==chestName then
  44.             dig.digUp()
  45.             turtle.placeUp()
  46.         end
  47.     end
  48.     sucess ,itemData=turtle.inspectUp()
  49.     if sucess then
  50.         if itemData['name']==chestName then
  51.             sendItems()
  52.             refuel()
  53.             turtle.select(16)
  54.             dig.digUp()
  55.             turtle.select(1)
  56.         else
  57.             return false
  58.         end
  59.     else
  60.         return false
  61.     end
  62.     return true
  63. end
  64. function mine()
  65.     while turtle.detectUp() do
  66.         turtle.select(1)
  67.         dig.digUp()
  68.         sleep(0.5)
  69.     end
  70.     while turtle.detect() do
  71.         turtle.select(1)
  72.         dig.dig()
  73.         sleep(0.5)
  74.     end
  75.     turtle.select(1)
  76.     dig.digDown()
  77. end
  78. function forward()
  79.     local sucess=false
  80.     local counter=0
  81.     while not turtle.forward() do
  82.         mine()
  83.         turtle.attack()
  84.         counter=counter+1
  85.         if counter>2 then
  86.             turtle.select(16)
  87.             turtle.placeUp()
  88.             refuel()
  89.             dig.digUp()
  90.         elseif counter>4 then
  91.             stop()
  92.         end
  93.     end
  94. end
  95. function stop()
  96.     local success=false
  97.     while not success do
  98.         turtle.sleep(200)
  99.         success = startup()
  100.     end
  101. end
  102.  
  103. if not startup() then
  104.     stop()
  105. end
  106. while true do
  107.     for times=1,15 do
  108.         mine()
  109.         forward()
  110.     end
  111.     mine()
  112.     turtle.select(16)
  113.     turtle.placeUp()
  114.     sendItems()
  115.     refuel()
  116.     dig.digUp()
  117. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement