Posted 21 September 2012 - 10:56 PM
Hey, so this is my first program! It makes a simple 11x11 house. It has 3 2x3 windows and a skylight. Now this is version one, so the house is only made of one material, and I haven't gone through the code and made it more efficient or anything yet, it just works at the moment. Put fuel in slot 1, put the material you want the house built out of in slots 2 -7, glass panes (or glass, your choice) in slot 8, and Glass in slot 9, then run. Here's the code:
Current version: 1.01
How is it? Any criticism?
Change Log:
1.00: Initial version
Current version: 1.01
Spoiler
a = 10
b = 10
c = 10
function checkStone()
turtle.getItemCount(2)
ItemCount1 = turtle.getItemCount(2)
turtle.getItemCount(3)
ItemCount2 = turtle.getItemCount(3)
turtle.getItemCount(4)
ItemCount3 = turtle.getItemCount(4)
turtle.getItemCount(5)
ItemCount4 = turtle.getItemCount(5)
turtle.getItemCount(6)
ItemCount5 = turtle.getItemCount(6)
turtle.getItemCount(7)
ItemCount6 = turtle.getItemCount(7)
if ItemCount1 > 1 then
turtle.select(2)
elseif ItemCount2 > 1 then
turtle.select(3)
elseif ItemCount3 > 1 then
turtle.select(4)
elseif ItemCount4 > 1 then
turtle.select(5)
elseif ItemCount5 > 1 then
turtle.select(6)
elseif ItemCount6 > 1 then
turtle.select(7)
else
write("No stone")
end
end
function DigWall()
for i = 1, a do
turtle.digDown()
turtle.forward()
end
turtle.turnRight()
end
function PlaceFloor()
for i = 1, b do
checkStone()
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
end
function PlaceWall()
for i = 1, 10 do
checkStone()
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
end
function PlaceWallDoor()
for i = 1, 5 do
checkStone()
turtle.placeDown()
turtle.forward()
end
turtle.forward()
for i = 1, 4 do
checkStone()
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
end
function PlaceWindowsFront()
turtle.turnLeft()
for i = 1, 2 do
turtle.up()
turtle.dig()
turtle.place()
end
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
for i = 1, 2 do
turtle.dig()
turtle.place()
turtle.down()
end
end
function PlaceWallWindow()
for i = 1, 4 do
checkStone()
turtle.placeDown()
turtle.forward()
end
turtle.select(8)
for i = 1, 3 do
turtle.placeDown()
turtle.forward()
end
for i = 1, 3 do
checkStone()
turtle.placeDown()
turtle.forward()
end
checkStone()
turtle.placeDown()
turtle.turnRight()
end
function PlaceWall2()
for i = 1, 8 do
checkStone()
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
end
function PlaceGlass()
for i = 1, c do
turtle.placeDown()
turtle.forward()
end
turtle.turnRight()
end
turtle.select(1)
turtle.refuel()
for i = 1, 3 do
DigWall()
end
a = a-1
for i = 1, 9 do
for i = 1, 2 do
DigWall()
end
a = a-1
end
turtle.digDown()
turtle.turnRight()
for i = 1, 2 do
for i = 1, 5 do
turtle.forward()
end
turtle.turnRight()
end
for i = 1, 3 do
PlaceFloor()
end
b = b-1
for i = 1, 9 do
for i = 1, 2 do
PlaceFloor()
end
b = b-1
end
turtle.placeDown()
turtle.turnRight()
for i = 1, 2 do
for i = 1, 5 do
turtle.forward()
end
turtle.turnRight()
end
turtle.up()
for i = 1, 3 do
PlaceWall()
end
PlaceWallDoor()
turtle.up()
for i = 1, 3 do
PlaceWallWindow()
end
PlaceWallDoor()
turtle.up()
for i = 1, 3 do
PlaceWallWindow()
end
PlaceWall()
turtle.up()
for i = 1, 4 do
PlaceWall()
end
turtle.up()
for i = 1, 4 do
PlaceWall()
end
turtle.turnRight()
for i = 1, 5 do
turtle.forward()
end
turtle.turnLeft()
PlaceWall()
turtle.turnLeft()
turtle.turnLeft()
for i = 1, 5 do
turtle.forward()
end
turtle.turnLeft()
for i = 1, 5 do
turtle.forward()
end
turtle.turnLeft()
PlaceWall()
for i = 1, 4 do
turtle.forward()
end
turtle.turnRight()
turtle.forward()
for i = 1, 5 do
PlaceWall2()
end
turtle.turnLeft()
turtle.forward()
turtle.turnRight()
turtle.back()
turtle.select(9)
for i = 1, 3 do
PlaceGlass()
end
c = c-1
for i = 1, 9 do
for i = 1, 2 do
PlaceGlass()
end
c = c-1
end
turtle.turnRight()
for i = 1, 2 do
for i = 1, 5 do
turtle.forward()
end
turtle.turnRight()
end
turtle.turnRight()
turtle.turnRight()
turtle.forward()
for i = 1, 5 do
turtle.down()
end
turtle.select(8)
turtle.turnLeft()
turtle.forward()
turtle.forward()
PlaceWindowsFront()
turtle.turnRight()
for i = 1, 4 do
turtle.forward()
end
PlaceWindowsFront()
turtle.turnLeft()
for i = 1, 8 do
turtle.forward()
end
turtle.turnLeft()
write("Building Finished")
How is it? Any criticism?
Change Log:
Spoiler
1.01: Added front wall windows on either side of door, a little bit of cleaning up of the code1.00: Initial version
Edited on 22 September 2012 - 04:35 PM