Advertisement
Guest User

testThomasMiner

a guest
Feb 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. -- functions
  2. function thomasTunneler(width, height, depth)
  3.    
  4.     if width < 1 or height < 1 or depth < 1 then
  5.         return -- invalid parameter inputs
  6.     end
  7.    
  8.     -- mine the first row
  9.     mineRow(height)
  10.    
  11.     -- For every width
  12.     for w = 1, width, 1 do
  13.         -- for every depth
  14.         for d = 2, depth, 1 do
  15.             mineRow(height)
  16.         end
  17.        
  18.         -- prepare for next slice
  19.         if not w == width then
  20.             prepareNextSlice(w, height)
  21.         end
  22.        
  23.     end
  24. end
  25.  
  26. function prepareNextSlice(currentWidth, height)
  27.     turn(currentWidth) -- rotate 90 degree
  28.     mineRow(height) -- mine the first row
  29.     turn(currentWidth) -- rotate 90 degree again
  30. end
  31.  
  32. function turn(currentWidth)
  33.     if (currentWidth % 2) == 1 then
  34.         turtle.turnRight()
  35.     else
  36.         turtle.turnLeft()
  37.     end
  38. end
  39.  
  40. function mineRow(height)
  41.     turtle.dig("left") -- mine forward
  42.     turtle.forward() -- move forward
  43.    
  44.     -- mine the row
  45.     for h = 2, height, 1 do
  46.         turtle.digUp("left")
  47.         turtle.up()
  48.     end
  49.    
  50.     -- move down to the ground again
  51.     for h = 1, height, 1 do
  52.         turtle.down()
  53.     end
  54. end
  55. -- functions end
  56.  
  57. -- program
  58. local width, height, depth = ...
  59.  
  60. thomasTunneler(width, height, depth)
  61. -- program end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement