Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This builds a 2 storey house.
- -- Place the turtle on the ground at the right front corner
- -- of where you want the house to be.
- -- Place a single chest on the ground behind the turtle.
- -- Download the companion quarry script using this command:
- --
- -- Requires about 1300 fuel in the turtle.
- -- At first, it runs with nothing in the turtle's inventory
- -- while it digs the foundation. After that, place
- -- the following blocks in the turtle's inventory:
- -- Slots 1,2 & 3 - foundation: 2 x 64 + 57
- -- Slot 4 - glass blocks: 4
- -- Slots 5, 6, 7 & 8 - floor planks: 3 x 64 + 25
- -- slots 9, 10 & 11 - interior walls: 2 x 64 + 30
- -- slot 12 - stairs: 4
- -- slots 13, 14, 15 & 16 - roof: 3 x 64 + 4
- --
- -- Place the following in the chest, in the following order:
- -- Outside wall blocks: 7 x 64
- -- Interior wall blocks: 2 x 64 (for ceiling too)
- -- Glass blocks: 24
- -- Roof peak blocks: 14 (these are blocks that match your roof, or not . . :))
- -- Doors: 16
- -- Stone blocks: 6 (for the front and back steps)
- -- Stone steps: 5 (for the same)
- -- Torches: 12
- --
- -- Run when ready :)
- local placed = 0
- local used = 0
- local moved = 0
- -- Build functions --------------------------------
- local function pf() -- place block forward
- turtle.place()
- placed=placed+1
- end
- local function pu()
- turtle.placeUp()
- placed=placed+1
- end
- local function pd()
- turtle.placeDown()
- placed=placed+1
- end
- local function pbu(n) -- place block up
- for i=1,n do
- turtle.forward()
- turtle.placeUp()
- end
- moved=moved+n
- placed=placed+n
- end
- local function pbd(n) -- place block down
- for i=1,n do
- turtle.forward()
- turtle.placeDown()
- end
- moved=moved+n
- placed=placed+n
- end
- local function pbb(n) -- place block forward, back up
- for i=1,n do
- turtle.place()
- turtle.back()
- end
- moved=moved+n
- placed=placed+n
- end
- local function pt(n) -- place top & bottom block, back up, & place middle
- for i=1,n do
- turtle.placeUp()
- turtle.placeDown()
- turtle.back()
- turtle.place()
- end
- moved=moved+n
- placed=placed+(3*n)
- end
- local function ptf(n) -- place right & left block, back up, & place middle. F is for flat ;)
- for i=1,n do
- turtle.turnRight()
- turtle.place()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.place()
- turtle.turnRight()
- turtle.back()
- turtle.place()
- end
- moved=moved+n
- placed=placed+(3*n)
- end
- local function pBack(n) -- place block to the front, and then back up
- for i=1,n do
- turtle.place()
- turtle.back()
- end
- moved=moved+n
- placed=placed+n
- end
- local function roofL(n) -- builds the roof and moves to the left
- for i=1,n do
- turtle.placeUp()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- moved=moved+n
- placed=placed+n
- end
- local function roofR(n) -- builds the roof and moves to the right
- for i=1,n do
- turtle.placeUp()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- moved=moved+n
- placed=placed+n
- end
- local function torch()
- turtle.select(15)
- turtle.up()
- turtle.placeUp()
- turtle.down()
- moved=moved+2
- placed=placed+1
- end
- -- Simple Movement functions --------------------------------
- local function t() -- turn around
- turtle.turnRight()
- turtle.turnRight()
- end
- local function l() -- turn left
- turtle.turnLeft()
- end
- local function r() -- turn right()
- turtle.turnRight()
- end
- local function u(n) -- turtle go up
- for i=1,n do
- turtle.up()
- end
- moved=moved+n
- end
- local function d(n) -- turtle go down
- for i=1,n do
- turtle.down()
- end
- moved=moved+n
- end
- local function f(n) -- turtle go forward
- for i=1,n do
- turtle.forward()
- end
- moved=moved+n
- end
- local function b(n) -- turtle go back
- for i=1,n do
- turtle.back()
- end
- moved=moved+n
- end
- -- Complex Movement functions ---------------
- local function nextRowL() -- moves forward and up for next roof row to the left
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.up()
- moved=moved+3
- end
- local function nextRowR() -- moves forward and up for next roof row to the right
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.up()
- moved=moved+3
- end
- local function nextRowDL() -- moves back and down for next roof row to the left
- turtle.down()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.back()
- moved=moved+3
- end
- local function nextRowDR() -- moves back and down for next roof row to the right
- turtle.down()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.back()
- moved=moved+3
- end
- local function hLTurn() -- flat left turn at the end of a horizontal row (ie floor)
- turtle.forward()
- turtle.left()
- turtle.forward()
- turtle.left()
- moved=moved+2
- end
- local function hRTurn() -- flat right turn at the end of a horizontal row (ie floor)
- turtle.forward()
- turtle.right()
- turtle.forward()
- turtle.right()
- moved=moved+2
- end
- local function nextCrse() -- moves turtle up to next row (ie a wall)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- end
- ---------------------------------------------------------------
- --------------- Building code starts here ---------------------
- ---------------------------------------------------------------
- -- Digs a foundation for the 2 Storey house ---------------
- print("")
- print("Going off to dig the foundation.")
- print("Be right back.")
- print("")
- turtle.turnLeft()
- for i=1,11 do
- turtle.forward()
- moved=moved+1
- end
- turtle.turnRight()
- turtle.up()
- moved=moved+1
- shell.run("quarry -dim 13 12 4 -invert false -startY 75")
- local function drop()
- for i=1,16 do
- turtle.select(i)
- turtle.drop(64)
- end
- end
- drop()
- turtle.turnRight()
- for i=1,11 do
- turtle.forward()
- moved=moved+1
- end
- turtle.turnLeft()
- turtle.down()
- moved=moved+1
- print("Whew! Ok, load me up with blocks, so I can build the house")
- -- Building the foundation ---------------
- -- start on the edge of the foundation hole
- -- front right corner
- print("Make sure the turtle has the following:")
- print("(in this order)")
- print("")
- print("- Foundation wall blocks: 2 x 64 + 57")
- print("- Glass: 4")
- print("- Floor blocks: 3 x 64 + 25")
- print("- Interior wall blocks: 2 x 64 + 30")
- print("- Stairs: 4")
- print("- Roof blocks: 3 x 64 + 4")
- print("-----------------")
- print("Type 'r' when ready to go")
- local m=io.read() -- prompts for user input
- if m=="r" then
- end
- print("")
- print("Make sure the chest has the following:")
- print("- Outside wall blocks: 7 x 64")
- print("- Interior wall blocks: 2 x 64 (for ceiling)")
- print("- Glass blocks: 23")
- print("- Roof peak blocks: 14")
- print("- Doors: 16")
- print("- Stone blocks: 6 (steps)")
- print("- Stone steps: 4")
- print("- Torches: 12")
- print("-----------------")
- print("Type 'r' when ready to go")
- local m=io.read() -- prompts for user input
- if m=="r" then
- end
- print("")
- print("----- Building the foundation -----")
- print("")
- f(1)
- d(1)
- turtle.select(1)
- pd()
- -- building bottom row ---------------
- pbd(12)
- l()
- pbd(11)
- l()
- pbd(12)
- l()
- pbd(10)
- u(1)
- pbd(1) -- start of 2nd row ------------------
- l()
- pbd(12)
- l()
- pbd(2)
- turtle.select(4)
- pbd(1) -- Placing window
- turtle.select(1)
- pbd(2)
- turtle.select(4)
- pbd(1) -- Placing 2nd window
- turtle.select(2) -- NEW STACK
- pbd(5)
- l()
- pbd(12)
- l()
- pbd(3)
- turtle.select(4)
- pbd(1) -- Placing window
- turtle.select(2)
- pbd(4)
- turtle.select(4)
- pbd(1) -- Placing 2nd window
- turtle.select(2)
- pbd(1)
- u(1)
- pbd(1) -- start of 3rd row -----------------
- l()
- pbd(12)
- l()
- pbd(11)
- l()
- pbd(12)
- l()
- pbd(2)
- turtle.select(3) -- NEW STACK
- pbd(8)
- l()
- print("----- Foundation complete-----")
- -- start placing flooring ------------------------------
- print("----- Laying ground floor -----")
- print("")
- turtle.select(5)
- pbd(11) --1
- l()
- pbd(1)
- l()
- pbd(10)
- r()
- pbd(1)
- r()
- pbd(10) --3
- l()
- pbd(1)
- l()
- pbd(10)
- r()
- pbd(1)
- r()
- pbd(10) --5
- l()
- pbd(1)
- l()
- pbd(7)
- turtle.select(6)
- pbd(3)
- r()
- pbd(1)
- r()
- pbd(5) --7
- f(1)
- pbd(4)
- l()
- pbd(1)
- l()
- pbd(10)
- r()
- pbd(1)
- r()
- pbd(10) --9
- l()
- pbd(1)
- l()
- pbd(10)
- r()
- pbd(1)
- r()
- print("----- Ground floor complete -----")
- print("")
- -- Building the stairs ---------------------
- print("----- Placing stairs -----")
- print("")
- u(1)
- f(1)
- l()
- b(1)
- turtle.select(9) -- wall blocks
- pt(2)
- l()
- f(1)
- pu()
- b(1)
- pt(1)
- d(1)
- r()
- f(1)
- pf()
- turtle.select(12) -- stairs
- b(1)
- pf() --1
- r()
- f(1)
- l()
- f(2)
- r()
- pu() --2
- f(1)
- t()
- turtle.select(9) -- wall blocks (uses 12 total)
- pf()
- t()
- u(1)
- turtle.select(12) -- stairs
- pu() --3
- f(1)
- r()
- f(1)
- u(1)
- pu() --4
- b(1)
- d(1)
- t()
- print("----- Stairs complete ------")
- print("")
- -- Laying first floor walls ---------------
- print("Building first floor walls -----")
- print("")
- turtle.select(6) -- flooring
- pu()
- turtle.select(9) -- wall blocks
- pd()
- b(1)
- pf()
- pu() -- doorway
- b(1)
- pt(4)
- b(1) -- doorway
- pt(3)
- r()
- f(1)
- l()
- f(6)
- l()
- pt(2)
- pu() -- doorway
- b(1)
- pt(2)
- r()
- f(1)
- l()
- f(4)
- l()
- pt(1)
- l()
- pt(1)
- pu() -- used 44 wall blocks
- print("-----First floor walls complete -----")
- print("")
- -- 2nd floor, floor ------------------
- print("----- Laying 2nd floor -----")
- print("")
- l()
- f(2)
- u(3)
- r()
- turtle.select(6)
- pd()
- pbd(4)
- r()
- pbd(1)
- r()
- pbd(5)
- f(1)
- pd()
- pbd(3)
- r()
- pbd(1)
- l()
- pbd(1)
- l()
- turtle.select(7)
- pbd(2)
- l()
- pbd(10) --1
- r()
- pbd(1)
- r()
- pbd(10)
- l()
- pbd(1)
- l()
- pbd(10) --3
- r()
- pbd(1)
- r()
- pbd(10)
- l()
- pbd(1)
- l()
- pbd(10) --5
- r()
- pbd(1)
- r()
- pbd(7)
- turtle.select(8)
- pbd(3)
- l()
- pbd(1)
- l()
- pbd(10) --7
- r()
- pbd(1)
- r()
- pbd(10)
- t()
- print("----- 2nd floor complete -----")
- print("")
- -- 2nd floor walls ---------------
- print("----- Building 2nd floor walls -----")
- print("")
- u(1)
- turtle.select(9)
- f(3)
- l()
- f(1)
- pt(1)
- pu() --closet
- l()
- b(1)
- l()
- pt(1)
- turtle.select(10)
- pt(2)
- pu() --doorway
- b(1)
- l()
- pt(5)
- r()
- b(1)
- l()
- f(5)
- r() -- doorway
- pu()
- b(1)
- pt(2)
- l()
- pt(3)
- r()
- b(1)
- r()
- f(1)
- pu() --closet
- b(1)
- pt(1)
- b(4)
- r()
- pt(2)
- pu() --doorway
- b(1)
- l()
- pt(4)
- pu()
- turtle.select(11)
- r()
- b(1)
- r()
- pt(1)
- b(3)
- l()
- pt(1)
- pu() --doorway
- b(1)
- l()
- pt(5)
- l()
- f(1)
- l(1)
- b(3)
- pt(1)
- pu() --doorway
- b(1)
- pt(1)
- pu()
- r()
- f(4)
- l()
- f(7)
- t()
- print("----- 2nd floor walls complete -----")
- print("")
- -- build the back roof ---------------
- print("----- Building the back roof -----")
- print("")
- turtle.select(13)
- for i=1,2 do -- build roof in rows of 2
- roofR(14)
- nextRowL()
- roofL(14)
- nextRowR()
- end
- roofR(8) --5th row
- turtle.select(14)
- roofR(6)
- nextRowL()
- roofL(14)
- nextRowR()
- roofR(14)
- print("----- Back roof completed -----")
- print("")
- f(2)
- l()
- f(1)
- l()
- -- build the front roof ---------------
- print("----- Building the front roof -----")
- print("")
- roofR(14) -- 1st row
- nextRowDL()
- roofL(14)
- nextRowDR()
- roofR(2) -- 3rd
- turtle.select(15)
- roofR(12)
- nextRowDL()
- roofL(14)
- nextRowDR()
- roofR(14) -- 5th
- nextRowDL()
- roofL(14)
- nextRowDR()
- roofR(10)
- turtle.select(16)
- roofR(4)
- print("----- Front roof complete -----")
- print("")
- l()
- f(2)
- r()
- d(6)
- t()
- print("----- Reloading inventory. ------")
- print("")
- -- reloads from chest ---------------
- for i=1,16 do
- turtle.select(i)
- turtle.drop(64)
- end
- turtle.select(1)
- for i=1,15 do
- turtle.suck(i,64)
- end
- turtle.select(6) -- This section selects an inventory slot to make sure it's loaded with blocks
- if turtle.getItemCount(6) < 64 then
- print("Make sure the turtle has the following:")
- print("(in this order)")
- print("")
- print("- Outside wall blocks: 7 x 64")
- print("- Interior wall blocks: 2 x 64 (for ceiling)")
- print("- Glass blocks: 64")
- print("- Roof peak blocks: 14")
- print("- Doors: 16")
- print("- Stone blocks: 5")
- print("- Stone steps: 5")
- print("- Torches: 64")
- print("-----------------")
- print("Type 'r' when ready to go")
- local m=io.read() -- prompts for user input
- if m=="r" then
- end
- else
- end
- turtle.select(1)
- -- placing doors ---------------
- print("----- Dealing with privacy concerns -----")
- print("")
- u(1)
- r()
- f(4)
- r()
- f(10)
- l()
- f(3)
- t()
- turtle.select(12)
- pf() -- kitchen door
- torch()
- b(2)
- l()
- b(2)
- r()
- turtle.select(12)
- pf() -- closet door
- torch()
- l()
- b(2)
- turtle.select(12)
- pf() -- utility room door
- l()
- turtle.select(12)
- pf() -- stairs closet
- torch()
- b(2)
- l()
- f(4)
- r()
- turtle.select(12)
- pf() -- front entrance
- torch()
- r()
- f(2)
- l()
- u(2)
- f(3) -- in stairwell
- u(2)
- r()
- f(3)
- r()
- f(2)
- l()
- f(2)
- t()
- turtle.select(12)
- pf() -- bedroom door
- torch()
- t()
- f(3)
- r()
- turtle.select(12)
- pf() -- 1st closet
- l()
- f(1)
- r()
- f(6)
- r()
- f(4)
- r()
- turtle.select(12)
- pf() -- bedroom closet
- torch()
- l()
- f(2)
- r()
- b(2)
- l()
- f(3)
- r()
- f(1)
- r()
- turtle.select(12)
- pf() -- closet door
- torch()
- l()
- f(3)
- r()
- f(3)
- r()
- turtle.select(12)
- pf() -- bedroom door
- torch()
- r()
- turtle.select(12)
- pf() -- bedroom door
- r()
- f(1)
- r()
- turtle.select(12)
- pf() -- bathroom door
- l()
- f(1)
- l()
- f(2)
- t()
- turtle.select(12)
- pf() -- bedroom door
- torch()
- t()
- f(3)
- r()
- f(3)
- turtle.select(12)
- pf() -- closet door
- u(3)
- print("----- Privacy restored -----")
- print("")
- -- placing the ceiling blocks ---------------
- print("----- Installing the ceiling -----")
- print("")
- turtle.select(8)
- pf()
- t()
- pf()
- r()
- b(1)
- pf()
- ptf(9)
- r()
- pbb(3)
- r()
- ptf(10)
- l()
- turtle.select(9)
- pbb(3)
- l()
- ptf(10)
- r()
- pbb(2)
- pf()
- r()
- b(1)
- pBack(9)
- pf()
- l()
- b(1)
- pf()
- print("----- Ceiling completed -----")
- print("")
- print("----- Finishing roof -----")
- print("")
- b(1)
- r()
- f(5)
- l()
- u(5)
- turtle.select(11)
- pu()
- pbu(13)
- -- Starting left end wall ---------------
- turtle.select(1)
- b(1)
- d(1)
- pu()
- l()
- pf()
- t()
- pf()
- d(1)
- pu()
- d(2)
- f(3)
- pf()
- pu()
- b(1)
- pf()
- u(1)
- pt(5)
- d(1)
- pu()
- t()
- pf()
- d(1)
- pu()
- d(1)
- f(3)
- pd()
- b(1)
- pf()
- pt(5)
- turtle.select(10) -- window
- pd()
- turtle.select(1)
- pu()
- b(1)
- pf()
- pt(3)
- turtle.select(10) -- window
- pd()
- turtle.select(1)
- pu()
- b(1)
- pf()
- pt(1)
- d(3)
- f(1)
- t()
- pt(2)
- turtle.select(2)
- pt(10)
- d(3)
- t()
- b(1)
- for i=1,11 do
- turtle.placeUp()
- turtle.back()
- turtle.place()
- end
- turtle.select(10) -- window
- pu()
- turtle.select(2)
- b(1)
- pf()
- u(5)
- -- Starting back wall ---------------
- r()
- pt(2)
- pu()
- pd()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(2)
- pt(1)
- turtle.select(3)
- pt(2)
- pu()
- pd()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(3)
- pt(2)
- pu()
- pd()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(3)
- pt(2)
- d(3)
- f(1)
- t()
- pt(3)
- pu()
- turtle.select(10) -- window
- pd()
- b(1)
- turtle.select(3)
- pf()
- pu()
- turtle.select(10) -- window
- pd()
- b(1)
- turtle.select(3)
- pf()
- pt(2)
- pu()
- b(1)
- pf() -- door
- pt(2)
- pu()
- turtle.select(10) -- window
- pd()
- b(1)
- turtle.select(3)
- pf()
- pt(1)
- d(2)
- t()
- b(2)
- pbb(3)
- pf()
- l()
- b(1)
- turtle.select(12) -- back door
- pf()
- torch()
- turtle.select(13) -- back steps
- d(1)
- r()
- pf()
- t()
- pf()
- r()
- b(1)
- pf()
- b(1)
- turtle.select(14)
- pf()
- turtle.select(3)
- u(1)
- f(2)
- l()
- f(2)
- r()
- f(1)
- r()
- pbb(6)
- turtle.select(4)
- pf()
- l()
- f(1)
- r()
- u(1)
- f(1)
- r()
- -- Starting right end wall ---------------
- pt(1)
- pd()
- pu()
- turtle.select(10) -- window
- b(1)
- pf()
- turtle.select(4)
- pt(10)
- u(3) -- next row
- t()
- b(1)
- pt(2)
- pd()
- turtle.select(10) -- window
- pu()
- turtle.select(4)
- b(1)
- pf()
- pt(5)
- pd()
- turtle.select(10) -- window
- pu()
- turtle.select(4)
- b(1)
- pf()
- pt(1)
- turtle.select(5)
- pu()
- pd()
- b(1)
- pf()
- r()
- pt(1)
- u(3) -- next row
- f(1)
- r()
- pd()
- b(1)
- pf()
- pt(9)
- d(1)
- t()
- pu()
- pf()
- r()
- b(1)
- pf()
- r()
- f(3)
- l()
- u(3) -- next row
- f(1)
- l()
- pf()
- pu()
- b(1)
- pf()
- u(1)
- pt(3)
- d(1)
- t()
- pf()
- pu()
- r()
- b(1)
- pf()
- r()
- f(2)
- r()
- u(3)
- b(2)
- pf()
- l()
- for i=1,7 do
- d(1)
- f(1)
- end
- -- Starting front wall ---------------
- r()
- f(2)
- r()
- f(1)
- r()
- pt(1)
- pu()
- pd()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(5)
- pt(1)
- pu()
- pd()
- turtle.select(6)
- b(1)
- pf()
- pt(1)
- pu()
- pd()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(6)
- pu()
- pd()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(6)
- pt(2)
- pu()
- d(1)
- l()
- pu()
- d(1)
- l()
- pu()
- d(1) -- next row
- pt(1)
- pu()
- b(1) -- doorway
- pf()
- pt(3)
- pu()
- turtle.select(10) -- window
- pd()
- b(1)
- pf()
- pd()
- turtle.select(6)
- pu()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(6)
- pt(1)
- pu()
- turtle.select(10) -- window
- pd()
- b(1)
- pf()
- pd()
- turtle.select(6)
- pu()
- r()
- b(1)
- turtle.select(10) -- window
- pf()
- turtle.select(6)
- d(2) -- next row
- f(1)
- r()
- b(1)
- pbb(7)
- pf()
- t()
- pf()
- r()
- b(1)
- turtle.select(12) -- front door
- pf()
- torch()
- d(1)
- r()
- turtle.select(13) -- front porch
- pf()
- t()
- pf()
- r()
- b(1)
- pf()
- b(1)
- turtle.select(14) -- front stairs
- pf()
- l()
- f(1)
- r()
- pf()
- r()
- f(2)
- l()
- pf()
- -- Back to chest ---------------
- r()
- f(8)
- print("----- House complete -----")
- print("")
- print("Total blocks placed: "..placed)
- print("Total fuel used was: "..moved)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement