Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- fuels up the turtle as much as it can
- function fuelUp()
- print("Current Fuel Level: ", turtle.getFuelLevel())
- if turtle.getFuelLevel() == turtle.getFuelLimit() then
- return
- end
- for i = 1, 16 do
- turtle.select(i)
- turtle.refuel(turtle.getItemCount(i))
- if turtle.getFuelLevel() == turtle.getFuelLimit() then
- break
- end
- end
- print("Current Fuel Level: ", turtle.getFuelLevel())
- end
- -- checks if the turtle can hold more fuel
- function checkFuel()
- if turtle.getFuelLevel() <= 0 then
- fuelUp()
- end
- end
- --[[14 - full block
- 15 - slab
- 16 - water bucket]]
- function findBlock(block)
- for i = 1, 13 do
- turtle.select(i)
- if turtle.compareTo(block) then
- return i
- end
- end
- print("no more blocks, need a fillup")
- end
- --checks if there are any more blocks left in the stack, if not the find a new stack
- function checkRemaining(block)
- if turtle.getItemCount() > 0 then
- return
- end
- findBlock(block)
- end
- --move the turtle forward a distance of dist
- function forward(dist)
- for i = 1, dist do
- turtle.forward()
- checkFuel()
- end
- end
- --move the turtle forward a distance of dist placeing a block below it after each move
- function placeForward(dist, block)
- for i = 1, dist do
- turtle.forward()
- turtle.placeDown()
- checkFuel()
- checkRemaining(block)
- end
- end
- function perimeter()
- findBlock(14)
- for i = 1, 4 do
- placeForward(19, 14)
- turtle.turnRight()
- end
- end
- --layer 1 functions
- function funnels()
- --get to first block
- turtle.forward()
- turtle.turnRight()
- forward(8)
- turtle.turnLeft()
- --build the funnels
- findBlock(14)
- for i = 1, 4 do
- turtle.placeDown()
- for j = 1, 2 do
- findBlock(14)
- placeForward(7, 14)
- turtle.turnLeft()
- end
- turtle.turnRight()
- turtle.turnRight()
- for j = 1, 2 do
- turtle.forward()
- findBlock(16)
- turtle.placeDown()
- end
- turtle.forward()
- turtle.turnRight()
- findBlock(14)
- turtle.placeDown()
- end
- --get back to the initial location
- turtle.turnLeft()
- forward(8)
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- --layer 2 functions
- function placeSquare(num)
- checkRemaining(14)
- for i = 1, 8 do
- for j = 1, 8 do
- turtle.placeDown()
- checkFuel()
- checkRemaining(14)
- turtle.forward()
- end
- if i%2 == num then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- turtle.forward()
- end
- end
- function layer2()
- --get inside the wall
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- placeSquare(1)
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- placeSquare(0)
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- placeSquare(1)
- turtle.turnRight()
- for i = 1, 11 do
- turtle.forward()
- end
- placeSquare(1)
- --return to start
- for i = 1, 9 do
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1, 19 do
- turtle.forward()
- end
- turtle.turnRight()
- turtle.forward()
- end
- --layer 3 functions
- function placeSlabs(turn)
- --row 1
- findBlock(15)
- for x = 1, 3 do
- turtle.placeDown()
- checkFuel()
- checkRemaining(15)
- forward(3)
- end
- --move to next row
- if turn == 0 then
- turtle.turnRight()
- forward(3)
- turtle.turnRight()
- else
- turtle.turnLeft()
- forward(3)
- turtle.turnLeft()
- end
- --row 2
- for i = 1, 3 do
- forward(3)
- turtle.placeDown()
- checkFuel()
- checkRemaining(15)
- end
- --move to next row
- if turn == 0 then
- turtle.turnLeft()
- forward(3)
- turtle.turnLeft()
- else
- turtle.turnRight()
- forward(3)
- turtle.turnRight()
- end
- --row 3
- for x = 1, 3 do
- turtle.placeDown()
- checkFuel()
- checkRemaining(15)
- forward(3)
- end
- end
- function slabs()
- --get inside the wall
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- placeSlabs(0)
- turtle.turnRight()
- forward(5)
- turtle.turnRight()
- forward(3)
- placeSlabs(1)
- turtle.turnRight()
- turtle.turnRight()
- forward(14)
- turtle.turnLeft()
- placeSlabs(0)
- turtle.turnLeft()
- forward(6)
- turtle.turnRight()
- forward(2)
- placeSlabs(0)
- --return to start
- turtle.turnLeft()
- forward(18)
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- --layer 4 functions
- function roof()
- checkRemaining(14)
- for i = 1, 19 do
- for j = 1, 19 do
- turtle.placeDown()
- checkFuel()
- checkRemaining(14)
- turtle.forward()
- end
- if i%2 == 0 then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- end
- --return to start
- for i = 1, 19 do
- turtle.forward()
- end
- turtle.turnRight()
- for i = 1, 19 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- -- main function
- function run()
- --1st layer of blocks
- -- turtle.up()
- -- perimeter()
- -- funnels()
- --2nd layer of blocks
- -- turtle.up()
- -- perimeter()
- -- layer2()
- --slab it up
- -- turtle.up()
- -- perimeter()
- slabs()
- --top it off
- -- turtle.up()
- -- roof()
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement