Lorc520

room creator

Nov 11th, 2022 (edited)
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.16 KB | Gaming | 0 0
  1. print('Start the digging\n')
  2.  
  3. print("Please give x lenght")
  4. term.setTextColor(colors.pink)
  5. local inputx = read()
  6. term.setTextColor(colors.white)
  7.  
  8. print("Please give z lenght")
  9. term.setTextColor(colors.pink)
  10. local inputz = read()
  11. term.setTextColor(colors.white)
  12.  
  13. print("Please give y height")
  14. term.setTextColor(colors.pink)
  15. local inputy = read()
  16. term.setTextColor(colors.white)
  17.  
  18. print("Thank you, mining will begin")
  19. local function variablereset()
  20.     x = tonumber(inputx)
  21.  
  22.     z = tonumber(inputz)
  23.  
  24.     s = True
  25.  
  26. end
  27.  
  28. y = tonumber(inputy)
  29.  
  30.  
  31. local function minex(x)
  32.     r = 0
  33.         while r < x do
  34.            turtle.dig()
  35.            turtle.forward()
  36.             r = r + 1
  37.         end
  38.     end
  39.  
  40.     local function minez(z)
  41.         r = 0
  42.             while r < z do
  43.                 turtle.dig()
  44.                 turtle.forward()
  45.                 r = r + 1
  46.             end
  47.         end
  48.  
  49.  
  50. local function refuel_all()
  51. f = 1
  52. while f <= 16 do
  53.     turtle.select(f)
  54.     turtle.refuel()
  55.     f = f + 1
  56.         end
  57. end
  58.  
  59. local function unload()
  60.     turtle.turnLeft()
  61.     turtle.turnLeft()
  62.     r = 0
  63.     while not turtle.detectDown() do
  64.        turtle.down()
  65.        print("turtle going down?")
  66.         r = r + 1
  67.      end
  68.  
  69.     u = 1
  70.     while u <= 16 do
  71.         turtle.select(u)
  72.         turtle.drop()
  73.         u = u + 1
  74.     end
  75.     if r > 0 then
  76.         turtle.up(r)
  77.     end
  78.     turtle.turnLeft()
  79.     turtle.turnLeft()
  80. end
  81.  
  82.  
  83. local function horizontallayer(x, z)
  84.     -- removed x = x
  85.     a = 2
  86.     n = 1
  87.     cz = 2
  88.     minex(x) --arrive en cx =  x et en cz = 1
  89.     turtle.turnLeft()
  90.     minez(z - 1) --arrive en cx = x et en cz = z
  91.     turtle.turnLeft()
  92.     minex(x - 1) --arrive en cx = 1 et en cz = z
  93.     turtle.turnLeft()
  94.     minez(z - 2) --arrive en cx = 1 et en cz = 2
  95.     turtle.turnLeft()
  96.  
  97.  
  98.  while x - a > 0 and s == True  do --changed y to z
  99.         minex(x - a) --cx = x-1, cz = 2
  100.         cx = x - n
  101.         turtle.turnLeft()
  102.         --face ouest
  103. print("facing West")
  104. print(cx)
  105.         f = "West"
  106.         if z - 1 - a > 0 then
  107.             minez(z - 1 - a) --cx = x - 1, cz = z -1
  108.             cz = z - n
  109.             turtle.turnLeft()
  110.             --face sud
  111. print("facing south")
  112. print(cz)
  113.             f = "South"
  114.             else s = false
  115.         end
  116.         if x - 1 - a > 0 and s == True then
  117.             minex(x - 1 - a) --cx = 2, cz = z - 1
  118.             cx = 1 + n
  119.            turtle.turnLeft()
  120.                 --face east
  121. print("facing east")
  122. print(cx)
  123.  
  124.                 f = "East"
  125.             else s = false
  126.         end
  127.         if z - 2 - a > 0 then
  128.                     minez(z - 2 -  a) --cx = 2, cz = 3
  129.                     cz = 2 + n
  130.                     turtle.turnLeft()
  131.                     --face north
  132. print("facing North")
  133. print(cz)
  134.                     f = "North"
  135. else s = false
  136.  
  137.         end
  138.         n = n + 1
  139.         a = a + 2
  140.     end
  141.     return cx, cz, f -- pas sûr syntaxe
  142. end
  143.  
  144. local function gobacktostart()
  145.     if f == "North" then
  146.         turtle.turnRight()
  147.         print("facing north?")
  148.     elseif f == "East" then
  149.         print("Already facing East")
  150.     elseif f == "South" then
  151.         turtle.turnLeft()
  152.         print("facing south?")
  153.         r = 0
  154.         while r < z - 2 -  a do -- achtung !!
  155.         turtle.forward()
  156.         r = r + 1
  157.         end
  158.  
  159.     elseif f == "West" then
  160.         turtle.turnLeft()
  161.         turtle.turnLeft()
  162.         print("facing west")
  163.     end
  164.  
  165.     q = 0    
  166.     while q < cz - 1 do
  167.         turtle.forward()
  168.         q = q + 1
  169.     end
  170.         turtle.turnRight()
  171.     q = 0    
  172.     while q < cx do
  173.         turtle.forward()
  174.         q = q + 1
  175.     end
  176.         turtle.turnRight()
  177.         turtle.turnRight()
  178.  
  179. end
  180.  
  181.  
  182.  
  183.  
  184.  
  185. h = 1
  186.     while h <= y do
  187.         variablereset()
  188.         horizontallayer(x, z)
  189.         print("now going back to start")
  190.         gobacktostart()
  191.         refuel_all()
  192.         unload()
  193.         h = h + 1
  194.         if h <= y then
  195.             turtle.digUp()
  196.             turtle.up()
  197.         else
  198.             print('Jobs Done')
  199.         end
  200.     end
  201.  
  202. while not turtle.detectDown() do
  203.     turtle.down()
  204.     end
Advertisement
Add Comment
Please, Sign In to add comment