Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- local xMax = tonumber(args[1])
- local yMax = tonumber(args[2])
- if #args < 2 then
- xMax = 7
- yMax = 7
- end
- if ( xMax < 7 ) then xMax = 7 end
- if ( yMax < 7 ) then yMax = 7 end
- local fuelNeeded = yMax * xMax * 4 + yMax * 3 + xMax * 3
- if ( turtle.getFuelLevel() < fuelNeeded ) then
- print("Not enough fuel, need at least " .. fuelNeeded .. " to make a maze of that size")
- return
- end
- local selection = 1
- turtle.select(selection)
- function tryForward()
- if ( turtle.forward() == false ) then
- print("Get out of my way!!")
- while ( turtle.forward() == false ) do
- os.sleep(2)
- end
- end
- end
- function selectBlock()
- if ( selection == 16 ) then return end
- while ( turtle.getItemCount(selection) <= 0 ) do
- if ( selection == 16 ) then return end
- selection = selection + 1
- turtle.select(selection)
- end
- end
- function DropBlock()
- selectBlock()
- turtle.placeDown()
- end
- function CutZLevel(addFloor)
- local x = 1
- while ( x <= xMax ) do
- local y = 1
- while ( y < yMax ) do
- if ( addFloor ) then DropBlock() end
- turtle.dig()
- tryForward()
- y = y + 1
- end
- if ( addFloor ) then DropBlock() end
- x = x + 1
- if ( x > xMax ) then
- turtle.up()
- turtle.turnLeft()
- turtle.turnLeft()
- else
- if ( x % 2 == 1 ) then
- turtle.turnRight()
- turtle.dig()
- tryForward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turtle.dig()
- tryForward()
- turtle.turnLeft()
- end
- end
- end
- end
- function ReturnHome()
- local i = 1
- while ( i < yMax ) do
- tryForward()
- i = i + 1
- end
- turtle.turnLeft()
- i = 1
- while ( i < xMax ) do
- tryForward()
- i = i + 1
- end
- turtle.turnLeft()
- end
- CutZLevel(true)
- ReturnHome()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement