Skip to content

Instantly share code, notes, and snippets.

@duff
Last active December 12, 2015 08:09
Show Gist options
  • Save duff/4742284 to your computer and use it in GitHub Desktop.
Save duff/4742284 to your computer and use it in GitHub Desktop.
Minecraft turtle ops
term.clear()
term.setCursorPos(1, 1)
print("Enter floor length: ")
floor_length = read()
print("Enter floor width (even #): ")
floor_width = read()
fueltype = "1"
function fueltypeset()
if fueltype == "1" then
fueltype = 80
elseif fueltype == "2" then
fueltype = 160
elseif fueltype == "3" then
fueltype = 520
elseif fueltype == "4" then
fueltype = 1520
end
end
fueltypeset()
term.clear()
term.setCursorPos(1, 1)
term.clear()
term.setCursorPos(1, 1)
print("")
print("Place Fuel in Slot 1")
print("Place Flooring in the remaining slots")
print("")
print("Begin flooring?")
print("0=Cancel Program, Any Key=Yes")
beginmine = read()
if beginmine == "0" then
os.reboot()
end
term.clear()
term.setCursorPos(1,1)
print("Flooring " .. floor_length .. " blocks, then returning.")
sleep(2)
torchpos = 0
function progress()
term.setCursorPos(1,3)
print("Progress: " .. torchpos .. " of " .. floor_length)
end
function fuelcheck()
if turtle.getFuelLevel() ~= "unlimited" then
if turtle.getFuelLevel()/fueltype < 0.26 then
turtle.select(1)
turtle.refuel(1)
end
end
end
function place_block()
for d = current_slot, 16 do
turtle.select(d)
if turtle.placeDown() then
current_slot = d
return
end
end
end
function two_rows()
for d = 1, floor_length do
turtle.forward()
place_block()
fuelcheck()
end
turtle.turnRight()
turtle.forward()
place_block()
turtle.turnRight()
for d = 1, floor_length - 1 do
turtle.forward()
place_block()
fuelcheck()
end
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
current_slot = 2
fuelcheck()
for d = 1, floor_width / 2 do
two_rows()
end
print("Flooring Successful")
# One time install
# Use a new number for each turtle
label set gavin_#
pastebin get P4F1bD9i boot
boot
gfs install 4742284 t
# Whenever you want to use it
gfs go t
term.clear()
term.setCursorPos(1, 1)
repeat
-- print("Enter tunnel length (even digit): ")
-- tunnellength = read()
tunnellength = 100
until tunnellength % 2 == 0
-- term.clear()
-- term.setCursorPos(1, 1)
-- print("Enter number for fuel type: ")
-- print("")
-- print("No Fuel Required = 0")
-- print("Coal/Charcoal/Peat = 1")
-- print("Coal Coke = 2")
-- print("Biofuel Can = 3 **")
-- print("Coalfuel Can = 4 **")
-- print("** Ensure these work in your version")
-- fueltype = read()
fueltype = "1"
function fueltypeset()
if fueltype == "1" then
fueltype = 80
elseif fueltype == "2" then
fueltype = 160
elseif fueltype == "3" then
fueltype = 520
elseif fueltype == "4" then
fueltype = 1520
end
end
fueltypeset()
term.clear()
term.setCursorPos(1, 1)
-- print("Drop mined cobblestone? 0=No, 1=Yes")
-- cobblesetting = read()
cobblesetting = "1"
-- term.clear()
-- term.setCursorPos(1, 1)
-- if cobblesetting == "1" then
-- if turtle.getItemCount(2) < 1 then
-- print("Place 1 cobblestone in Slot 2")
-- print("")
-- end
-- end
-- print("Place torches? 0=No, 1=Yes")
-- print("Place torches in Slot 3")
-- torchsetting = read()
torchsetting = "1"
term.clear()
term.setCursorPos(1, 1)
if torchsetting == "1" then
if turtle.getItemCount(3) < tunnellength/4 then
print("Warning: You will not have enough torches for entire tunnel length.")
print("")
print("")
end
end
-- print("Return and deposit items to chest if inventory nears full?")
-- print("0=No, 1=Yes")
-- returnsetting = read()
returnsetting = "1"
term.clear()
term.setCursorPos(1, 1)
-- if returnsetting == "1" then
-- print("Place chest immediately behind turtle.")
-- print("")
-- end
-- print("Deposit inventory into chest upon completion?")
-- print("0=No, 1=Yes")
-- dcomplete = read()
dcomplete = "1"
-- term.clear()
-- term.setCursorPos(1, 1)
-- if dcomplete == "1" then
-- print("Place chest immediately behind turtle.")
-- print("")
-- end
-- print("Terminate program once length is reached?")
-- print("Note: This will prevent the turtle from depositing items into a chest upon completion.")
-- print("0=No, 1=Yes")
-- tcomplete = read()
tcomplete = "0"
-- term.clear()
-- term.setCursorPos(1, 1)
-- if tcomplete == "1" then
-- if dcomplete == "1" then
-- print("Turtle will NOT deposit items upon completion.")
-- print("")
-- end
-- end
print("")
print("Place Fuel in Slot 1")
print("Place 1 Cobble in Slot 2")
print("Place Torches in Slot 3")
print("Place chest immediately behind turtle.")
print("")
print("Begin mining?")
print("0=Cancel Program, Any Key=Yes")
beginmine = read()
if beginmine == "0" then
os.reboot()
end
term.clear()
term.setCursorPos(1,1)
if tcomplete == "1" then
print("Tunneling " .. tunnellength .. " blocks, then terminating.")
elseif tcomplete == "0" then
print("Tunneling " .. tunnellength .. " blocks, then returning.")
end
sleep(2)
torchpos = 0
function progress()
term.setCursorPos(1,3)
print("Progress: " .. torchpos .. " of " .. tunnellength)
end
function fuelcheck()
if turtle.getFuelLevel() ~= "unlimited" then
if turtle.getFuelLevel()/fueltype < 0.26 then
turtle.select(1)
turtle.refuel(1)
end
end
end
function dropcobble()
local stackSize = turtle.getItemCount(2)
if cobblesetting == "1" then
if turtle.getFuelLevel() ~= "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
elseif turtle.getFuelLevel() == "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
turtle.select(1)
if turtle.compareTo(2) then
turtle.drop()
end
end
end
end
function minewallRight()
fuelcheck()
turtle.select(1)
turtle.dig()
moveforward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
turtle.turnLeft()
torchpos = torchpos + 1
progress()
end
function minewallLeft()
fuelcheck()
turtle.select(1)
turtle.dig()
moveforward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
turtle.turnRight()
torchpos = torchpos + 1
progress()
end
function minecycle()
for z = 1, tunnellength/2 do
minewallRight()
dropcobble()
minewallLeft()
placetorch()
end
end
function placetorch()
if torchsetting == "1" then
if torchpos % 4 == 0 then
turtle.turnLeft()
turtle.dig()
turtle.select(3)
turtle.place()
turtle.turnRight()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
else
if torchpos % 4 == 0 then
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
end
function moveforward()
while not turtle.forward() do
sleep(0.25)
turtle.dig()
end
end
function turtlehome()
for y = 1, tunnellength do
fuelcheck()
moveforward()
end
end
function fullinventory()
local invcount = 0
if returnsetting == "1" then
for c = 4, 16 do
if turtle.getItemCount(c) > 0 then
invcount = invcount+1
end
end
if invcount > 12 then
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
for d = 4, 16 do
turtle.select(d)
turtle.dropDown()
end
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
invcount = 0
else
invcount = 0
end
end
end
function depositcomplete()
if dcomplete == "1" then
for d = 1, 16 do
turtle.select(d)
turtle.drop()
end
end
end
function terminatecomplete()
if tcomplete =="1" then
turtle.down()
os.reboot()
sleep(3)
end
end
fuelcheck()
turtle.digUp()
turtle.up()
minecycle()
terminatecomplete()
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
turtlehome()
turtle.down()
depositcomplete()
turtle.turnRight()
turtle.turnRight()
term.setCursorPos(1,5)
print("Mining Successful")
term.setCursorPos(1,7)
term.clear()
term.setCursorPos(1, 1)
tunnellength = 50
tunnelwidth = 9
fueltype = "1"
function fueltypeset()
if fueltype == "1" then
fueltype = 80
elseif fueltype == "2" then
fueltype = 160
elseif fueltype == "3" then
fueltype = 520
elseif fueltype == "4" then
fueltype = 1520
end
end
fueltypeset()
term.clear()
term.setCursorPos(1, 1)
term.clear()
term.setCursorPos(1, 1)
if turtle.getItemCount(3) < ((tunnellength/4) * 2) then
print("Warning: You will not have enough torches for entire tunnel length.")
print("")
print("")
end
tcomplete = "0"
print("")
print("Place Fuel in Slot 1")
print("Place 1 Cobble in Slot 2")
print("Place Torches in Slot 3")
print("Place chest immediately behind turtle.")
print("")
print("Begin mining?")
print("0=Cancel Program, Any Key=Yes")
beginmine = read()
if beginmine == "0" then
os.reboot()
end
term.clear()
term.setCursorPos(1,1)
print("Tunneling " .. tunnellength .. " blocks, then returning.")
sleep(2)
torchpos = 0
function progress()
term.setCursorPos(1,3)
print("Progress: " .. torchpos .. " of " .. tunnellength)
end
function fuelcheck()
if turtle.getFuelLevel() ~= "unlimited" then
if turtle.getFuelLevel()/fueltype < 0.26 then
turtle.select(1)
turtle.refuel(1)
end
end
end
function dropcobble()
local stackSize = turtle.getItemCount(2)
if turtle.getFuelLevel() ~= "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
elseif turtle.getFuelLevel() == "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
turtle.select(1)
if turtle.compareTo(2) then
turtle.drop()
end
end
end
function digForward()
moveforward()
turtle.digUp()
turtle.digDown()
end
function minewallRight()
fuelcheck()
turtle.select(1)
turtle.dig()
digForward()
turtle.turnRight()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnLeft()
torchpos = torchpos + 1
placeTorchRight()
progress()
end
function minewallLeft()
fuelcheck()
turtle.select(1)
turtle.dig()
digForward()
turtle.turnLeft()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnRight()
torchpos = torchpos + 1
placeTorchLeft()
progress()
end
function minecycle()
for z = 1, tunnellength/2 do
minewallRight()
dropcobble()
minewallLeft()
end
end
function placeTorchLeft()
if torchpos % 4 == 0 then
turtle.turnLeft()
turtle.dig()
turtle.select(3)
turtle.place()
turtle.turnRight()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
function placeTorchRight()
if torchpos % 4 == 1 then
turtle.turnRight()
turtle.dig()
turtle.select(3)
turtle.place()
turtle.turnLeft()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
function moveforward()
while not turtle.forward() do
sleep(0.25)
turtle.dig()
end
end
function digInitialRightSection()
turtle.turnRight()
turtle.select(1)
turtle.dig()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnRight()
turtle.turnRight()
dropcobble()
fuelcheck()
for y = 0, (tunnelwidth - 2) do
moveforward()
end
turtle.turnRight()
fuelcheck()
end
function turtlehome()
for y = 1, tunnellength do
fuelcheck()
moveforward()
end
end
function fullinventory()
local invcount = 0
for c = 4, 16 do
if turtle.getItemCount(c) > 0 then
invcount = invcount+1
end
end
if invcount > 12 then
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
for d = 4, 16 do
turtle.select(d)
turtle.dropDown()
end
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
invcount = 0
else
invcount = 0
end
end
function depositcomplete()
for d = 1, 16 do
turtle.select(d)
turtle.drop()
end
end
function terminatecomplete()
if tcomplete =="1" then
turtle.down()
os.reboot()
sleep(3)
end
end
fuelcheck()
turtle.digUp()
turtle.up()
digInitialRightSection()
dropcobble()
minecycle()
terminatecomplete()
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
turtlehome()
turtle.down()
depositcomplete()
turtle.turnRight()
turtle.turnRight()
term.setCursorPos(1,5)
print("Mining Successful")
term.setCursorPos(1,7)
term.clear()
term.setCursorPos(1, 1)
tunnellength = 20
tunnelwidth = 15
fueltype = "1"
function fueltypeset()
if fueltype == "1" then
fueltype = 80
elseif fueltype == "2" then
fueltype = 160
elseif fueltype == "3" then
fueltype = 520
elseif fueltype == "4" then
fueltype = 1520
end
end
fueltypeset()
term.clear()
term.setCursorPos(1, 1)
term.clear()
term.setCursorPos(1, 1)
if turtle.getItemCount(3) < ((tunnellength/4) * 2) then
print("Warning: You will not have enough torches for entire tunnel length.")
print("")
print("")
end
print("")
print("Place Fuel in Slot 1")
print("Place 1 Cobble in Slot 2")
print("Place Torches in Slot 3")
print("Place chest immediately behind turtle.")
print("")
print("Begin mining?")
print("0=Cancel Program, Any Key=Yes")
beginmine = read()
if beginmine == "0" then
os.reboot()
end
term.clear()
term.setCursorPos(1,1)
print("Tunneling " .. tunnellength .. " blocks, then returning.")
sleep(2)
torchpos = 0
function progress()
term.setCursorPos(1,3)
print("Progress: " .. torchpos .. " of " .. tunnellength)
end
function fuelcheck()
if turtle.getFuelLevel() ~= "unlimited" then
if turtle.getFuelLevel()/fueltype < 0.26 then
turtle.select(1)
turtle.refuel(1)
end
end
end
function dropcobble()
local stackSize = turtle.getItemCount(2)
if turtle.getFuelLevel() ~= "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
elseif turtle.getFuelLevel() == "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
turtle.select(1)
if turtle.compareTo(2) then
turtle.drop()
end
end
end
function minewallRight()
fuelcheck()
turtle.select(1)
turtle.dig()
digForward()
turtle.turnRight()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnLeft()
torchpos = torchpos + 1
placeTorchRight()
progress()
end
function minewallLeft()
fuelcheck()
turtle.select(1)
turtle.dig()
digForward()
turtle.turnLeft()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnRight()
torchpos = torchpos + 1
placeTorchLeft()
progress()
end
function minecycle()
for z = 1, tunnellength/2 do
minewallRight()
dropcobble()
minewallLeft()
dropcobble()
end
end
function digForward()
moveforward()
turtle.digUp()
turtle.digDown()
end
function moveforward()
while not turtle.forward() do
sleep(0.35)
turtle.dig()
end
end
function digInitialRightSection()
turtle.turnRight()
turtle.select(1)
turtle.dig()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnRight()
turtle.turnRight()
dropcobble()
fuelcheck()
for y = 0, (tunnelwidth - 2) do
moveforward()
end
turtle.turnRight()
fuelcheck()
end
function placeTorchLeft()
if torchpos % 4 == 0 then
turtle.turnLeft()
turtle.dig()
turtle.select(3)
-- turtle.place()
turtle.turnRight()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
function placeTorchRight()
if torchpos % 4 == 1 then
turtle.turnRight()
turtle.dig()
turtle.select(3)
-- turtle.place()
turtle.turnLeft()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
function turtlehome()
for y = 1, tunnellength do
fuelcheck()
moveforward()
end
end
function fullinventory()
local invcount = 0
for c = 4, 16 do
if turtle.getItemCount(c) > 0 then
invcount = invcount+1
end
end
if invcount > 12 then
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
for d = 4, 16 do
turtle.select(d)
turtle.dropDown()
end
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
invcount = 0
else
invcount = 0
end
end
function depositcomplete()
for d = 1, 16 do
turtle.select(d)
turtle.drop()
end
end
fuelcheck()
turtle.digUp()
turtle.up()
digInitialRightSection()
dropcobble()
minecycle()
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
turtlehome()
turtle.down()
depositcomplete()
turtle.turnRight()
turtle.turnRight()
term.setCursorPos(1,5)
print("Mining Successful")
term.setCursorPos(1,7)
term.clear()
term.setCursorPos(1, 1)
tunnellength = 50
tunnelwidth = 15
fueltype = "1"
function fueltypeset()
if fueltype == "1" then
fueltype = 80
elseif fueltype == "2" then
fueltype = 160
elseif fueltype == "3" then
fueltype = 520
elseif fueltype == "4" then
fueltype = 1520
end
end
fueltypeset()
term.clear()
term.setCursorPos(1, 1)
term.clear()
term.setCursorPos(1, 1)
if turtle.getItemCount(3) < ((tunnellength/4) * 2) then
print("Warning: You will not have enough torches for entire tunnel length.")
print("")
print("")
end
print("")
print("Place Fuel in Slot 1")
print("Place 1 Sand/Cobble in Slot 2")
print("Place 1 Sand/Cobble in Slot 3")
print("Place chest immediately behind turtle.")
print("")
print("Begin mining?")
print("0=Cancel Program, Any Key=Yes")
beginmine = read()
if beginmine == "0" then
os.reboot()
end
term.clear()
term.setCursorPos(1,1)
print("Tunneling " .. tunnellength .. " blocks, then returning.")
sleep(2)
torchpos = 0
function progress()
term.setCursorPos(1,3)
print("Progress: " .. torchpos .. " of " .. tunnellength)
end
function fuelcheck()
if turtle.getFuelLevel() ~= "unlimited" then
if turtle.getFuelLevel()/fueltype < 0.26 then
turtle.select(1)
turtle.refuel(1)
end
end
end
function dropslot(slot)
local stackSize = turtle.getItemCount(slot)
if turtle.getFuelLevel() ~= "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(slot)
turtle.drop(stackSize)
end
elseif turtle.getFuelLevel() == "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(slot)
turtle.drop(stackSize)
end
turtle.select(1)
if turtle.compareTo(slot) then
turtle.drop()
end
end
end
function dropcobble()
dropslot(2)
dropslot(3)
end
function minewallRight()
fuelcheck()
turtle.select(1)
turtle.dig()
digForward()
turtle.turnRight()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnLeft()
torchpos = torchpos + 1
placeTorchRight()
progress()
end
function minewallLeft()
fuelcheck()
turtle.select(1)
turtle.dig()
digForward()
turtle.turnLeft()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnRight()
torchpos = torchpos + 1
placeTorchLeft()
progress()
end
function minecycle()
for z = 1, tunnellength/2 do
minewallRight()
dropcobble()
minewallLeft()
dropcobble()
end
end
function digForward()
moveforward()
turtle.digUp()
turtle.digDown()
end
function moveforward()
while not turtle.forward() do
sleep(0.35)
turtle.dig()
end
end
function digInitialRightSection()
turtle.turnRight()
turtle.select(1)
turtle.dig()
for z = 0, (tunnelwidth - 2) do
digForward()
end
turtle.turnRight()
turtle.turnRight()
dropcobble()
fuelcheck()
for y = 0, (tunnelwidth - 2) do
moveforward()
end
turtle.turnRight()
fuelcheck()
end
function placeTorchLeft()
if torchpos % 4 == 0 then
turtle.turnLeft()
turtle.dig()
turtle.select(3)
-- turtle.place()
turtle.turnRight()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
function placeTorchRight()
if torchpos % 4 == 1 then
turtle.turnRight()
turtle.dig()
turtle.select(3)
-- turtle.place()
turtle.turnLeft()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
function turtlehome()
for y = 1, tunnellength do
fuelcheck()
moveforward()
end
end
function fullinventory()
local invcount = 0
for c = 4, 16 do
if turtle.getItemCount(c) > 0 then
invcount = invcount+1
end
end
if invcount > 12 then
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
for d = 4, 16 do
turtle.select(d)
turtle.dropDown()
end
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
invcount = 0
else
invcount = 0
end
end
function depositcomplete()
for d = 1, 16 do
turtle.select(d)
turtle.drop()
end
end
fuelcheck()
turtle.digUp()
turtle.up()
digInitialRightSection()
dropcobble()
minecycle()
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
turtlehome()
turtle.down()
depositcomplete()
turtle.turnRight()
turtle.turnRight()
term.setCursorPos(1,5)
print("Mining Successful")
term.setCursorPos(1,7)
term.clear()
term.setCursorPos(1, 1)
print("Place Fuel in Slot 1")
print("Place 1 Cobble in Slot 2")
print("Place Torches in Slot 3")
print("Place chest immediately behind turtle.")
repeat
print("Enter tunnel length (even digit): ")
tunnellength = read()
until tunnellength % 2 == 0
term.clear()
term.setCursorPos(1, 1)
-- print("Enter number for fuel type: ")
-- print("")
-- print("No Fuel Required = 0")
-- print("Coal/Charcoal/Peat = 1")
-- print("Coal Coke = 2")
-- print("Biofuel Can = 3 **")
-- print("Coalfuel Can = 4 **")
-- print("** Ensure these work in your version")
-- fueltype = read()
fueltype = "1"
function fueltypeset()
if fueltype == "1" then
fueltype = 80
elseif fueltype == "2" then
fueltype = 160
elseif fueltype == "3" then
fueltype = 520
elseif fueltype == "4" then
fueltype = 1520
end
end
fueltypeset()
term.clear()
term.setCursorPos(1, 1)
-- print("Drop mined cobblestone? 0=No, 1=Yes")
-- cobblesetting = read()
cobblesetting = "1"
-- term.clear()
-- term.setCursorPos(1, 1)
-- if cobblesetting == "1" then
-- if turtle.getItemCount(2) < 1 then
-- print("Place 1 cobblestone in Slot 2")
-- print("")
-- end
-- end
-- print("Place torches? 0=No, 1=Yes")
-- print("Place torches in Slot 3")
-- torchsetting = read()
torchsetting = "1"
term.clear()
term.setCursorPos(1, 1)
if torchsetting == "1" then
if turtle.getItemCount(3) < tunnellength/4 then
print("Warning: You will not have enough torches for entire tunnel length.")
print("")
print("")
end
end
-- print("Return and deposit items to chest if inventory nears full?")
-- print("0=No, 1=Yes")
-- returnsetting = read()
returnsetting = "1"
term.clear()
term.setCursorPos(1, 1)
-- if returnsetting == "1" then
-- print("Place chest immediately behind turtle.")
-- print("")
-- end
-- print("Deposit inventory into chest upon completion?")
-- print("0=No, 1=Yes")
-- dcomplete = read()
dcomplete = "1"
-- term.clear()
-- term.setCursorPos(1, 1)
-- if dcomplete == "1" then
-- print("Place chest immediately behind turtle.")
-- print("")
-- end
-- print("Terminate program once length is reached?")
-- print("Note: This will prevent the turtle from depositing items into a chest upon completion.")
-- print("0=No, 1=Yes")
-- tcomplete = read()
tcomplete = "0"
-- term.clear()
-- term.setCursorPos(1, 1)
-- if tcomplete == "1" then
-- if dcomplete == "1" then
-- print("Turtle will NOT deposit items upon completion.")
-- print("")
-- end
-- end
print("")
print("Begin mining?")
print("0=Cancel Program, Any Key=Yes")
beginmine = read()
if beginmine == "0" then
os.reboot()
end
term.clear()
term.setCursorPos(1,1)
if tcomplete == "1" then
print("Tunneling " .. tunnellength .. " blocks, then terminating.")
elseif tcomplete == "0" then
print("Tunneling " .. tunnellength .. " blocks, then returning.")
end
sleep(2)
torchpos = 0
function progress()
term.setCursorPos(1,3)
print("Progress: " .. torchpos .. " of " .. tunnellength)
end
function fuelcheck()
if turtle.getFuelLevel() ~= "unlimited" then
if turtle.getFuelLevel()/fueltype < 0.26 then
turtle.select(1)
turtle.refuel(1)
end
end
end
function dropcobble()
local stackSize = turtle.getItemCount(2)
if cobblesetting == "1" then
if turtle.getFuelLevel() ~= "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
elseif turtle.getFuelLevel() == "unlimited" then
if stackSize > 2 then
stackSize = stackSize-1
turtle.select(2)
turtle.drop(stackSize)
end
turtle.select(1)
if turtle.compareTo(2) then
turtle.drop()
end
end
end
end
function minewallRight()
fuelcheck()
turtle.select(1)
turtle.dig()
moveforward()
turtle.digUp()
turtle.digDown()
turtle.turnRight()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
turtle.turnLeft()
torchpos = torchpos + 1
progress()
end
function minewallLeft()
fuelcheck()
turtle.select(1)
turtle.dig()
moveforward()
turtle.digUp()
turtle.digDown()
turtle.turnLeft()
moveforward()
turtle.digDown()
turtle.digUp()
moveforward()
turtle.digDown()
turtle.digUp()
turtle.turnRight()
torchpos = torchpos + 1
progress()
end
function minecycle()
for z = 1, tunnellength/2 do
minewallRight()
minewallLeft()
placetorch()
end
end
function placetorch()
if torchsetting == "1" then
if torchpos % 4 == 0 then
turtle.turnLeft()
turtle.dig()
turtle.select(3)
turtle.place()
turtle.turnRight()
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
else
if torchpos % 4 == 0 then
dropcobble()
fuelcheck()
fullinventory()
turtle.select(1)
end
end
end
function moveforward()
while not turtle.forward() do
sleep(0.25)
turtle.dig()
end
end
function turtlehome()
for y = 1, tunnellength do
fuelcheck()
moveforward()
end
end
function fullinventory()
local invcount = 0
if returnsetting == "1" then
for c = 4, 16 do
if turtle.getItemCount(c) > 0 then
invcount = invcount+1
end
end
if invcount > 12 then
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
for d = 4, 16 do
turtle.select(d)
turtle.dropDown()
end
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
for f = 1, torchpos+1 do
moveforward()
fuelcheck()
end
invcount = 0
else
invcount = 0
end
end
end
function depositcomplete()
if dcomplete == "1" then
for d = 1, 16 do
turtle.select(d)
turtle.drop()
end
end
end
function terminatecomplete()
if tcomplete =="1" then
turtle.down()
os.reboot()
sleep(3)
end
end
fuelcheck()
turtle.digUp()
turtle.up()
minecycle()
terminatecomplete()
turtle.turnLeft()
turtle.turnLeft()
fuelcheck()
turtlehome()
turtle.down()
depositcomplete()
turtle.turnRight()
turtle.turnRight()
term.setCursorPos(1,5)
print("Mining Successful")
term.setCursorPos(1,7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment