Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("homeAPI")
- local tArgs = {...}
- if #tArgs ~= 3 then
- print("Usage: room <length> <width> <height>")
- return
- end
- height = tonumber(tArgs[3])
- width = tonumber(tArgs[2])
- length = tonumber(tArgs[1])
- if turtle.getFuelLevel() < (height * width * length) then
- print("not enough fuel to complete room")
- return
- end
- function breakBlock()
- while turtle.detect() do
- turtle.dig()
- sleep(0.4)
- end
- end
- function turn(bool)
- if bool then
- homeAPI.turnRight()
- breakBlock()
- homeAPI.forward()
- homeAPI.turnRight()
- return not bool
- else
- homeAPI.turnLeft()
- breakBlock()
- homeAPI.forward()
- homeAPI.turnLeft()
- return not bool
- end
- end
- bool = true
- for h = 1, height do
- for w = 1, width do
- for l = 2, length do
- homeAPI.invState()
- breakBlock()
- homeAPI.forward()
- end
- if w ~= width then
- bool = turn(bool)
- else
- homeAPI.turnLeft()
- homeAPI.turnLeft()
- end
- end
- if(h ~= height) then
- while turtle.detectUp() do
- turtle.digUp()
- sleep(0.4)
- end
- homeAPI.up()
- end
- end
Add Comment
Please, Sign In to add comment