csmit195

Dragon Egg Harvester

Sep 25th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. local sensor = peripheral.wrap('right')
  2.  
  3. local isMoving
  4. local isStart = true
  5. local isEnd
  6.  
  7. --0.0, y=-3.0, z=1.0
  8.  
  9. function init()
  10.     while true do
  11.         while not placeCobbleStone() do
  12.             sleep(3)
  13.         end
  14.         checkFuel()
  15.         moveToEgg()
  16.         turtle.dig()
  17.         returnToBase()
  18.         transferEgg()
  19.         sleep(5)
  20.     end
  21. end
  22.  
  23. function placeCobbleStone()
  24.     if ( turtle.getItemCount(1) > 0 and turtle.getItemDetail(1).name == 'minecraft:cobblestone' ) then
  25.         turtle.select(1)
  26.         return turtle.place()
  27.     else
  28.         error("No Cobblestone")
  29.     end
  30. end
  31.  
  32. function transferEgg()
  33.     if ( turtle.getItemCount(2) > 0 and turtle.getItemDetail(2).name == 'minecraft:dragon_egg' ) then
  34.         turtle.select(2)
  35.         turtle.dropDown()
  36.     else
  37.         error('what the $!@#, there is no egg?!')
  38.     end
  39. end
  40.  
  41. function checkFuel()
  42.     if turtle.getFuelLevel() <= 5 then
  43.         turtle.select(16)
  44.         turtle.refuel(1)
  45.         turtle.select(1)
  46.     end
  47. end
  48.  
  49. function moveToEgg()
  50.     isMoving = true
  51.     turtle.up()
  52.     turtle.forward()
  53.     turtle.forward()
  54.     turtle.forward()
  55.     isMoving = false
  56.     isStart = false
  57.     isEnd = true
  58. end
  59.  
  60. function returnToBase()
  61.     isMoving = true
  62.     turtle.back()
  63.     turtle.back()
  64.     turtle.back()
  65.     turtle.down()
  66.     isMoving = false
  67.     isEnd = false
  68.     isStart = true
  69. end
  70.  
  71. init()
Advertisement
Add Comment
Please, Sign In to add comment