Advertisement
AdventurousMR

Turtle Melon Farmer 2.0

Jul 21st, 2022 (edited)
1,010
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. -- Turtle Melon Farmer -- -- AdventurousMR --
  2.  
  3. function limeWool()
  4.     turtle.turnLeft()
  5.     turtle.forward()
  6.     turtle.turnLeft()
  7. end
  8.  
  9. function redWool()
  10.     turtle.turnRight()
  11.     turtle.forward()
  12.     turtle.turnRight()
  13. end
  14.  
  15. function lightBlueWool()
  16.     turtle.turnRight()
  17.     turtle.turnRight()
  18.     for i=1,16 do
  19.         turtle.select(i)
  20.         local item = turtle.getItemDetail()
  21.         if item ~= nil and item.name == "minecraft:melon_slice" then
  22.             turtle.dropDown()
  23.         end
  24.     end
  25.     station()
  26. end
  27.  
  28. function orangeWool()
  29.     turtle.turnRight()
  30.     while true do
  31.         local I_success, I_data = turtle.inspect()
  32.         if I_success and I_data.name == "minecraft:orange_wool" then
  33.             orangeWool()
  34.         elseif I_success and I_data.name == "minecraft:light_blue_wool" then
  35.             lightBlueWool()
  36.             break
  37.         else
  38.             turtle.forward()
  39.         end
  40.     end
  41. end
  42.  
  43. function run()
  44.     local ID_success, ID_data = turtle.inspectDown()
  45.     local I_success, I_data = turtle.inspect()
  46.  
  47.     if ID_success and ID_data.name == "minecraft:melon" then
  48.         turtle.digDown()
  49.         run()
  50.     elseif I_success and I_data.name == "minecraft:red_wool" then
  51.         redWool()
  52.         run()
  53.     elseif I_success and I_data.name == "minecraft:lime_wool" then
  54.         limeWool()
  55.         run()
  56.     elseif I_success and I_data.name == "minecraft:light_blue_wool" then
  57.         lightBlueWool()
  58.     elseif I_success and I_data.name == "minecraft:orange_wool" then
  59.         orangeWool()
  60.     elseif ID_success == false or ID_success and ID_data.name ~= "minecraft:melon" then
  61.         turtle.forward()
  62.         run()
  63.     end
  64. end
  65.  
  66. function station()
  67.     local bin = peripheral.wrap("Bottom")
  68.     while true do
  69.         if bin.getStored().count < 50 then
  70.             if turtle.getFuelLevel() > 150 then
  71.                 run()
  72.                 break
  73.             else
  74.                 for i=1,16 do
  75.                     turtle.select(i)
  76.                     local item = turtle.getItemDetail()
  77.                     if item ~= nil and item.name == "minecraft:coal" then
  78.                         turtle.refuel()
  79.                     end
  80.                     if item ~= nil and item.name ~= "minecraft:coal" and i == 16 then
  81.                         print("ERROR:NO COAL")
  82.                     end
  83.                 end
  84.             end
  85.         end
  86.     end
  87. end
  88.  
  89. term.clear()
  90. run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement