Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 2013 (c) psychedelixx
- Minecraft Turtle: Room
- 2013-05-22
- Digs a room with specified dimensions.
- Usage:
- - use turtle and type "label set <name>"
- (to give your turtle an unique name so it remembers its programs)
- - type "pastebin get tPQVZfmw room"
- - type "room <width> [<length>] [<height>]"
- - default length = width
- - default height = 2
- - place solid blocks in slot 16 to fill the ground
- --]]
- function move()
- if turtle.getFuelLevel() < 2 then
- turtle.refuel()
- end
- if fillGround and not turtle.detectDown() then
- turtle.select(16)
- turtle.placeDown()
- end
- while not turtle.forward() do
- turtle.dig()
- end
- repeat
- turtle.digUp()
- until not turtle.detectUp()
- end
- local args = { ... }
- if #args < 1 then
- print("")
- print("Usage: room <width> [<length>] [<height>]")
- print("# default length = width")
- print("# default height = 2")
- print("# place solid blocks in slot 16 to fill the ground")
- print("")
- error()
- end
- width = tonumber(args[1])
- length = width
- height = 2
- fillGround = true
- if #args >= 2 then
- length = tonumber(args[2])
- end
- if #args == 3 then
- height = tonumber(args[3])
- end
- if height*width*length < 1 then
- print( "A room must be at least 1m^3." )
- error()
- end
- if turtle.getFuelLevel() == 0 then
- turtle.refuel()
- end
- if turtle.getFuelLevel() == 0 then
- print("I need fuel!")
- else
- print("======== 2013 (c) psychedelixx ========")
- print("Let's go!")
- print("Digging " .. width .. "*" .. length .. "*" .. height .. " (w*l*h)")
- move()
- nextTurnRight = true
- h = 0
- repeat
- w = 1
- while w <= width do
- print("")
- if turtle.getFuelLevel() ~= "unlimited" then
- print("Fuel: " .. turtle.getFuelLevel())
- end
- for l = 1, length-1 do
- move()
- end
- if w < width then
- if nextTurnRight then
- turtle.turnRight()
- move()
- turtle.turnRight()
- nextTurnRight = false
- else
- turtle.turnLeft()
- move()
- turtle.turnLeft()
- nextTurnRight = true
- end
- end
- w = w+1
- end
- if h < height-1 then
- h = h+2
- else
- if h == height-1 then
- h = h+1
- end
- end
- if h < height then
- turtle.turnRight()
- turtle.turnRight()
- turtle.up()
- turtle.digUp()
- if h < height-1 then
- turtle.up()
- turtle.digUp()
- end
- end
- fillGround = false
- until h >= height
- while h > 2 do
- turtle.down()
- h = h-1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement