Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- 2014 (c) psychedelixx
- Minecraft Turtle: Room (Tobust)
- 2014-04-21
- Digs a room with specified dimensions.
- Robust API:
- http://computercraft.info/wiki/Robust_Turtle_API
- Usage:
- - use turtle and type "label set <name>"
- (to give your turtle an unique name so it remembers its programs)
- - type "pastebin get VRR7iLat room"
- - type "room <width> [<length>] [<height>]"
- - default length = width
- - default height = 2
- - place solid blocks in slot 16 to fill the ground
- --]]
- function move()
- t.digUp()
- t.dig()
- t.forward()
- empty = 0
- if nextTurnRight then
- print("w"..w.." l"..l.." h"..h.." next turn right. Fuel: " .. turtle.getFuelLevel())
- else
- print("w"..w.." l"..l.." h"..h.." next turn left. Fuel: " .. turtle.getFuelLevel())
- end
- for slot = 1, 16 do
- if turtle.getItemCount(slot) == 0 then
- empty = 1
- break
- end
- end
- if empty == 0 then
- t.down(h-1)
- if (h-1)%4==0 then
- if nextTurnRight then
- t.left()
- t.forward(w-1)
- t.left()
- t.forward(l)
- else
- t.right()
- t.forward(w-1)
- t.left()
- t.forward(length-l-1)
- end
- else
- if nextTurnRight then
- t.right()
- t.forward(width-w)
- t.left()
- t.forward(length-l-1)
- else
- t.left()
- t.forward(width-w)
- t.left()
- t.forward(l)
- end
- end
- for slot = 1, 15 do
- turtle.select(slot)
- turtle.drop()
- end
- t.turnAround()
- if (h-1)%4==0 then
- if nextTurnRight then
- t.forward(l)
- t.right()
- t.forward(w-1)
- t.left()
- else
- t.forward(length-l-1)
- t.right()
- t.forward(w-1)
- t.right()
- end
- else
- if nextTurnRight then
- t.forward(length-l-1)
- t.right()
- t.forward(width-w)
- t.right()
- else
- t.forward(l)
- t.right()
- t.forward(width-w)
- t.left()
- end
- end
- t.up(h-1)
- end
- end
- local args = { ... }
- if #args < 1 then
- print("")
- print("Usage: room <width> [<length>] [<height>]")
- print("# default length = width")
- print("# default height = 2")
- print("")
- error()
- end
- if #args >= 1 then
- width = tonumber(args[1])
- length = width
- height = 2
- end
- if #args >= 2 then
- length = tonumber(args[2])
- end
- if #args == 3 then
- height = tonumber(args[3])
- end
- if turtle.getFuelLevel() < height*width*length then
- print("I need " .. height*width*length - turtle.getFuelLevel() .. " more fuel!")
- else
- print("======== 2014 (c) psychedelixx ========")
- print("Let's go!")
- print("Digging " .. width .. "*" .. length .. "*" .. height .. " (w*l*h)")
- nextTurnRight = true
- h = 1
- repeat
- w = 1
- while w <= width do
- print("")
- l = 1
- while l < length do
- move()
- l = l+1
- end
- if w < width then
- if nextTurnRight then
- t.right()
- move()
- t.right()
- nextTurnRight = false
- else
- t.left()
- move()
- t.left()
- nextTurnRight = true
- end
- end
- w = w+1
- end
- if h < height then
- h = h+2
- end
- if h == height then
- h = h+1
- end
- if h < height then
- t.turnAround()
- t.up()
- t.digUp()
- if h < height then
- t.up()
- t.digUp()
- end
- end
- until h >= height
- t.down(height-2)
- for slot = 1, 15 do
- turtle.select(slot)
- turtle.drop()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement