Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --block in front of turtle at beginning is bottom left corner
- --when viewed from above
- -- 1 = Wall
- -- 2 = Roof
- -- 3 = Door
- -- 4 = Chest
- -- 5 = Crafting table
- -- 6 = Bed
- -- 16 = Fuel
- local wallIndex = 1
- local roofIndex = 2
- local doorIndex = 3
- local chestIndex = 4
- local craftIndex = 5
- local bedIndex = 6
- local fuelIndex = 16
- function forceMoveLeft()
- turtle.turnLeft()
- forceMoveForward()
- turtle.turnRight()
- end
- function forceTurnLeft()
- turtle.turnLeft()
- forceMoveForward()
- end
- function forceMoveRight()
- turtle.turnRight()
- forceMoveForward()
- turtle.turnLeft()
- end
- function forceMoveUp()
- while not turtle.up() do
- turtle.digUp()
- end
- end
- function forceMoveDown()
- while not turtle.down() do
- turtle.digDown()
- end
- end
- function forceMoveBack()
- turtle.turnLeft()
- turtle.turnLeft()
- forceMoveForward()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- function forceMoveForward()
- refuel()
- while not turtle.forward() do
- turtle.dig()
- end
- end
- function refuel()
- if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 10 then
- print("Refuelling")
- turtle.select(fuelIndex)
- turtle.refuel(1)
- end
- end
- function fillInDirection(length, height, blockIndex)
- for h = 1, height do
- --move to just before the end
- for i = 1, length do
- forceMoveForward()
- end
- --now move backwards, placing blocks
- print("Placing row")
- for l = 1, length do
- turtle.back()
- placeByIndex(blockIndex)
- end
- forceMoveUp()
- end
- print("Resetting height")
- --reset to original position
- for h = 1, height do
- turtle.down()
- end
- end
- function placeByIndex(index)
- turtle.select(index)
- turtle.place()
- end
- function buildRoom()
- print("Building left wall")
- fillInDirection(3,2,wallIndex) --left wall
- turtle.turnRight()
- print("Building front wall")
- fillInDirection(3,2,wallIndex) -- front wall
- print("Adding door space to front wall")
- --clear the door part of the wall and place door
- forceMoveRight()
- forceMoveForward()
- forceMoveForward()
- forceTurnLeft() -- clear bottom half of door
- forceMoveUp() -- clear top half of door
- turtle.down()
- turtle.back()
- --move to the end of the front wall on the right
- turtle.turnRight()
- forceMoveForward()
- forceMoveForward()
- forceTurnLeft()
- print("Building right wall")
- fillInDirection(3,2,wallIndex) --right wall
- --move to place back wall
- forceMoveRight()
- forceMoveForward()
- forceMoveForward()
- forceMoveForward()
- forceMoveForward()
- forceTurnLeft()
- print("Building back wall")
- fillInDirection(3,2,wallIndex) --back wall
- print("Building the roof")
- forceMoveUp()
- forceMoveUp()
- forceMoveForward()
- turtle.turnLeft()
- fillInDirection(3,1,roofIndex)
- forceMoveRight()
- fillInDirection(4,1,roofIndex) --extra to cover door
- forceMoveRight()
- fillInDirection(3,1,roofIndex)
- forceMoveRight()
- print("Moving inside")
- for i = 1, 4 do
- forceMoveForward()
- end
- forceMoveDown()
- forceMoveDown()
- forceMoveForward()
- forceTurnLeft()
- forceMoveForward()
- turtle.turnLeft()
- forceMoveForward() -- on the threshold
- print("Clearing interior")
- forceMoveForward()
- --clear front inside
- forceMoveRight()
- turtle.digUp()
- forceMoveLeft()
- turtle.digUp()
- forceMoveLeft()
- turtle.digUp()
- --clear middle inside
- forceMoveForward()
- turtle.digUp()
- forceMoveRight()
- turtle.digUp()
- forceMoveRight()
- turtle.digUp()
- --clear back inside
- forceMoveForward()
- turtle.digUp()
- forceMoveLeft()
- turtle.digUp()
- forceMoveLeft()
- turtle.digUp()
- print("Placing interior items")
- --place interior items
- turtle.back()
- turtle.back()
- placeByIndex(bedIndex)
- forceMoveRight()
- turtle.forward()
- placeByIndex(chestIndex)
- forceMoveRight()
- placeByIndex(craftIndex)
- print("Placing door")
- --Lastly, place the door
- forceMoveLeft()
- turtle.back()
- turtle.back()
- turtle.back()
- placeByIndex(doorIndex)
- --move to next start point
- forceMoveRight()
- forceMoveRight()
- forceMoveForward()
- print("House complete!")
- print("Press enter to close")
- read()
- end
- --Do the things
- buildRoom()
Advertisement
Add Comment
Please, Sign In to add comment