code for my current set-up is here:
it probably not the best laid out but it works for me
Spoiler
function Start()
local Sleep = 0
local time = 0
local SWall = 1
local SFL = turtle.getFuelLevel()
local SCount= 0
local SCount2= 0
local SCount3= 0
local SWidth = 1
-- slot 16 mining well
-- slot 15 loot ender chest
-- slot 14 energy conduits
-- slot 13 fuel ender chest
-- slot 12 energy conduits for main power
print("")
print("How far should i go? Maximum of 63! default is 1!")
print("")
Size = tonumber(read())
if Size == nil then
Size = 1
end
while Size >= 64 do
print("Limit is 64")
Size = tonumber(read())
end
print("")
print("Wait time? Default is 0.1 seconds")
print("1 is 1 second, 2 is 2 seconds ETC")
print("")
time = tonumber(read())
if time == nil then
time = 0.1
end
print("")
print("Starting Left or Right?")
print("")
Direction = tostring(read())
while not ((Direction == "Right") or (Direction == "Left") or (Direction == "R") or (Direction == "L") or (Direction == "r") or (Direction == "l") or (Direction == "")) do
print("Choose Correct Direction Left or Right? Default is Right")
print("Right, R, r for Right")
print("or")
print("Left, L, l for Left")
Direction = read()
end
function Load()
local SStats = {Size = Size, time = time, SWidth = SWidth, SCount = SCount, Wait = Wait, Direction = Direction}
for key,value in pairs( SStats ) do
if tostring(key) == "Size" then
SWidth = tonumber(value)
SCount= tonumber(value)
time = tonumber(value)
elseif tostring(key) == "Direction" then
if tostring(value) == "Right" or tostring(value) == "R" or tostring(value) == "r" or tostring(value) == "" then
Direction = 1
elseif tostring(value) == "Left" or tostring(value) == "L" or tostring(value) == "l" then
Direction = 0
end
end
end
end
function Fuel()
if SFL < 500 then
turtle.select(13)
turtle.dig()
while not turtle.place() do
turtle.dig()
turtle.attack()
end
if turtle.suck() then
turtle.refuel(64)
turtle.dig()
SFL = turtle.getFuelLevel()
return true
else
turtle.select(13)
turtle.dig()
return false
end
else
return true
end
end
function County()
for i = 1, 8 do
SCount2 = SCount2+ turtle.getItemCount(i)
end
if SCount2 >= (SCount*4+2) then
SCount2 = 0
print("Enough Blocks in inventory to build walls")
print("")
return false
else
SCount2= 0
return true
end
end
function County2()
SCount3 = SCount3+ turtle.getItemCount(12)
if SCount3 >= (SCount) then
SCount3 = 0
print("Enough Redstone Energy Conduits to build power line")
print("")
return false
else
SCount3= 0
return true
end
end
Load()
print("")
print("I will dig for: "..SWidth .." Blocks")
print("")
if Fuel() then
print("Please place: " .. SCount*4+2 .. " amount of blocks into my inventory")
print("")
while County() do
sleep(1)
end
print("Please place: " .. SCount .. " amount of redstone energy conduits into my inventory slot 12")
print("")
while County2() do
sleep(1)
end
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
--bottom wall
for i = 1, 4 do
for i = 1, SWidth - 1 do
if Direction == 1 then
for i = 1, 8 do
if turtle.getItemCount(i) >= 1 then
turtle.select(i)
end
end
while not turtle.place() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
elseif Direction == 0 then
for i = 1, 8 do
if turtle.getItemCount(i) >= 1 then
turtle.select(i)
end
end
while not turtle.place() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
end
end
if SWall == 2 or SWall == 4 then
if Direction == 1 then
for i = 1, 8 do
if turtle.getItemCount(i) >= 1 then
turtle.select(i)
end
end
while not turtle.place() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
elseif Direction == 0 then
for i = 1, 8 do
if turtle.getItemCount(i) >= 1 then
turtle.select(i)
end
end
while not turtle.place() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
end
end
for i = 1, 8 do
if turtle.getItemCount(i) >= 1 then
turtle.select(i)
end
end
while not turtle.place() do
turtle.dig()
turtle.attack()
end
SWall = SWall + 1
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
end
SWall = 1
--top wall
turtle.up()
if Direction == 1 then
turtle.turnLeft()
elseif Direction == 0 then
turtle.turnRight()
end
for i = 1, SWidth-1 do
if Direction == 1 then
turtle.select(12)
while not turtle.place() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
elseif Direction == 0 then
turtle.select(12)
while not turtle.place() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
end
end
while not turtle.place() do
turtle.dig()
turtle.attack()
end
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
for i = 1, SWidth - 2 do
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
end
turtle.down()
local Move = {Size = Size, Direction = Direction, Sleep = time}
local NS = fs.open("NewStats","w")
NS.write(Move)
NS.close()
print("Add power at furthest conduit behind the turtle then press enter")
print("")
local Power = read()
local DigStats = {Finished = "No", Detail = "None", Sleep = time, Direction = Direction}
local DS = fs.open("DigStats","w")
DS.write(DigStats)
DS.close()
Main()
else
print("Couldn't get enough fuel! Restock the chest or refuel me and try again!")
end
end
function Main()
local time = 0
local MFL = turtle.getFuelLevel()
local Finished = "No"
local Detail = "None"
local Direction = 1
local GR = peripheral.wrap("right")
local WD = "No"
local Info = false
function Check()
GRI = GR.get()
for key, value in pairs ( GRI ) do
if tostring(key) == "Work Done" then
if tostring(value) == "true" then
return true
else
return false
end
end
end
end
if fs.exists("DigStats") then
local file = fs.open("DigStats","r")
local DigStatsInfo = file.readAll()
file.close()
Info = textutils.unserialize(DigStatsInfo)
end
function Load()
for key, value in pairs( Info ) do
if tostring(key) == "Finished" then
Finished = tostring(value)
elseif tostring(key) == "Detail" then
Detail = tostring(value)
elseif tostring(key) == "Direction" then
Direction = tonumber(value)
elseif tostring(key) == "Sleep" then
time = tonumber(value)
end
end
end
function Save()
local DigStats = {Finished = Finished, Detail = Detail, Direction = Direction, Sleep = time}
local SF = fs.open("DigStats","w")
SF.write(textutils.serialize(DigStats))
SF.close()
end
function Dig()
Detail = "Digging"
Save()
Done = "No"
while Done == "No" do
print("Working on next column")
if turtle.detect() == false then
turtle.select(16)
while not turtle.place() do
turtle.attack()
turtle.dig()
end
turtle.up()
turtle.select(15)
while not turtle.placeDown() do
turtle.attackDown()
turtle.digDown()
end
turtle.select(14)
while not turtle.place() do
turtle.attack()
turtle.dig()
end
print("Sleeping for: "..time)
sleep(time)
turtle.select(15)
turtle.digDown()
turtle.select(16)
turtle.down()
turtle.dig()
if Direction == 1 then
turtle.turnRight()
if turtle.detect() == true then
Done = "Yes"
turtle.turnLeft()
else
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
end
elseif Direction == 0 then
turtle.turnLeft()
if turtle.detect() == true then
Done = "Yes"
turtle.turnRight()
else
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
end
end
else
print("Sleeping for: "..time)
sleep(time)
turtle.select(15)
turtle.digDown()
turtle.select(16)
turtle.down()
turtle.dig()
if Direction == 1 then
turtle.turnRight()
if turtle.detect() == true then
Done = "Yes"
turtle.turnLeft()
else
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
end
elseif Direction == 0 then
turtle.turnLeft()
if turtle.detect() == true then
Done = "Yes"
turtle.turnRight()
else
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
end
end
end
end
Save()
end
function CPL()
Detail = "CPL"
print("Collecting Power Line")
turtle.select(14)
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.digUp()
if Direction == 1 then
turtle.turnLeft()
elseif Direction == 0 then
turtle.turnRight()
end
Save()
while turtle.detect() == false do
turtle.select(14)
turtle.digUp()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
end
turtle.select(14)
turtle.digUp()
if Direction == 1 then
turtle.turnRight()
turtle.back()
elseif Direction == 0 then
turtle.turnLeft()
turtle.back()
end
end
function Fuel()
if MFL < 500 then
turtle.select(13)
turtle.dig()
while not turtle.place() do
turtle.dig()
turtle.attack()
end
if turtle.suck() then
turtle.select(1)
turtle.refuel(64)
turtle.dig()
MFL = turtle.getFuelLevel()
return true
else
turtle.select(13)
turtle.dig()
return false
end
else
return true
end
end
function DigStart()
Load()
if Fuel() then
Dig()
CPL()
turtle.turnRight()
turtle.turnRight()
if turtle.detect() then
Finished = "Yes"
turtle.turnRight()
turtle.turnRight()
while not turtle.detect() do
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
end
turtle.turnRight()
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
turtle.turnRight()
Save()
--fs.delete("DigStats")
else
turtle.turnRight()
turtle.turnRight()
turtle.back()
end
end
end
if fs.exists("DigStats") == true then
Load()
if Finished == "Yes" then
else
if Detail == "CPL" then
while turtle.detect() == false do
turtle.select(14)
turtle.digUp()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
end
turtle.select(14)
turtle.digUp()
if Direction == 1 then
turtle.turnRight()
turtle.back()
elseif Direction == 0 then
turtle.turnLeft()
turtle.back()
end
elseif Detail == "None" then
turtle.forward()
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
turtle.select(14)
while turtle.detect() == false do
turtle.placeUp()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
end
turtle.placeUp()
turtle.turnRight()
turtle.turnRight()
while turtle.detect() == false do
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
end
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
turtle.turnRight()
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
turtle.turnRight()
elseif Detail == "Digging" then
if not turtle.detect() then
if Direction == 1 then
turtle.turnLeft()
elseif Direction == 0 then
turtle.turnRight()
end
if turtle.detect() then
while turtle.detect() do
turtle.up()
end
turtle.down()
turtle.down()
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
else
print("else")
turtle.forward()
turtle.up()
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
if turtle.detect() then
turtle.down()
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
turtle.forward()
if Direction == 1 then
turtle.turnLeft()
elseif Direction == 0 then
turtle.turnRight()
end
else
turtle.down()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
turtle.select(16)
while not turtle.place() do
turtle.attack()
turtle.dig()
end
turtle.up()
turtle.select(15)
while not turtle.placeDown() do
turtle.attackDown()
turtle.digDown()
end
turtle.select(14)
while not turtle.place() do
turtle.attack()
turtle.dig()
end
print("Sleeping for: "..time)
sleep(time)
turtle.select(15)
turtle.digDown()
turtle.select(16)
turtle.down()
turtle.dig()
if Direction == 1 then
turtle.turnRight()
if turtle.detect() == true then
Done = "Yes"
turtle.turnLeft()
else
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
end
elseif Direction == 0 then
turtle.turnLeft()
if turtle.detect() == true then
Done = "Yes"
turtle.turnRight()
else
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
end
end
end
end
end
end
while Finished == "No" do
DigStart()
end
fs.delete("DigStats")
print("If it is finished please press enter")
print("")
local Enter = read()
Remove()
end
end
function Remove()
local RWall = 1
local RFL = turtle.getFuelLevel()
local RWidth= 1
local file = fs.open("NewStats","r")
local NewStatsFile = file.readAll()
file.close()
NewStatsinfo = textutils.unserialize(NewStatsFile)
local Wall = 1
function Load()
for key,value in pairs( NewStatsinfo ) do
if tostring(key) == "Size" then
RWidth= tonumber(value)
elseif tostring(key) == "Direction" then
Direction = tonumber(value)
end
end
end
if fs.exists("NewStats") then
Load()
turtle.up()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.select(12)
if Direction == 1 then
turtle.turnLeft()
elseif Direction == 0 then
turtle.turnRight()
end
--top wall
for i = 1, RWidth- 1 do
turtle.dig()
if Direction == 0 then
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
turtle.dig()
elseif Direction == 1 then
turtle.turnLeft()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
turtle.dig()
end
end
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
for i = 1, RWidth - 1 do
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
end
turtle.down()
--bottom wall
for i = 1, 4 do
for i = 1, RWidth- 1 do
turtle.dig()
if Direction == 1 then
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
turtle.dig()
elseif Direction == 0 then
turtle.turnLeft()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
turtle.dig()
end
end
if Wall == 2 or Wall == 4 then
turtle.dig()
if Direction == 1 then
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnLeft()
turtle.dig()
elseif Direction == 0 then
turtle.turnLeft()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
turtle.dig()
end
end
Wall = Wall + 1
if Direction == 1 then
turtle.turnRight()
elseif Direction == 0 then
turtle.turnLeft()
end
end
Wall = 1
turtle.turnRight()
turtle.turnRight()
while not turtle.forward() do
turtle.dig()
turtle.attack()
end
turtle.turnRight()
turtle.turnRight()
turtle.select(1)
fs.delete("NewStats")
end
end
if fs.exists("DigStats") then
print("Starting Main Section")
Main()
elseif fs.exists("NewStats") then
print("Removing Walls")
Remove()
else
print("Starting")
Start()
end
Rather than having the script sleep for a period of time (defined when you start the program above) i want it to read the system (wait for something to tell it) that the mining well is finished, so it can move onto the next position to place the mining well down, have tried lots of different possible ways and have yet to come up with a solution, any tips/things to try?