Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Turtle configuration
- refuel_level = 600
- --Turtle slot configuration
- fuel_slot = 16
- fuel_ender_chest_slot = 15
- sorting_ender_chest_slot = 14
- max_mining_slot = 13
- --Varables setup for funcition use later. do not change.
- oporation_type = 0 --(0 = dig, 1 = place)
- slot = 1 --(Default is set to 1, slot to use placing blocks)
- length = 0 --(Default is set to 0 for testing to know if user need to enter a valid length)
- width = 0 --(Default is set to 0 for testing to know if user need to enter a valid width)
- function sand_test()
- --Test is there is anything in the way of moving forward
- --Loop to test for blocks that fall like sand or gravel
- while turtle.detect() do
- turtle.dig()
- end
- end
- function go_forward()
- --Moving the turtle forward
- refuel_turtle()
- sand_test()
- turtle.forward()
- end
- function go_down()
- refuel_turtle()
- turtle.digDown()
- turtle.down()
- end
- function full_inventory_test()
- --Test for full inventory
- turtle.select(max_mining_slot) --Last slot for placing items while digging
- full = turtle.getItemCount(max_mining_slot) > 0
- turtle.select(1)
- return full
- end
- function refuel_turtle()
- --Test fuel level.
- --If it is low check for fuel in fuel slot.
- --If there is no fuel in fuel slot it places the ender chest and get more fuel
- --Test the current fuel level
- while turtle.getFuelLevel() < refuel_level do
- --Test if there is more then one fuel in
- if turtle.getItemCount(fuel_slot) > 0 then
- turtle.select(fuel_slot)
- turtle.refuel(1)
- else
- while turtle.detectUp() do
- turtle.digUp()
- end
- turtle.select(fuel_ender_chest_slot)
- turtle.placeUp()
- turtle.select(fuel_slot)
- turtle.suckUp()
- turtle.select(fuel_ender_chest_slot)
- turtle.digUp()
- end
- end
- end
- function dig_line(length)
- -- body
- --Even number vs uneven number - based on the number the code with start going left or right.
- for i=1,length do
- go_forward()
- end
- end
- function dig_level(length, width)
- next_turn = 0
- for i=1,width do
- api_turtle.dig_line(length)
- if i == width then
- else
- if next_turn == 0 then
- turtle.turnLeft()
- api_turtle.go_forward()
- turtle.turnLeft()
- next_turn = 1
- else
- turtle.turnRight()
- api_turtle.go_forward()
- turtle.turnRight()
- next_turn = 0
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement