Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Stack = 0
- ItemIndex = 2
- function TurnBackFloor(length)
- print("Turning back...")
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,length - 1 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- function TurnBackRoof(length)
- print("Turning back...")
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,length - 1 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- function ReturnToStart(width,height)
- print("Returning to start position...")
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,width - 1 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnLeft()
- for i=1,height - 1 do
- turtle.down()
- end
- end
- function ReturnToStartRoof(width,height)
- print("Returning to start position...")
- turtle.turnLeft()
- for i=1,width - 1 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- turtle.turnLeft()
- for i=1,height - 1 do
- turtle.down()
- end
- end
- function MakeLine(length)
- print("Building floor...")
- for i=1,length do
- if Stack == 64 then
- ItemIndex = ItemIndex + 1
- turtle.select(ItemIndex)
- Stack = 0
- end
- while not turtle.placeDown() do
- turtle.digDown()
- end
- Stack = Stack + 1
- if i ~= length then
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- end
- function NextLine()
- print("Preparing for next line...")
- turtle.turnRight()
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.turnRight()
- end
- function MakeFloor(width,length)
- print("Building floor...")
- for i=1,width do
- MakeLine(length)
- TurnBackFloor(length)
- if i ~= width then
- NextLine()
- else
- turtle.turnRight()
- end
- end
- end
- function WallUp(height)
- print("Building wall...")
- for i=1,height do
- if Stack == 64 then
- ItemIndex = ItemIndex + 1
- turtle.select(ItemIndex)
- Stack = 0
- end
- while not turtle.place() do
- turtle.dig()
- end
- Stack = Stack + 1
- turtle.place()
- if i ~= height then
- while not turtle.up() do
- turtle.digUp()
- end
- end
- end
- for i=1,height - 1 do
- while not turtle.down() do
- turtle.digDown()
- end
- end
- end
- function MakeLengthWall(length,height)
- print("Starting to build wall...")
- for i=1,length do
- WallUp(height)
- turtle.turnRight()
- if i ~= length then
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.turnLeft()
- end
- end
- end
- function MakeWidthWall(width,height)
- print("Starting to build wall...")
- for i=1,width do
- WallUp(height)
- turtle.turnRight()
- if i ~= width then
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.turnLeft()
- end
- end
- end
- function PrepareRoof(height)
- print("Positioning to build roof...")
- for i=1,height - 1 do
- while not turtle.up() do
- turtle.digUp()
- end
- end
- end
- function MakeRoof(length,width)
- print("Building roof...")
- for i=1,width do
- for e=1,length do
- if Stack == 64 then
- ItemIndex = ItemIndex + 1
- turtle.select(ItemIndex)
- Stack = 0
- end
- if turtle.placeUp() then
- Stack = Stack + 1
- end
- if e ~= length then
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- TurnBackRoof(length)
- if i ~= width then
- NextLine()
- end
- end
- end
- function CheckBuildLimit(length,width,height)
- print("Calculating required item amount...")
- if (length * width) > 64*15 then
- if ((length * height) * 2) + ((width * height) * 2) > 64*15 then
- if (length * width) > 64*15 then
- return true
- end
- end
- end
- return false
- end
- function ResetPosition(width,height)
- print("Moving back to starting position...")
- turtle.turnLeft()
- for i=1,width - 1 do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- for i=1,height do
- while not turtle.down() do
- turtle.digDown()
- end
- end
- turtle.turnLeft()
- end
- function RequestInput()
- io.write("Enter length of room:")
- local length = io.read()
- io.write("Enter width of room:")
- local width = io.read()
- io.write("Enter height of room:")
- local height = io.read()
- local room = {tonumber(length),tonumber(width),tonumber(height)}
- return room
- end
- function Done()
- print("Finished building room!")
- print("Fuel remaining:")
- print(turtle.getFuelLevel())
- end
- function RequestResource()
- io.write("Refill resources - ")
- io.write("press enter when finished..")
- _ = io.read()
- end
- function Start()
- local room = RequestInput()
- if (CheckBuildLimit(room[1], room[2], room[3])) then
- print("Area is too big!")
- return
- end
- Stack = 0
- ItemIndex = 2
- turtle.select(ItemIndex)
- MakeFloor(room[2],room[1])
- RequestResource()
- Stack = 0
- ItemIndex = 2
- turtle.select(ItemIndex)
- MakeLengthWall(room[1],room[3])
- MakeWidthWall(room[2],room[3])
- MakeLengthWall(room[1],room[3])
- MakeWidthWall(room[2],room[3])
- ReturnToStart(room[2],room[3])
- RequestResource()
- Stack = 0
- ItemIndex = 2
- turtle.select(ItemIndex)
- PrepareRoof(room[3])
- MakeRoof(room[1],room[2])
- ReturnToStartRoof(room[2],room[3])
- Done()
- end
- Start()
Add Comment
Please, Sign In to add comment