Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ER library start
- -- Written by Erlend Ellingsen
- botName = 'min3rB0t'
- function printMsg(content)
- print('[' .. botName .. '] ' .. content)
- end
- function exit(msg)
- error(msg)
- return
- end
- -- turtle specific functions
- function moveDig(direction, times)
- for i = 1, times do
- if (direction == 'forward') then
- while(turtle.forward() ~= true) do
- while (turtle.detect()) do
- turtle.dig()
- end
- end
- elseif (direction == 'up') then
- while(turtle.up() ~= true) do
- while (turtle.detectUp()) do
- turtle.digUp()
- end
- end
- elseif (direction == 'down') then
- while(turtle.down() ~= true) do
- while (turtle.detectDown()) do
- turtle.digDown()
- end
- end
- end
- end
- end
- function rotate(direction, times)
- for i = 1, times do
- if (direction == 'left') then
- turtle.turnLeft()
- elseif (direction == 'right') then
- turtle.turnRight()
- end
- end
- end
- function selectSlot(slot)
- turtle_slot_current = slot
- turtle.select(slot)
- end
- function storage_disposeAllItems()
- --dispose all items
- for i = 1, 16 do
- selectSlot(i)
- turtle.drop()
- end
- end
- -- ER library end
- --Min3rb0t
- --vars
- torchEnabled = false
- torchAmount = 0
- turtle_slot_torch = 1
- --functions
- function placeTorch()
- if (torchEnabled == false) then
- return
- end
- if (torchAmount ~= turtle.getItemCount(turtle_slot_torch)) then
- printMsg('No more torches. Disabling.')
- printMsg('Expected amount: ' .. torchAmount .. ' actual amount: ' .. turtle.getItemCount(turtle_slot_torch))
- torchEnabled = false
- return
- end
- rotate('right', 2)
- while (turtle.detect()) do
- turtle.dig()
- end
- selectSlot(turtle_slot_torch)
- turtle.place()
- rotate('left', 2)
- torchAmount = torchAmount - 1
- end
- --INIT
- term.clear()
- printMsg('Welcome to Min3rb0t')
- printMsg('Coded by Erlend Ellingsen')
- printMsg('Length of single-tunnel?')
- tunnelLength = read()
- printMsg('Use torch-placement? (Slot 1)')
- torchPlacementAnswer = read()
- if (torchPlacementAnswer == 'yes') then
- torchEnabled = true
- torchAmount = turtle.getItemCount(turtle_slot_torch)
- elseif (torchPlacementAnswer == 'no') then
- torchEnabled = false
- torchAmount = 0
- end
- --Actual process
- torchPlacement = 0
- for i = 1, tunnelLength do
- torchPlacement = torchPlacement + 1
- printMsg('Processing ' .. i .. '/' .. tunnelLength)
- while (turtle.detect()) do
- turtle.dig()
- end
- if (torchPlacement >= 15) then
- if (torchEnabled) then
- if (torchAmount > 0) then
- currentTorchAmount = turtle.getItemCount(turtle_slot_torch)
- if (currentTorchAmount > 0) then
- placeTorch()
- end
- end
- end
- torchPlacement = 0
- end
- while (turtle.detectUp()) do
- turtle.digUp()
- end
- moveDig('forward', 1)
- end
Advertisement
Add Comment
Please, Sign In to add comment