Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function estimatefuel(width, length, height)
- return (((width * height * 2) + ((length - 2) * height * 2) + ((length - 1) * (width - 1))) - turtle.getFuelLevel()) / 80
- end
- function digforward(n)
- for i = 1, n do
- repeat
- if turtle.detect() then turtle.dig() end
- until turtle.forward()
- end
- end
- function refuel(n)
- print("Refueling turtle.")
- for i = n, 16 do
- turtle.select(i)
- turtle.refuel()
- end
- turtle.select(1)
- print("Turtle has " .. turtle.getFuelLevel() .. " fuel left.")
- end
- function inventory()
- if turtle.getItemCount(1) < 2 then
- for i = 1, 16 do
- turtle.select(i)
- turtle.transferTo(1, 64)
- end
- turtle.select(1)
- if turtle.getItemCount(1) < 2 then
- print("Turtle has run out of blocks to place. Please refill turtle and press Enter to continue construction.")
- io.read()
- end
- end
- end
- function placeforward(n)
- inventory()
- turtle.placeDown()
- if n > 1 then digforward(1) placeforward((n - 1)) end
- end
- --I got this to work. I don't even know how it works, just don't touch it.
- function buildceiling(width, length)
- placeforward(length - 2)
- turtle.turnRight()
- digforward(1)
- if ((length - 2) * (width - 2)) > 0 then buildceiling(length , (width - 1)) end
- end
- function buildwalls(width, length, height)
- for i = 1, 2 do
- placeforward(length)
- turtle.turnRight()
- digforward(1)
- placeforward(width - 2)
- digforward(1)
- turtle.turnRight()
- end
- if height > 1 then digup(1) buildwalls(width, length, (height - 1)) end
- end
- function digup(n)
- for i = 1, n do
- repeat
- if turtle.detectUp() then turtle.digUp() end
- until turtle.up()
- end
- end
- function build(width, length, height)
- digup(1)
- buildwalls(width, length, height)
- digforward(1)
- turtle.turnRight()
- digforward(1)
- turtle.turnLeft()
- buildceiling(width, length)
- end
- print("Enter the Length (forward):")
- length = tonumber(io.read())
- print("Enter the Width (across):")
- width = tonumber(io.read())
- print("Enter the Height:")
- height = tonumber(io.read())
- estimate = estimatefuel(width, length, height)
- if estimate > 0 then print("Estimating the turtle will require "..estimate.." peices of coal.\nPlace them into the turtle and press Enter to continue.") io.read() refuel(1) end
- print("Please fill the turtle's inventory with required building materials.")
- io.read()
- print("Turtle will now begin construction.")
- build(width, length, height)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement