1 posts
Posted 19 April 2013 - 09:05 AM
Are you trying to set up a server? Are you trying to make long strip mines without the hassle of digging them yourself?
Take this program, put it into a turtle and just start the program up!
The turtle takes torches in slot 1, and chests in slot 2. Once it runs out of torches, chests or has only enough fuel to return, it will return to where it started ,face the tunnel and tell you why it stopped!
Special features:
- Has a very simple EnderChest capability. Simply set 'enderchest' to true, and it works!
- Easy to set up for different light sources, simply edit the 'light' function for floor lighting, or edit the first for loop in the main while loop to make more space between the torches if you're using better torches!
- Tells you why the tunneling stopped.
Using this system will allow you to dig a two block tall strip mine, allowing you to access all of the ores there. Set up a few of these three blocks apart, and just check the walls once they're done!
By Default:
- Torch spacing is set to 12, prevents mob spawning with regular torches
- Enderchest is turned off.
- The turtle has no refueling capability, refuel before the strip to control the journey length.
The code:
Spoiler
local enderchest = false
local torch = turtle.getItemCount(1)
local chests = turtle.getItemCount(2)
local dist = 0
function dump()
if turtle.getItemCount(16)>0 then
turtle.digDown()
turtle.select(2)
turtle.placeDown()
for slot = 3,16,1 do
turtle.select(slot)
turtle.dropDown()
end
if enderchest then
turtle.select(2)
turtle.digDown()
else
c = c - 1
end
end
end
function digforw()
if turtle.detect() then
turtle.dig()
end
turtle.forward()
dump()
turtle.digUp()
dump()
dist = dist + 1
end
function home()
turtle.turnLeft()
turtle.turnLeft()
if turtle.detectUp() then
turtle.digUp()
end
turtle.up()
for i=1,dist,1 do
turtle.forward()
end
turtle.down()
if torch==0 then
print("Ran out of torches.")
elseif chests==0 then
print("Ran out of chests.")
else
print("Ran out of fuel.")
end
turtle.turnLeft()
turtle.turnLeft()
end
function light()
turtle.turnLeft()
turtle.turnLeft()
turtle.select(1)
turtle.place()
turtle.turnLeft()
turtle.turnLeft()
torch = torch - 1
end
local retdist = 0
local fuel = turtle.getFuelLevel()
function run()
while (torch>0) and (chests>0) and (fuel>retdist) do
for i=1,12,1 do
digforw()
end
light()
retdist = dist + 14
fuel = turtle.getFuelLevel()
end
home()
end
run()Or get it on your turtles with pastebin code:
pastebin get vMSPVVi0
or just go and see it at
http://pastebin.com/vMSPVVi0Hope you like this!
- Vralka
2 posts
Posted 23 April 2013 - 10:41 PM
Hey, would you mind if I post a modified version of this code up? Full credit etc. to you for the original code. I stripped it down to a tunnel miner and then changed the size of the tunnel to 3x2 and extended it so that it makes multiple tunnels with a two block wall between them.
Terra
25 posts
Posted 11 July 2013 - 04:14 PM
tunnel2:19: attemp to perform arithmetic __sub on nil and number
Erorr.
I fixed it here :
pastebin.com/bk8xaz9NThe problem was, you can't do c = c - 1.
You have to do : local c = c - 1
40 posts
Location
Philippines
Posted 16 September 2013 - 11:39 AM
521 posts
Location
Stockholm, Sweden
Posted 16 September 2013 - 01:23 PM
You could do
c = (c or 0) - 1
where you could replace 0 with the default, I presume 0 would be the starting point.
187 posts
Location
Bowie, TX
Posted 16 September 2013 - 03:26 PM
You could do
c = (c or 0) - 1
where you could replace 0 with the default, I presume 0 would be the starting point.
Is this a joke? Why all the emphasis on that line? I don't see where c is being used anywhere. Looks like the programmer didn't want that else block to me.
40 posts
Location
Philippines
Posted 17 September 2013 - 04:30 AM
You could do
c = (c or 0) - 1
where you could replace 0 with the default, I presume 0 would be the starting point.
Is this a joke? Why all the emphasis on that line? I don't see where c is being used anywhere. Looks like the programmer didn't want that else block to me.
That is why i remove it Because has no use.
http://pastebin.com/ZRak7N4X (Still lot Fixing To Do)
521 posts
Location
Stockholm, Sweden
Posted 17 September 2013 - 05:11 AM
Is this a joke? Why all the emphasis on that line? I don't see where c is being used anywhere. Looks like the programmer didn't want that else block to me.
Lol I am sorry, I can stay quiet
44 posts
Location
Sitting at my computer.
Posted 17 September 2013 - 07:23 PM
Epic program! Use cheese's fix and you have no errors!
44 posts
Location
Sitting at my computer.
Posted 18 September 2013 - 06:17 AM
Found an error. It stops when it places a chest.
40 posts
Location
Philippines
Posted 18 September 2013 - 11:21 AM
Epic program! Use cheese's fix and you have no errors!
I had Error with cheese fix when you watch turtle it will place down chest put item in it then break it aging and place chest and all items lands on floor
1 posts
Posted 28 December 2015 - 07:27 PM
I have found the solution! the problem was that c should be chests not c so replace c = c - 1 to
chests = chests - 1I have found the solution! the problem was that c should be chests not c so replace c = c - 1 to chests = chests - 1
Right after "turtle.Dropdown()" on the next line down put "turtle.select(3)" that will solve the multiple chests