Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local layerPairs = nil
- local maxLayer = 0
- local inPosition = false
- function dropItems()
- for x = 2, 16 do
- turtle.select(x)
- turtle.drop(64)
- end
- end
- function checkCoal()
- bendzoKiekis = turtle.getFuelLevel()
- if bendzoKiekis==0 then
- turtle.select(1)
- while not turtle.refuel(1) do
- print('out of fuel')
- sleep(1)
- end
- end
- end
- function moveForward(force)
- checkCoal()
- if force == true then
- while turtle.detect() do
- turtle.dig()
- end
- end
- return turtle.forward()
- end
- function moveUp(force)
- checkCoal()
- if force == true then
- while turtle.detectUp() do
- turtle.digUp()
- end
- end
- return turtle.up()
- end
- function moveDown(force)
- checkCoal()
- if force == true then
- while turtle.detectDown() do
- turtle.digDown()
- end
- end
- return turtle.down()
- end
- function digForward()
- turtle.dig()
- moveForward(true)
- end
- function digUp()
- turtle.digUp()
- moveUp(true)
- end
- function digDown()
- turtle.digDown()
- moveDown(true)
- end
- function digTwoColumns()
- for y = 1, 3 do
- digUp()
- end
- digForward()
- for y = 1, 3 do
- digDown()
- end
- end
- function digFourColumns()
- digTwoColumns()
- digForward()
- digTwoColumns()
- end
- function digTwoLayers()
- digForward()
- turtle.turnRight()
- digFourColumns()
- turtle.turnLeft()
- digForward()
- turtle.turnLeft()
- digFourColumns()
- turtle.turnRight()
- maxLayer = maxLayer + 2
- end
- function reachMaxLayer()
- while moveForward(false) do
- maxLayer = maxLayer + 1
- end
- inPosition = true
- end
- function goMining()
- if inPosition == true then
- inPosition = false
- else
- for i = 1, maxLayer do
- moveForward(true)
- end
- end
- for i = 1, layerPairs do
- digTwoLayers()
- end
- end
- function goTakeCoal()
- moveUp(true)
- turtle.select(1)
- hasFuel = turtle.getItemCount(1)
- needCount = 64 - hasFuel
- while not turtle.suck(needCount) do
- print('please put fuel in the chest')
- sleep(1)
- end
- moveDown(true)
- end
- function goStoreItems()
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, maxLayer do
- moveForward(true)
- end
- dropItems()
- goTakeCoal()
- turtle.turnRight()
- turtle.turnRight()
- end
- print('How many layer pairs should I dig per session? ')
- local input = nil
- while true do
- input = tonumber(read())
- if (input == nil) or (math.floor(input) ~= input) then
- print('input should be an integer.')
- else
- layerPairs = input
- term.clear()
- break
- end
- end
- goStoreItems()
- reachMaxLayer()
- while true do
- goMining()
- goStoreItems()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement