Posted 24 October 2013 - 02:35 PM
What it does:
You give depth and width, and it will miner 3 high layer (above, same and below turtle lvl)
When the turtle is full, it checks if it has cobble and dirt, and tosses that away.
The remaining stuff he puts in an enderchest.
The bug:
When running this script, somehow the turtle gets confused in the cobble/dirt drop check.
I cant wrap my finger round it yet.
He forgets to place the chest, or he is confused and forgets to place it or something, but he starts to throw away all the good stuff too.
Can anyone help me out here, i just cant find what is wrong
EDIT:
pastebin here: http://pastebin.com/mv77D8N4
You give depth and width, and it will miner 3 high layer (above, same and below turtle lvl)
When the turtle is full, it checks if it has cobble and dirt, and tosses that away.
The remaining stuff he puts in an enderchest.
The bug:
When running this script, somehow the turtle gets confused in the cobble/dirt drop check.
I cant wrap my finger round it yet.
He forgets to place the chest, or he is confused and forgets to place it or something, but he starts to throw away all the good stuff too.
Can anyone help me out here, i just cant find what is wrong
Spoiler
-- made by 1869_Flame
local EnderchestSlot = 1
local ignoreCobbleSlot = 2
local ignoreDirtSlot = 3
local FuelSlot = 16
local function clear()
term.clear()
term.setCursorPos(1,1)
end
local function DigForward()
while turtle.detect() do
turtle.dig()
end
end
local function DigDown()
while turtle.detectDown() do
turtle.digDown()
end
end
local function DigUp()
while turtle.detectUp() do
turtle.digUp()
end
end
local function CobbleDirt()
DigDown()
for i=1, 16 do
turtle.select(i)
if i <= 3 or i == 16 then
-- we do nothing, as this is he ender and ignore slots
else
if turtle.compareTo(2) then
if i ~= FuelSlot and i ~= EnderchestSlot and i ~= ignoreCobbleSlot and i ~= ignoreDirtSlot then
turtle.dropDown()
end
end
if turtle.compareTo(3) then
if i ~= FuelSlot and i ~= EnderchestSlot and i ~= ignoreCobbleSlot and i ~= ignoreDirtSlot then
turtle.dropDown()
end
end
end
end
end
local function CheckEmptySlots()
for i=1, 16 do
if turtle.getItemCount(i) < 1 then
return true
else
end
end
CobbleDirt()
return false
end
local function storeStuff()
if not CheckEmptySlots() then
if EnderchestSlot >= 1 and EnderchestSlot <= 16 then
turtle.turnLeft()
turtle.turnLeft()
sleep(0.8)
for i = 1,5 do
DigForward()
end
turtle.select(EnderchestSlot)
turtle.place()
sleep(0.1)
for i = 1, 16 do
turtle.select(i)
if i ~= FuelSlot and i ~= EnderchestSlot and i ~= ignoreCobbleSlot and i ~= ignoreDirtSlot then
turtle.drop()
end
end
sleep(0.1)
turtle.select(EnderchestSlot)
turtle.dropDown()
sleep(0.1)
turtle.dig()
turtle.select(1)
turtle.turnLeft()
turtle.turnLeft()
end
end
end
local function CheckForRefuel()
if turtle.getFuelLevel() < 500 then
oldFuel = turtle.getFuelLevel()
turtle.select(FuelSlot)
turtle.refuel(1)
newFuel = turtle.getFuelLevel()
if oldFuel >= newFuel then
count = 1
turtle.select(count)
while not turtle.refuel() do
count = count + 1
turtle.select(count)
if count >= 16 then
count = 0
end
end
end
end
end
function slotsEmpty()
for i=1, 16 do
if turtle.getItemCount(i) < 1 then
return true
end
end
return false
end
local function clearDepthLine()
for i = 1, depth do
while not turtle.forward() do
DigForward()
DigUp()
DigDown()
end
storeStuff()
CheckForRefuel()
DigUp()
DigDown()
end
end
local function clearWidthLine()
for i = 1, width do
while not turtle.forward() do
DigForward()
DigUp()
DigDown()
storeStuff()
end
CheckForRefuel()
DigUp()
DigDown()
end
end
function Mine()
turns = 0
if depth >= width then
turns = width
end
if width >= depth then
turns = depth
end
clearDepthLine()
turtle.turnLeft()
clearWidthLine()
turtle.turnLeft()
clearDepthLine()
turtle.turnLeft()
while turns >=0 do
turns = turns -1
width = width - 1
clearWidthLine()
turtle.turnLeft()
depth = depth - 1
clearDepthLine()
turtle.turnLeft()
end
end
-- Start --
clear()
print("a Minerbot by 1869_Flame")
print("")
print("Please put an enderchest in slot 1")
print("Please put fuel in slot 16")
term.write("Insert depth: ")
depth = tonumber(read())
print(" ")
term.write("Insert width: ")
width = tonumber(read())
print(" ")
CheckForRefuel()
Mine()
print("im done!")
EDIT:
pastebin here: http://pastebin.com/mv77D8N4