Building Builder

                Never    
Lua
       
--House builder
--Logan Eastman

local length = 5; --Length of building
local width = 7; --Width of building
local height = 1; --Height does not include ceiling


function buildWalls()
	for floor = 1,height,1 do --Loop for every block height of building

		turtle.up() --Move up

		for i = 1,2,1 do --repeat twice per block height
			for side = 0,length,1 do --Forward for length
				turtle.placeDown() --Place blocks
				turtle.forward() --Move forward
			end

			turtle.turnRight()


			for side = 0,width,1 do --forward for width
				turtle.placeDown() --place blocks
				turtle.forward() --Move forward
			end
			
			turtle.turnRight()

		end
	end
end

function buildCeiling()
	local rightTurn = true
	turtle.up()
	for w = 1,width,1 do --Loop for every block height of building
		rightTurn = (not rightTurn)

		for side = 0,length,1 do --Forward for length
			turtle.placeDown() --Place blocks
			turtle.forward() --Move forward
		end
		
		if(rightTurn) then
			turtle.turnRight()
		else
			turtle.turnLeft()
		end

		turtle.placeDown() --Place block before moving
		turtle.forward() --Move forward

		turtle.turnRight()


		for side = 0,length,1 do --Forward for length
			turtle.placeDown() --Place blocks
			turtle.forward() --Move forward
		end
		
		if(rightTurn) then
			turtle.turnLeft()
		else
			turtle.turnRight()
		end

		turtle.placeDown() --Place block before moving
		turtle.forward() --Move forward

		if(rightTurn) then
			turtle.turnLeft()
		else
			turtle.turnRight()
		end
	end
end

buildWalls()
buildCeiling()

Raw Text