Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nRoomWidth = 5
- nRoomLength = 5
- nRoomHeight = 3
- -- BASIC MOVEMENT METHODS --
- function placeThenMoveLeft()
- turtle.placeDown()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- function placeThenMoveRight()
- turtle.placeDow()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- function turnAround()
- turtle.turnRight()
- turtle.turnRight()
- end
- ----------------------------
- function buildRoof(nWidth, nLength)
- turtle.up()
- for nLine=1, nLength do
- for nBlock=1, nWidth-1 do
- placeThenMoveLeft()
- end
- turtle.placeDown()
- turtle.forward()
- if nLine ~= nLength then
- turtle.placeDown()
- end
- turtle.turnRight()
- for nPositionInLine=nWidth-1, 1, -1 do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- -- Return to the starting position.
- turnAround()
- for nPositionInLength=nLength, 1, -1 do
- turtle.forward()
- end
- turnAround()
- end
- function buildLayer(nWidth, nLength)
- turtle.up() -- Get above the space to build.
- -- Build the solid outer line first.
- -- +-----+
- -- | |
- -- +-----x <-
- for nBlock=1, nWidth-1 do
- placeThenMoveLeft()
- end
- turtle.placeDown()
- ---------------
- -- +-----+
- -- | |
- -- xXXXXXX
- --
- -- Get the turtle in position to build the inner layers.
- turtle.forward()
- -- Build the inner layers of the room.
- for nLine=1, nLength-2 do
- turtle.placeDown()
- turtle.turnRight()
- for nPositionInLine=1, nWidth-1 do
- turtle.forward()
- end
- turtle.turnLeft()
- turtle.placeDown()
- turtle.forward()
- turtle.turnLeft()
- for nPositionInLine=nWidth-1, 1, -1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- -- x-----+
- -- X X
- -- XXXXXXX
- -- Build the final solid outer line.
- turtle.placeDown()
- turtle.turnRight()
- for nPositionInLine=nWidth-1, 1, -1 do
- turtle.forward()
- turtle.placeDown()
- end
- turtle.turnLeft()
- turtle.placeDown()
- -- XXXXXXx
- -- X X
- -- XXXXXXX
- -- Return to the original position of the turtle.
- turnAround()
- for nPositionInLength=nLength-1, 1, -1 do
- turtle.forward()
- end
- turnAround()
- end
- function buildStructure(nWidth, nLength, nHeight)
- for nCurrentHeight=1, nHeight do
- buildLayer(nWidth, nLength)
- end
- buildRoof(nWidth, nLength)
- end
- buildStructure(nRoomWidth, nRoomLength, nRoomHeight)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement