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

Miner Turtle - Ic2 Edition

Started by grom79, 17 September 2013 - 06:16 AM
grom79 #1
Posted 17 September 2013 - 08:16 AM
Hello there, I would like to show you 4 programs for a mining turtle to help you setup and semi-automate setting IC2 Miner.
You need simple Mining Turtle filled with:

- Drawbridge(3), Miner(2), Chute(1), Geothermal Generator(12)
- IC2 Cable (any, I suggest copper or glass fibre cable, 5), Liquiduct(6), Torch(3), Any solid building material (no glass or sand etc. 4)
- Ender Tank with a steady supply of lava(1), Redstone reacting Lamp(can be vanilla one, 1), Ender Chest prepared for a input of items (1), empty slot
- empty slot, items needed for Miner to operate, OV/OC Scanner, Mining/Diamond Drill, Mining Pipes(64)

I suggest setting turtle on a y=66 because of the mining pipes restriction. Also, turtle will put Miner in exacly the same position that he was.
When you pick a plase for your turtle, use "Clear" command. It'll clear all needed terrain for the whole setup. If it needs to break a block, it'll do that and then it'll deposit that thing in a ender chest.

After clearing that space, use "Miner" command. It'll prepare all needed items for a Miner to work: 3 drawbridges sets, liquiducts and cables. Be sure that Ender Chest is constantly cleared by your sorting system and that your Ender Tank is constantly filled with lava.

The last phase of "Miner" program is checking if Miner is working. Once every minute it'll check the ammount of pipes in Miner, register that number and check if it changed sinse the last time or if there's any pipe left. If any of these two happens, turtle will emit redstone signal to the lamp that it'll set above itselt and print corresponding command ("No pipes left" or "Miner blocked or ended")

If you'll log out when Miner is working or you unstuck your Miner, I suggest using "Continue" program. It'll break that lamp (if there's any) and restart checking pipes.
When your Miner ended,use "Destruct" program. It'll pack that whole contraption created before and wait for the next command.

[media]http://www.youtube.com/watch?v=TfOy2uLXlBE[/media]

That's all I've created. Below I give you code for that thing.

Clear
Spoiler
function moveForward(m)
                for i=1,m do
                               turtle.forward()
                end
end
function moveBack(m)
                for i=1,m do
                               turtle.back()
                end
end
function moveUp(m)
                for i=1,m do
                               turtle.up()
                end
end
function moveDown(m)
                for i=1,m do
                               turtle.down()
                end
end

function clearWithout(n)
                for i=1,n do
                               turtle.select(11)
                               if turtle.digUp(true) then
                                               turtle.select(11)
                                               turtle.placeUp()
                                               turtle.select(12)
                                               turtle.dropUp()
                                               turtle.select(11)
                                               turtle.digUp()
                                               turtle.select(12)
                               end
                               if turtle.digDown(true) then
                                               turtle.select(11)
                                               turtle.placeUp()
                                               turtle.select(12)
                                               turtle.dropUp()
                                               turtle.select(11)
                                               turtle.digUp()
                                               turtle.select(12)
                               end
                               if turtle.dig(true) then
                                               turtle.select(11)
                                               turtle.placeUp()
                                               turtle.select(12)
                                               turtle.dropUp()
                                               turtle.select(11)
                                               turtle.digUp()
                                               turtle.select(12)
                               end
                               turtle.forward()
                end
end

function clear(l)
                clearWithout(l)
                moveBack(l)
end

function nextLine()
                turtle.turnLeft()
                clearWithout(1)
                turtle.turnRight()
end

turtle.select(11)
turtle.turnLeft()
turtle.turnLeft()
clearWithout(2)
turtle.turnLeft()
clearWithout(2)
turtle.turnLeft()
clear(3)
nextLine()
clear(3)
nextLine()
clear(3)
nextLine()
clear(7)
nextLine()
clear(7)
turtle.turnRight()
turtle.up()
clearWithout(3)
turtle.down()
turtle.back()
turtle.turnLeft()
moveForward(2)
print("Section cleared")
Miner
Spoiler
function moveForward(m)
                for i=1,m do
                               turtle.forward()
                end
end
function moveBack(m)
                for i=1,m do
                               turtle.back()
                end
end
function moveUp(m)
                for i=1,m do
                               turtle.up()
                end
end
function moveDown(m)
                for i=1,m do
                               turtle.down()
                end
end

function placeSeq(m,n)
                turtle.select(1)
                turtle.place()
                turtle.select(m)
                turtle.drop(n)
                turtle.select(8)
                turtle.placeDown()
                turtle.up()
                turtle.select(7)
                turtle.placeDown()
end

function nextLine()
                turtle.turnLeft()
                turtle.forward()
                turtle.turnRight()
end

function minerPrep()
                for i=14,16 do
                               turtle.select(i)
                               turtle.drop()
                end
end

function lineBuild(m,n)
                turtle.select(m)
                moveForward(n-2)
                for i=1,n do
                               turtle.place()
                               turtle.back()
                end
end

function pipeCheck()
                if turtle.getItemCount(2) > 0 then
                               turtle.up()
                               turtle.select(2)
                               turtle.drop()
                               turtle.select(1)
                               turtle.drop()
                               turtle.down()
                else
                               if turtle.getItemCount(1) > 0 then
                                               turtle.up()
                                               turtle.select(1)
                                               turtle.drop()
                                               turtle.down()
                               end
                end
                turtle.select(16)
                if turtle.suck(true) then
                               local i = turtle.getItemCount(16)
                               turtle.drop()
                               turtle.back()
                               sleep(60)
                               turtle.forward()
                               turtle.suck()
                               if i == turtle.getItemCount(16) then
                                               turtle.drop()
                                               turtle.back()
                                               turtle.select(10)
                                               turtle.placeUp()
                                               redstone.setOutput("top", true)
                                               print("Miner blocked or ended. Awaiting command")
                               else
                                               turtle.drop()
                                               turtle.back()
                                               sleep(60)
                                               turtle.forward()
                                               pipeCheck()
                               end
                else
                               turtle.drop()
                               turtle.back()
                               turtle.select(10)
                               turtle.placeUp()
                               redstone.setOutput("top", true)
                               print("No more pipes. Awaiting command")
                end
end

moveBack(2)
placeSeq(2,2)
turtle.forward()
turtle.select(8)
turtle.dropDown(1)
turtle.select(3)
turtle.place()
minerPrep()
sleep(7)
turtle.select(3)
turtle.dig()
turtle.select(11)
turtle.place()
nextLine()
turtle.forward()
turtle.down()
lineBuild(5,5)
turtle.up()
placeSeq(4,6)
nextLine()
moveDown(2)
placeSeq(4,6)
moveForward(2)
lineBuild(6,5)
turtle.place()
turtle.turnLeft()
turtle.up()
turtle.select(9)
turtle.placeDown()
moveBack(4)
moveDown(2)
turtle.turnRight()
moveForward(2)
turtle.turnLeft()
sleep(60)
turtle.forward()
pipeCheck()
Continue
Spoiler
redstone.setOutput("top", false)
turtle.select(10)
turtle.digUp()
turtle.forward()
function pipeCheck()
                if turtle.getItemCount(2) > 0 then
                               turtle.up()
                               turtle.select(2)
                               turtle.drop()
                               turtle.select(1)
                               turtle.drop()
                               turtle.down()
                else
                               if turtle.getItemCount(1) > 0 then
                                               turtle.up()
                                               turtle.select(1)
                                               turtle.drop()
                                               turtle.down()
                               end
                end
                turtle.select(16)
                if turtle.suck(true) then
                               local i = turtle.getItemCount(16)
                               turtle.drop()
                               turtle.back()
                               sleep(60)
                               turtle.forward()
                               turtle.suck()
                               if i == turtle.getItemCount(16) then
                                               turtle.drop()
                                               turtle.back()
                                               turtle.select(10)
                                               turtle.placeUp()
                                               redstone.setOutput("top", true)
                                               print("Miner blocked or ended. Awaiting command")
                               else
                                               turtle.drop()
                                               turtle.back()
                                               sleep(60)
                                               turtle.forward()
                                               pipeCheck()
                               end
                else
                               turtle.drop()
                               turtle.back()
                               turtle.select(10)
                               turtle.placeUp()
                               redstone.setOutput("top", true)
                               print("No more pipes. Awaiting command")
                end
end

turtle.forward()
pipeCheck()
Destruct
Spoiler
function moveForward(m)
                for i=1,m do
                               turtle.forward()
                end
end
function moveBack(m)
                for i=1,m do
                                turtle.back()
                end
end
function moveUp(m)
                for i=1,m do
                               turtle.up()
                end
end
function moveDown(m)
                for i=1,m do
                               turtle.down()
                end
end

function check()
                turtle.select(1)
                if turtle.getItemCount(1) ~= 64 then
                               sleep(5)
                               check()
                end
                turtle.transferTo(16)
end

function clearDraw(m)
                turtle.select(7)
                turtle.dig()
                turtle.forward()
                turtle.select(8)
                turtle.digDown()
                turtle.turnRight()
                turtle.select(m)
                turtle.suck()
end

function endDraw()
                turtle.select(1)
                turtle.dig()
end
function destLine(n,m)
                turtle.select(n)
                for i=1,m do
                               turtle.dig()
                               turtle.forward()
                end
                moveBack(m)
end

redstone.setOutput("top", false)
turtle.select(10)
turtle.digUp()
turtle.forward()
turtle.select(16)
turtle.suck()
turtle.up()
turtle.select(11)
turtle.dig()
turtle.forward()
turtle.select(15)
turtle.suckDown()
check()
turtle.back()
moveDown(2)
turtle.forward()
turtle.select(14)
turtle.suckUp()
turtle.back()
turtle.up()
turtle.turnLeft()
moveForward(2)
turtle.turnRight()
clearDraw(2)
turtle.up()
turtle.forward()
turtle.select(8)
turtle.suckDown()
turtle.back()
turtle.down()
endDraw()
turtle.turnLeft()
turtle.up()
clearDraw(4)
endDraw()
turtle.down()
turtle.forward()
destLine(5,5)
turtle.back()
turtle.turnLeft()
clearDraw(4)
endDraw()
turtle.select(9)
turtle.digUp()
turtle.up()
destLine(6,6)
turtle.down()
turtle.turnRight()
moveForward(2)
turtle.turnLeft()
moveForward(2)
print("All clear!")
Beware that it's my first program and it has many flaws (if you stand in a way of turtle, it'll break everything), but it's working if not disturbed!
Goof #2
Posted 17 September 2013 - 09:55 AM
please indent the code and use the code tag.

OP:

looks nice :D/>
grom79 #3
Posted 17 September 2013 - 10:17 AM
Indented, used "code" tag.
Apfeldstrudel #4
Posted 18 September 2013 - 10:46 AM
Sorry for being this guy but.. spoilers?
Moti #5
Posted 19 September 2013 - 12:22 AM
Good code, but you have to make it easier to read.
grom79 #6
Posted 19 September 2013 - 07:59 AM
One tells me to use "code" tag when I was using "spoiler", other tells me to use "spoiler" tag xD Both applied!
Easier to read. Can you tell me how? I've tried to do that with tabulator in function segment, but work segment is a little bit hard to clean with all these proceeding commands.