Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local top = 46
- local bottom = 7
- local width = 63
- local torches = 2
- local torchCounter = 0
- local xStartRow = 4
- local xSpacing = 6
- local yStartRow = {8, 3}
- local ySpacing = 9
- local function refuel()
- if turtle.getFuelLevel() == 0 then
- local prev = turtle.getSelectedSlot()
- turtle.select(1)
- if not turtle.refuel(1) then
- print('Need more fuel')
- while not turtle.refuel(1) do
- sleep(1)
- end
- end
- turtle.select(prev)
- end
- end
- local function advance()
- if turtle.getSelectedSlot() == 16 then
- print('Need more materials')
- local empty = true
- while empty do
- for n=3, 16 do
- if turtle.getItemCount(n) > 0 and turtle.getItemDetail(n).name == 'chisel:marble' then
- empty = false
- turtle.select(n)
- return
- end
- end
- sleep(5)
- end
- else
- turtle.select(turtle.getSelectedSlot() + 1)
- end
- end
- local function replace()
- while turtle.detect() do
- turtle.dig()
- sleep(.5)
- end
- local data = turtle.getItemDetail()
- while turtle.getItemCount() == 0 or turtle.getItemDetail().name ~= 'chisel:marble' do
- advance()
- end
- turtle.place()
- end
- local function returnToFloor()
- turtle.turnRight()
- while not turtle.forward() do
- turtle.dig()
- sleep(.5)
- end
- turtle.turnLeft()
- end
- local function checkForTorch(x, y)
- print(torchCounter)
- if x%xSpacing == xStartRow then
- if torchCounter % 2 == 0 then
- if y%ySpacing == yStartRow[1] then
- local prev = turtle.getSelectedSlot()
- turtle.select(torches)
- if not turtle.placeUp() then
- print 'Need more torches'
- while not turtle.placeUp() do
- sleep(5)
- end
- end
- turtle.select(prev)
- torchCounter = torchCounter + 1
- end
- else
- if y%ySpacing == yStartRow[2] then
- local prev = turtle.getSelectedSlot()
- turtle.select(torches)
- if not turtle.placeUp() then
- print 'Need more torches'
- while not turtle.placeUp() do
- sleep(5)
- end
- end
- turtle.select(prev)
- torchCounter = torchCounter + 1
- end
- end
- end
- end
- turtle.select(3)
- for i = 1, width, 1 do
- local success, data = turtle.inspect()
- if success then
- if data.name ~= 'chisel:marble' then
- replace()
- end
- else
- replace()
- end
- for j = bottom + 1, top - 1, 1 do
- refuel()
- if i % 2 == 1 then
- while not turtle.up() do
- if turtle.detect() then
- turtle.digUp()
- elseif turtle.attack() then
- else
- sleep(1)
- end
- end
- else
- while not turtle.down() do
- if turtle.detect() then
- turtle.digDown()
- elseif turtle.attack() then
- else
- sleep(1)
- end
- end
- end
- local success, data = turtle.inspect()
- if success then
- if data.name ~= 'chisel:marble' then
- replace()
- end
- else
- replace()
- end
- checkForTorch(i,j)
- end
- torchCounter = 0
- returnToFloor()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement