Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local xCurrent, zCurrent = 1, 1
- local xMax, zMax
- local facing = 0 --start 0, gedreht 1
- if #args == 2 then
- xMax = tonumber(args[1])
- zMax = tonumber(args[2])
- elseif #args==0 then
- xMax, zMax = 3, 3
- end
- function digUpDown()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(1)
- end
- while turtle.detectDown() do
- turtle.digDown()
- sleep(1)
- end
- end
- function dig()
- digUpDown()
- if turtle.detect() then
- while turtle.detect() do
- turtle.dig()
- sleep(1)
- end
- end
- end
- function start()
- turtle.refuel()
- while zCurrent <= zMax do
- if facing == 0 then
- while xCurrent < xMax do
- dig()
- turtle.forward()
- xCurrent = xCurrent +1
- end
- if zCurrent < zMax then
- turtle.turnLeft()
- dig()
- turtle.forward()
- turtle.turnLeft()
- zCurrent = zCurrent +1
- facing = 1
- else
- digUpDown()
- end
- end
- if facing == 1 then
- while xCurrent > 1 do
- dig()
- turtle.forward()
- xCurrent = xCurrent -1
- end
- if zCurrent < zMax then
- turtle.turnRight()
- dig()
- turtle.forward()
- turtle.turnRight()
- zCurrent = zCurrent +1
- facing = 0
- else
- digUpDown()
- end
- end
- end
- end
- --Begin
- if #args == 2 then
- start()
- elseif #args == 0 then
- start()
- else
- print("Usage: room <x> <z>")
- end
Add Comment
Please, Sign In to add comment