This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Artistboy360's profile picture

Mining, item retrieval, and mineral sorting system.

Started by Artistboy360, 07 October 2012 - 12:45 AM
Artistboy360 #1
Posted 07 October 2012 - 02:45 AM
This little system I've made allows for a set of 9 turtles to mine using an extremely simple digging program. They can dig from surface to bedrock in under an hour, and at 20 layer checkpoints, they place their inventory into chests so they won't run out of space. A retriever bot can be sent out to move the chests to the surface, along with their inventories, so you can reach them. After all the chests have been moved, you can take whatever resources you want out of them, move the items to a sorting chamber, and let the turtle in the room sort them for you.



http://www.mediafire...5mrk56mm6hck5cw <Download for all the files that the sorting turtle uses.

Digging program:
Spoilerfunction chest()

turtle.select(1) turtle.placeUp()
turtle.select(2) turtle.dropUp()
turtle.select(3) turtle.dropUp()
turtle.select(4) turtle.dropUp()
turtle.select(5) turtle.dropUp()
turtle.select(6) turtle.dropUp()
turtle.select(7) turtle.dropUp()
turtle.select(8) turtle.dropUp()
turtle.select(9) turtle.dropUp()
turtle.select(10) turtle.dropUp()
turtle.select(11) turtle.dropUp()
turtle.select(12) turtle.dropUp()
turtle.select(13) turtle.dropUp()
turtle.select(14) turtle.dropUp()
turtle.select(15) turtle.dropUp()
turtle.select(16) turtle.dropUp()
end

function diggy()
for a=1,2 do
for x=1,22 do
turtle.digDown()
turtle.forward()
turtle.digDown()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
end
end

for x=1,20 do
diggy()
turtle.digDown()
turtle.down()
end

chest()

for x=1,20 do
diggy()
turtle.digDown()
turtle.down()
end

chest()

for x=1,20 do
diggy()
turtle.digDown()
turtle.down()
end

Retrieval program:
Spoilerfunction goDown()
for x=1,50 do turtle.down()
end
for x=1,16 do turtle.suckDown()
end
turtle.digDown()
end

function goUp()
for x=1,20 do turtle.up()
end
end

function goUpMoar()
for x=1,39 do turtle.up()
end
end

function take()
turtle.forward()
turtle.forward()
goDown()
goUp()
turtle.select(1)
turtle.placeUp()
turtle.select(2)
turtle.dropUp()
turtle.select(3)
turtle.dropUp()
turtle.select(4)
turtle.dropUp()
turtle.select(5)
turtle.dropUp()
turtle.select(6)
turtle.dropUp()
turtle.select(7)
turtle.dropUp()
turtle.select(8)
turtle.dropUp()
turtle.select(9)
turtle.dropUp()
turtle.select(10)
turtle.dropUp()
turtle.select(11)
turtle.dropUp()
turtle.select(12)
turtle.dropUp()
turtle.select(13)
turtle.dropUp()
turtle.select(14)
turtle.dropUp()
turtle.select(15)
turtle.dropUp()
turtle.select(16)
turtle.dropUp()
turtle.select(1)
end

function take2()
turtle.forward()
turtle.forward()
goDown()
goUpMoar()
turtle.select(1)
turtle.placeUp()
turtle.select(2)
turtle.dropUp()
turtle.select(3)
turtle.dropUp()
turtle.select(4)
turtle.dropUp()
turtle.select(5)
turtle.dropUp()
turtle.select(6)
turtle.dropUp()
turtle.select(7)
turtle.dropUp()
turtle.select(8)
turtle.dropUp()
turtle.select(9)
turtle.dropUp()
turtle.select(10)
turtle.dropUp()
turtle.select(11)
turtle.dropUp()
turtle.select(12)
turtle.dropUp()
turtle.select(13)
turtle.dropUp()
turtle.select(14)
turtle.dropUp()
turtle.select(15)
turtle.dropUp()
turtle.select(16)
turtle.dropUp()
turtle.select(1)
end

for x=1,9 do
take()
end

turtle.turnLeft()
turtle.turnLeft()
for x=1,18 do turtle.forward()
end
turtle.turnLeft()
turtle.turnLeft()

for x=1,9 do
take2()
end

turtle.turnLeft()
turtle.turnLeft()

for x=1,18 do turtle.forward()
end
ChunLing #2
Posted 11 October 2012 - 05:01 AM
You should use a for loop in your chest functions, like so:

function chest()
turtle.select(1) turtle.placeUp()
for i=2,16 do turtle.select(i) turtle.dropUp() end
end

You can also use turtle.compare() and turtle.getItemCount/Space() so that your turtles can drop-off/pick-up chests where they're needed, in case you're hitting a variety of different ores and stuff. You should also write some more robust and efficient mining functions rather than relying on turtle.forward to always work. I like
function trply(mssgstr) -- i.e. "unbreakable block in path"
    print(mssgstr)
    if cldt.rcID then sleep(0.1) rednet.send(cldt.rcID,mssgstr) end
end
function mvdgK(mvcmd, drctn) -- i.e.(turtle.up, "Up")
local itr8 = 0
while not mvcmd() do
  local fncnm = "detect"..drctn
  if turtle[fncnm]() then
   fncnm = "dig"..drctn
   if not turtle[fncnm]() then trply("unbreakable block in path") return false end
  elseif turtle.getFuelLevel() == 0 then trply("Out of fuel" ) return false
  else
   fncnm = "attack"..drctn
   turtle[fncnm]()
  end
  if itr8 > 64 then trply("persistent impediment") return false end
  itr8 = itr8+1
end
return true
end
It accepts a move command (turtle.forward(), turtle.up(), or turtle.down()) and a direction string ("", "Up", or "Down"). If he turtle can't move, then it will detect if there is a block and try to dig it, or if there is no block it will try attacking in that direction. If uses the trply() rather than just print() for remote control feedback, but you don't necessarily need that.
MrFrostmaul #3
Posted 18 November 2012 - 06:11 AM
Any information on how I set this up like where does it all have to go?