Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Prepare(height)
- print("Positioning for Roofing...")
- for i=1,height do
- while not turtle.up() do
- turtle.digUp()
- end
- end
- end
- function Done()
- print("Finished roofing!")
- print("Fuel remaining:")
- print(turtle.getFuelLevel())
- end
- function ResetPosition(width,height)
- print("Moving back to starting position...")
- turtle.turnRight()
- for i=1,width 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 NextLine()
- print("Preparing for next line...")
- turtle.turnRight()
- while not turtle.forward() do
- turtle.dig()
- end
- turtle.turnRight()
- end
- function TurnBack(length)
- print("Returning...")
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,length do
- while not turtle.forward() do
- turtle.dig()
- end
- end
- end
- function Roofing(length,width)
- print("building roof...")
- local stack = 0
- local itemIndex = 2
- turtle.select(itemIndex)
- 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
- while not turtle.forward() do
- turtle.dig()
- end
- end
- TurnBack(length)
- NextLine()
- end
- end
- function Start()
- local roof = RequestInput()
- if (CheckBuildLimit(roof)) then
- print("Area is too big!")
- return
- end
- Prepare(roof[3])
- Roofing(roof[1],roof[2])
- ResetPosition(roof[2],roof[3])
- Done()
- end
- function CheckBuildLimit(roof)
- if (roof[1] * roof[2]) + roof[3] > 64*15 then
- return true
- end
- return false
- end
- function RequestInput()
- io.write("Enter length of roof:")
- local length = io.read()
- io.write("Enter width of roof:")
- local width = io.read()
- io.write("Enter height of roof (Excluding turtle position):")
- local height = io.read()
- local roof = {tonumber(length),tonumber(width),tonumber(height)}
- return roof
- end
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement