This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
KrishGM's profile picture

Turtle House Builder

Started by KrishGM, 19 September 2014 - 06:27 AM
KrishGM #1
Posted 19 September 2014 - 08:27 AM
Turtle House Builder Program

This program makes the any turtle to build a house.
This is the Code:

Spoiler

print ("house builder")
print("slot 1 - 1st wall")
print("slot 2 - 2nd wall")
print("slot 3 - 3rd wall")
print("slot 4 - 4th wall")
print("slot 5 - windows")
print("slot 6 - door")
print("slot 7 - lighting")
print("flooring upto you!")
-- program start --
-- 1st wall --
turtle.place() -- 1st block
turtle.up()
turtle.place() -- 2nd block
turtle.up()
turtle.place() -- 3rd block
turtle.up()
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 2nd stack --
turtle.place() -- 1st block
turtle.down()
turtle.place() -- 2nd block
turtle.down()
turtle.select(5) -- slot 5
turtle.place() -- window
turtle.down()
turtle.select(1) -- slot 1
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 3rd stack --
turtle.select(6) -- slot 6
turtle.place() -- door
turtle.select(1) -- slot 1
turtle.up()
turtle.up()
turtle.place() -- 3rd block
turtle.up()
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 4th stack --
turtle.place() -- 4th block
turtle.down()
turtle.place() -- 3rd block
turtle.down()
turtle.place() -- 2nd block
turtle.down()
turtle.place() -- 1st block
-- 1st wall end --
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
-- 2nd wall start --
turtle.select(2) -- slot 2 selected
turtle.place() -- 1st block
turtle.up()
turtle.place() -- 2nd block
turtle.up()
turtle.place() -- 3rd block
turtle.up()
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 2nd stack --
turtle.place() -- 4th block
turtle.down()
turtle.place() -- 3rd block
turtle.down()
turtle.place() -- 2nd block
turtle.down()
turtle.place() -- 1st block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 3rd stack --
turtle.place() -- 1st block
turtle.up()
turtle.place() -- 2nd block
turtle.up()
turtle.place() -- 3rd block
turtle.up()
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 4th stack --
turtle.place() -- 4th block
turtle.down()
turtle.place() -- 3rd block
turtle.down()
turtle.place() -- 2nd block
turtle.down()
turtle.place() -- 1st block
-- 3rd wall --
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
-- 1st stack --
turtle.select(3) -- slot 3 selected
turtle.place() -- 1st block
turtle.up()
turtle.place() -- 2nd block
turtle.up()
turtle.place() -- 3rd block
turtle.up()
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 2nd stack
turtle.place() -- 4th block
turtle.down()
turtle.place() -- 3rd block
turtle.down()
turtle.select(5) -- slot 5 selected
turtle.place() -- window
turtle.down()
turtle.select(3) -- slot 3 selected
turtle.place() -- 1st block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 3rd stack --
turtle.place() -- 1st block
turtle.up()
turtle.place() -- 2nd block
turtle.up()
turtle.place() -- 3rd block
turtle.up()
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
-- last wall --
turtle.select(4) -- slot 4 selected
turtle.place() -- 4th block
turtle.down()
turtle.place() -- 3rd block
turtle.down()
turtle.place() -- 2nd block
turtle.down()
turtle.place() -- 1st block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- 2nd stack --
turtle.place() -- 1st block
turtle.up()
turtle.select(5) -- slot 5 selected
turtle.place() -- window
turtle.select(4) -- slot 4 selected
turtle.up()
turtle.place() -- 3rd block
turtle.up()
turtle.place() -- 4th block
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
-- last stack --
turtle.place() -- 4th block
turtle.down()
turtle.place() -- 3rd block
turtle.down()
turtle.place() -- 2nd block
turtle.down()
turtle.place() -- 1st block
-- lighting --
turtle.up()
turtle.up()
turtle.up()
turtle.up()
turtle.forward()
turtle.forward()
turtle.select(7) -- slot 7 selected
turtle.placeDown() -- lamp 1
turtle.forward()
turtle.placeDown() -- lamp 2
turtle.forward()
turtle.placeDown() -- lamp 3
turtle.turnLeft()
turtle.forward()
turtle.placeDown() -- lamp 4
turtle.turnLeft()
turtle.forward()
turtle.placeDown() -- lamp 5
turtle.forward()
turtle.placeDown() -- lamp 6
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.placeDown() -- lamp 7
turtle.forward()
turtle.placeDown() -- lamp 8
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.down()
turtle.down()
turtle.down()
turtle.down()
turtle.forward()
turtle.forward()
-- end --
textutils.slowPrint("house Building Complete.")

If you think that typing is boring, put this in the shell
prompt:

pastebin get QwLiNURd "houser" – change this to whatever name you want Without quotes.

Some Screenshots:

https://www.flickr.c...326847@N07/sets - my flickr account
Edited on 21 September 2014 - 03:49 AM
theoriginalbit #2
Posted 19 September 2014 - 02:53 PM
On these forums you can use [code][/code] tags around code to have it syntax highlighted.
KrishGM #3
Posted 21 September 2014 - 05:48 AM
thanks, theoriginalbit.
Chaos_Therum #4
Posted 09 March 2015 - 08:26 AM
thanks, theoriginalbit.

You should look into loops you could probably cut your code to a fifth of the size. That would probably be the next step in optimizing this I assume you are new to programming. Which if you are this is a pretty good early program.