Advertisement
Celica45

xyzminer

Mar 22nd, 2025 (edited)
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.34 KB | Source Code | 0 0
  1. function startup()
  2.     print("Enter width: ")
  3.     xin = read()
  4.     x = tonumber(xin)
  5.  
  6.     print("Enter length: ")
  7.     zin = read()
  8.     z = tonumber(zin)
  9.  
  10.     print("Up or down?")
  11.     inupdown = read()
  12.  
  13.     print("Enter height: ")
  14.     yin = read()
  15.     y = tonumber(yin)
  16.  
  17.     turtle.select(1)
  18.     turtle.refuel()
  19.  
  20.     return x, y, z, inupdown
  21. end
  22.  
  23. function width(x)
  24.     print(x)
  25.     if x == 1 then
  26.         print("Do nothing")
  27.     else
  28.         turtle.turnRight()
  29.         for i = 2, x do
  30.             if turtle.detect() then
  31.                 repeat
  32.                     turtle.dig()
  33.                     local success, digdig = turtle.detect()
  34.                 until(success == false)
  35.             end
  36.             turtle.forward()
  37.         end
  38.         turtle.turnRight()
  39.         turtle.turnRight()
  40.         for i = 2, x do
  41.             turtle.forward()
  42.         end
  43.         turtle.turnRight()
  44.     end
  45. end
  46.  
  47. function length(z)
  48.     if z == 1 then
  49.         print("Do nothing")
  50.     else
  51.         if turtle.detect() then
  52.             repeat
  53.                 turtle.dig()
  54.                 local success, digdig = turtle.detect()
  55.             until(success == false)
  56.         end
  57.         turtle.forward()
  58.     end
  59. end
  60.  
  61. function height(y, inupdown)
  62.     if y == 1 then
  63.         print("Do nothing")
  64.     elseif inupdown == "Up" or inupdown == "up" then
  65.         turtle.digUp()
  66.         turtle.up()
  67.     elseif inupdown == "Down" or inupdown == "down" then
  68.         turtle.digDown()
  69.         turtle.down()
  70.     end
  71. end
  72.  
  73. function length_return(z)
  74.     if z == 1 then
  75.         print("Do nothing")
  76.     else
  77.         turtle.turnRight()
  78.         turtle.turnRight()
  79.         for i = 2, z do
  80.             turtle.forward()
  81.         end
  82.         turtle.turnRight()
  83.         turtle.turnRight()
  84.     end
  85. end
  86.  
  87. function height_return(y)
  88.     if y == 1 then
  89.         print("Do nothing")
  90.     else
  91.         for i = 2, y do
  92.             turtle.down()
  93.         end
  94.     end
  95. end
  96.  
  97.  
  98. function main(x, y, z, inupdown)
  99.     for h = 0, y - 1 do
  100.         for i = 0, z - 1 do
  101.             width(x)
  102.             if i < z - 1 then
  103.                 length(z)
  104.             end
  105.         end
  106.         if h < y - 1 then
  107.             length_return(z)
  108.             height(y, inupdown)
  109.         end
  110.     end
  111.     height_return(y)
  112. end
  113.  
  114.  
  115.  
  116. x, y, z, inupdown = startup()
  117. main(x, y, z, inupdown)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement