Advertisement
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 = Furnace
- -- 6 = Bed
- -- 16 = Fuel
- local wallIndex = 1
- local roofIndex = 2
- local doorIndex = 3
- local chestIndex = 4
- local furnaceIndex = 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 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
- print("Moving to end of section")
- forceMoveForward()
- end
- --now move backwards, placing blocks
- print("Placing row")
- for l = 1, length do
- turtle.back()
- placeByIndex(blockIndex)
- end
- print("Moving up for next section")
- 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 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()
- placeByIndex(doorIndex)
- --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()
- for i = 1, 3 do
- fillInDirection(3,1,roofIndex)
- forceMoveRight()
- end
- --forceMoveBack()
- --fillInDirection(1,2,cornerIndex) -- corner
- end
- --Do the things
- buildRoom()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement