Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
-- Optimized tunnel digger (X width, Y height, Z length) local function askNumber(label) write(label .. ": ") return tonumber(read()) end local Y = askNumber("Y") local X = askNumber("X") local Z = askNumber("Z") -- ---------- helpers ---------- local function digForwardUntilClear() -- Handle gravel/sand + mobs while not turtle.forward() do turtle.dig() turtle.attack() sleep(0.2) end end local function goUp() while not turtle.up() do turtle.digUp() turtle.attackUp() sleep(0.2) end end local function goDown() while not turtle.down() do turtle.digDown() turtle.attackDown() sleep(0.2) end end local function turnTo(side) -- "left" or "right" if side == "left" then turtle.turnLeft() else turtle.turnRight() end end -- Move laterally one step in the current facing (after turning once at row start) local function stepLateral() while not turtle.forward() do turtle.dig() turtle.attack() sleep(0.1) end end -- ---------- main ---------- local goingRight = true for zi = 1, Z do -- Carve the X×Y cross-section of this slice with minimal turns for y = 1, Y do -- Face lateral direction ONCE at row start turnTo(goingRight and "right" or "left") -- Traverse the row across X-1 steps (no extra turns inside the row) for x = 1, X - 1 do turtle.dig() -- clear the next lateral block if any (cheap if air) stepLateral() -- move one to the side turtle.digUp() -- optional: clear ceiling as you go turtle.digDown() -- optional: clear floor as you go end -- Face forward again at row end (U-turn direction depends on side) turnTo(goingRight and "left" or "right") -- Next row will go the other way goingRight = not goingRight -- Climb to next row if needed if y ~= Y then turtle.digUp() goUp() end end -- Return to bottom of slice for _ = 1, Y - 1 do goDown() end -- Only now clear the *front* and advance to next slice (one dig + one move) if zi ~= Z then turtle.dig() digForwardUntilClear() end end
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)