Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- functions
- function thomasTunneler(width, height, depth)
- if width < 1 or height < 1 or depth < 1 then
- return -- invalid parameter inputs
- end
- -- mine the first row
- mineRow(height)
- -- For every width
- for w = 1, width, 1 do
- -- for every depth
- for d = 2, depth, 1 do
- mineRow(height)
- end
- -- prepare for next slice
- if not w == width then
- prepareNextSlice(w, height)
- end
- end
- end
- function prepareNextSlice(currentWidth, height)
- turn(currentWidth) -- rotate 90 degree
- mineRow(height) -- mine the first row
- turn(currentWidth) -- rotate 90 degree again
- end
- function turn(currentWidth)
- if (currentWidth % 2) == 1 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- function mineRow(height)
- turtle.dig("left") -- mine forward
- turtle.forward() -- move forward
- -- mine the row
- for h = 2, height, 1 do
- turtle.digUp("left")
- turtle.up()
- end
- -- move down to the ground again
- for h = 1, height, 1 do
- turtle.down()
- end
- end
- -- functions end
- -- program
- local width, height, depth = ...
- thomasTunneler(width, height, depth)
- -- program end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement