SHARE
TWEET

testThomasMiner

a guest Feb 15th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- functions
  2. function thomasTunneler(width, height, depth)
  3.    
  4.     if width == 0 or height == 0 or depth == 0 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 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.    
  52.     for h = 1, height, 1 do
  53.         turtle.down()
  54.     end
  55. end
  56. -- functions end
  57.  
  58. -- program
  59. local width, height, depth = ...
  60.  
  61. thomasTunneler(width, height, depth)
  62. -- program end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top