_Nobody_

Wall

Jan 18th, 2023 (edited)
1,368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. io.write("Enter Length: ")
  2. length = io.read()
  3. io.write("Enter Height: ")
  4. height = io.read()
  5.  
  6. local SLOT_COUNT = 16
  7. local FUEL_CHEST = 15
  8. local WOOD_CHEST = 16
  9. local FILL_SLOT_COUNT = 4
  10.  
  11. function countItems(itemToCount)
  12.     local itemCount = 0
  13.     for slot = 1, SLOT_COUNT, 1 do
  14.         item = turtle.getItemDetail(slot)
  15.         if(item ~= nil) then
  16.             if(item.name == itemToCount) then
  17.                 itemCount = itemCount + turtle.getItemCount(slot)
  18.             end
  19.         end
  20.     end
  21.  
  22.     return itemCount
  23. end
  24.  
  25.  
  26.  
  27. function refuel()
  28.     fuel_level = turtle.getFuelLevel()
  29.     if fuel_level < 1000 then
  30.         turtle.select(FUEL_CHEST)
  31.         turtle.digUp()
  32.         turtle.placeUp()
  33.  
  34.         slot = 9
  35.         turtle.select(slot)
  36.         turtle.suckUp(64)
  37.         turtle.refuel(64)
  38.  
  39.         turtle.select(FUEL_CHEST)
  40.         turtle.digUp()
  41.     end
  42. end
  43.  
  44.  
  45. function checkWOOD()
  46.     if (countItems("minecraft:cobblestone") < 64) then
  47.         turtle.select(WOOD_CHEST)
  48.         turtle.digUp()
  49.         turtle.placeUp()
  50.  
  51.         for slot = 1, FILL_SLOT_COUNT, 1 do
  52.             turtle.select(slot)
  53.             turtle.suckUp()
  54.         end
  55.  
  56.         turtle.select(WOOD_CHEST)
  57.         turtle.digUp()
  58.     end
  59. end
  60.  
  61. function getItemIndex(itemName)
  62.     for slot = 1, SLOT_COUNT, 1 do
  63.         local item = turtle.getItemDetail(slot)
  64.         if(item ~= nil) then
  65.             if(item["name"] == itemName) then
  66.                 return slot
  67.             end
  68.         end
  69.     end
  70. end
  71.  
  72. function moveForward()
  73.     turtle.forward()
  74. end
  75.  
  76. function moveBackward()
  77.     turtle.back()
  78. end
  79.  
  80. function placeBlock()
  81.     turtle.placeDown()
  82. end
  83.  
  84.  
  85. function turnAround()
  86.     turtle.turnRight()
  87.     turtle.turnRight()
  88.     turtle.up()
  89. end
  90.  
  91. repeat
  92.     for i = 1,tonumber(length) -1 do
  93.         checkWOOD()
  94.         refuel()
  95.         turtle.select(getItemIndex("minecraft:cobblestone"))
  96.         placeBlock()
  97.         moveForward()
  98.  
  99.         if i == tonumber(length) - 1 then
  100.             placeBlock()
  101.             turnAround()
  102.             height = height - 1        
  103.         end
  104.     end    
  105. until height == 0
  106.  
  107.  
Advertisement
Add Comment
Please, Sign In to add comment