Originally Posted by
Fuzzzie
Can you share the code? I'm terrible at doing it. Something I have to learn.
---------- Post added 2012-12-08 at 02:36 PM ----------
[/COLOR]
[COLOR="red"]
I'll share it when I get home later today. It's not that great of a code, and I'm sure it has many places I could compact it, but it works alright. It doesn't have a way of depositing it's inventory programmed in. You basically just place it, run the program and it should set up for the next shaft. It also does have some torch redundancy when it starts. I'll try to correct this before I post.
General Overview of the Program:
- You need to keep coal in the first slot and torches in the second.
- When placed, it will immediately check it's fuel levels and consume fuel from the first slot (just keep a stack of coal in there, you should be finding plenty).
- It will turn right, dig into the shaft, back up and place a torch on the wall of the corridor. Then continue digging 70 blocks forward (above and below forming a 1x2x70 shaft) and placing torches every 10 blocks.
- It will then turn around and exit the shaft, turn right, move forward two and stop. This sets it up for the next shaft so you only have to start the program again.
- I have written the code to have the program start with the command "multistrip <#>" The number is the number of shafts you want it to dig in a row. A full stack of torches will be used in about 5 strips. So you could start the program with the command "multistrip 5" and it will dig 5 shafts, each with two blocks in between (which is the optimal branch mining method).
- It will not get stuck on gravel of stop the program if someone stand in front of it. It will destroy anything in front and 1 block above it.
Using this program could be used to create a branch mine or pinwheel mine. I prefer pinwheels as they are easier to find you central shaft down, which is why I always had it turn right. It only has to be a mining turtle if you follow it around. If you don't you'll need to add a chunk loader. I mined my obsidian just using the lua prompt or making a program that just repeated digDown and move forward a few times then just move back to the original position.
I also wanted to mention that if you label your turtle, when you break it, it will keep it's programs and fuel level. This way you don't have to re-import programs or waste fuel when you have to manually move it. Otherwise, the game thinks you're placing a new turtle and creates a new folder and ID for it.
Edit: Coding is added.
This program uses an enderchest to return items. Place fuel in slot 1, torches in 2, and an enderchest in 3.
Code:
--Ender Strip Miner Program
local tArgs = { ... }
function fuel()
local f=turtle.getFuelLevel()
local c=turtle.getItemCount(1)
if f < 200 and c > 5 then
turtle.select(1)
turtle.refuel()
end
if f < 200 and c < 5 then
print("Low fuel "..f)
print("Enter to Continue")
io.read()
end
end
function inventoryFull()
full = turtle.getItemCount(16) > 0
return full
end
function returnItems()
turtle.select(3)
turtle.placeUp()
for i = 4,16 do
turtle.select(i)
turtle.dropUp()
end
turtle.select(3)
turtle.digUp()
turtle.select(1)
end
function torch()
turtle.back()
turtle.select(2)
turtle.placeUp()
turtle.select(1)
turtle.forward()
end
function digForward()
moved = false
while not(moved) do
turtle.dig()
moved = turtle.forward()
end
end
function shaft()
fuel()
turtle.turnRight()
digForward()
turtle.digUp()
for i=1,10 do
for i=1,7 do
if inventoryFull() then
returnItems()
end
digForward()
turtle.digUp()
end
torch()
end
turtle.turnRight()
turtle.turnRight()
for i=1,71 do
digForward()
end
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
end
function question()
print("Please place coal in slot 1, torches in 2, and an enderchest in 3")
print("Type anything when complete")
answer = read()
end
function start()
term.clear()
question()
for i=1,tArgs[1] do
shaft()
end
end
start()
This program does NOT use an enderchest to return items. If its inventory is full, it will just start dropping items on the ground. If you're following it, you'll just pick them up.
Code:
--Strip Miner Program
local tArgs = { ... }
function fuel()
local f=turtle.getFuelLevel()
local c=turtle.getItemCount(1)
if f < 200 and c > 5 then
turtle.select(1)
turtle.refuel()
end
if f < 200 and c < 5 then
print("Low fuel "..f)
print("Enter to Continue")
io.read()
end
end
function torch()
turtle.back()
turtle.select(2)
turtle.placeUp()
turtle.select(1)
turtle.forward()
end
function digForward()
moved = false
while not(moved) do
turtle.dig()
moved = turtle.forward()
end
end
function shaft()
fuel()
turtle.turnRight()
digForward()
turtle.digUp()
for i=1,10 do
for i=1,7 do
digForward()
turtle.digUp()
end
torch()
end
turtle.turnRight()
turtle.turnRight()
for i=1,71 do
digForward()
end
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
end
function question()
print("Please place coal in slot 1 and torches in 2")
print("Type anything when complete")
answer = read()
end
function start()
term.clear()
question()
for i=1,tArgs[1] do
shaft()
end
end
start()
I'm sure there's ways I could condense this or improve it, but I've already made a GoTo/Quarry turtle, so I'm not really worried about my strip mining program anymore. To import these files, save it in your turtle's directory. It is in your world save folder. So ...\minecraft\saves\Test\computer\0 if my computer ID was 0 (type ID in your turtle to find out it's ID). Whatever you save it as is now your program name. So if you save it as multistrip.txt, you start the program with as "multistrip.txt 2" to dig two mineshafts. If you save it as multistrip (without an extension on it) it will start up with "multistrip 2".