Yet another mining turtle...
Description
Simplest miner v0.2
Installation
Copy one of these commands into your ComputerCraft terminal:
Pastebin:
pastebin get C93d6FX6 yet_another_mining_turtle...wget:
wget https://pastebin.com/raw/C93d6FX6 yet_another_mining_turtle...Archive:
wget https://cc.shobie.xyz/cc/get/pb-C93d6FX6 yet_another_mining_turtle...
Quick Install:
wget https://cc.shobie.xyz/cc/get/pb-C93d6FX6 Yet another mining turtle...
Usage
Run the program after downloading
Tags
Source
View Original SourceCode Preview
--Simplest miner v0.2
--17 Nov 27
-- pastebin get C93d6FX6 cm
-- delete cm
--************
--
--This mining program is filled with
--assumptions, generalizations, and
--bugs. I will update/maintain when
--possible. Feel free to suggest changes
--
--Written by : Keystyles
--************
--************
--Constants/Initialization
--************
----Orientation (start location = 0,0,0)
local currX = 0
local currY = 0
local currZ = 0
local width = 15
--***********
--Functions
--***********
function checkJunk(name) --check the data from the inspect and return true if it's junk; add "--" before both lines to remove an entry
if name == "minecraft:stone" then
return false
elseif name == "minecraft:cobblestone" then
return false
elseif name == "minecraft:gravel" then
return false
elseif name == "minecraft:dirt" then
return false
elseif name == "minecraft:water" then
return false
elseif name == "minecraft:red_mushroom" then
return false
--elseif name == "minecraft:redstone_ore" then
-- return false
--elseif name == "minecraft:coal_ore" then
-- return false
elseif name == "ProjRed:Exploration:projectred.exploration.stone" then --Marble, need to find correct name*
return false
elseif name == "minecraft:sand" then
return false
elseif name == "minecraft:netherrack" then
return false
elseif name == "Botania:stone" then --this is all Botania stones; diorite, granite, etc
return false
elseif name == "Botania:mushroom" then --this is all Botania stones; diorite, granite, etc
return false
elseif name == "chisel:limestone" then
return false
elseif name == "chisel:andesite" then
return false
elseif name == "chisel:diorite" then
return false
elseif name == "chisel:granite" then
return false
elseif name == "chisel:marble" then
return false
elseif name == "BiomesOPlenty:flowers" then
return false
elseif name == "BiomesOPlenty:flowers2" then
return false
else
return true
end
end
function turtleUp()
x = turtle.up()
while x == false do
if turtle.digUp() then
x = turtle.up()
else
if turtle.inspectUp() then
if turtle.digUp() then
x=turtle.up()
else
return false
end
else
turtle.attackUp()
x = turtle.up()
end
end
end
return true
end
function turtleDown()
x = turtle.down()
while x == false do
if turtle.digDown() then
x = turtle.down()
else
if turtle.inspectDown() then
if turtle.digDown() then
x=turtle.down()
else
return false
end
else
turtle.attackDown()
x = turtle.down()
end
end
end
return true
end
function turtleForward()
x = turtle.forward()
while x == false do
if turtle.dig() then
x = turtle.forward()
else
if turtle.inspect() then
if turtle.dig() then
x=turtle.forward()
else
return false
end
else
turtle.attack()
x = turtle.forward()
end
end
end
return true
end
function check()
--Check down first, dig if necessary
local success, data = turtle.inspectDown()
if success then
if checkJunk(data.name) then
if data.name == "minecraft:flowing_lava" then
turtle.select(1)
turtle.placeDown()
turtle.refuel()
else
turtle.digDown()
end
end
end
--Check up second, ...
local success, data = turtle.inspectUp()
if success then
if checkJunk(data.name) then
if data.name == "minecraft:flowing_lava" then
turtle.select(1)
turtle.placeUp()
turtle.refuel()
else
turtle.digUp()
end
end
end
end
function inventoryClear()
for i=1, 16 do
turtle.select(i)
local data = turtle.getItemDetail()
if data then
if checkJunk(data.name) == false then
turtle.drop()
end
end
end
turtle.select(1)
end
function inventoryFull()
local count = 0
for i = 1,16 do
if turtle.getItemCount(i) > 0 then
count = count + 1
end
end
if count > 10 then
return true
else
return false
end
end
function inventoryUnload()
for i = 2, 16 do
turtle.select(i)
turtle.dropUp()
end
end
--************
--Main Loop
--************
----Fuel
turtle.select(1)
turtle.refuel()
turtle.select(2)
turtle.refuel()
print(turtle.getFuelLevel())
----Descend to bottom (bedrock +5)
while turtleDown() do
currY = currY - 1
end
print(currY)
--Move up to avoid non-flat bedrock
--for i = 1, 4 do
-- turtleUp()
-- currY = currY + 1
--end
--Mining Loop
inventoryClear()
while currY < -2 do --While you are in an acceptable mining range
for i = 1, width do --Mine one leg
turtleForward()
check()
end
inventoryClear()
turtle.turnRight() --Move right one
turtleForward()
currX = currX + 1
check()
turtle.turnRight()
for i = 1, width do --Mine return leg
turtleForward()
check()
end
if currX < width then --Move left one, or return to 0,0 if complete
inventoryClear()
turtle.turnLeft()
turtleForward()
currX = currX + 1
check()
turtle.turnLeft()
else
turtle.turnRight()
repeat
turtleForward()
currX = currX - 1
until currX == 0
turtle.turnRight()
for i = 1, 3 do --Move up three levels
turtleUp()
currY = currY + 1
end
inventoryClear() --Dump junk
if inventoryFull() then --Return to starting level and empty cargo is necessary
y = currY
print(y)
print(turtle.getFuelLevel())
while currY < 0 do
turtleUp()
currY = currY + 1
end
inventoryUnload()
while currY > y do
turtleDown()
currY = currY - 1
end
end
end
end
inventoryClear() --Dump junk
while currY < 0 do
turtleUp()
currY = currY + 1
end
inventoryUnload()
--************
--Rev history
--************
-- v0.1 - initial posting
-- v0.2 - fixed MANY issues, added inital fueling from slot2, increased inventoryClear frequency, added junk items, etc, etc, etc,