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

Mining / Digging configurable program with auto-dropping when slots full

Started by RODLON, 30 April 2012 - 08:27 PM
RODLON #1
Posted 30 April 2012 - 10:27 PM
NOTE: Code updated! Two bugfixes and new command with optional arguments to choose the coordinates.
A new update is coming soon, maybe this weekend if I have enough time… it will include, at least:
- Menu to control/configue the program, remotely controlable by a computer server program.
- Real time monitorization of the turtle with external screen (maybe support for several turtles simuntaniously). And with password to sync the turtle with new computer from the distance.
- Persistent variables and autostartup: if you close minecraft or the chunk unloads, the program will auto-continue the task in progres exactly where it was before.
- Eaisier to configure, keeping the command arguments to configurate and new option to skip the menu and mine directly.
- Configure it with minecraft world coordinates (needs a small calibration, once)
- Inverting the Y axis: now will be like the minecraft world.

You can give me some feedback or ideas :)/>/>
——————————————————————-

Hi!
I'm new in computercraft, and this is my firs program for computers(and my first program in lua).

What it does: The turtle digs a hole(configurable measures). You can configure it to only collect specific ores, and when cannot carry more ores of that kind, it comes back to the starting point, empty the slots and goes back to mining.

Changelog:
SpoilerV2:
Comming soon…

V1.1
- Two bugs fixed.
- Added input arguments to configure the home and measures of the mining zone.

v1:
- Initial release.
Instructions:
SpoilerInstallation - Copy the script to your turtle. To do it, you can copy&paste line by line directly to the text editor or…
Goto "%AppData%Roaming.minecraftsavesworldnamecomputercomputerID" and paste the code in a new text file without extension( for example: "miner"). Do it after switch on your turtle.
You also can put that text fie into "%AppData%Roaming.minecraftmodsComputerCraftluaromprogramsturtle" and it will be available for every turtle in your game.

Usage:
1- Put the turtle somewhere, like the picture(ignore the hole xD). switch it on and copy the script:

Note that the Y axis is has the + below and the - above.

2- Configure the variables editing the file(if you want) and put the ores in the slots.
3- Start the program and wait until the program finishes the hole.

You can use the optional arguments:
help -Show how to use the other arguments.
h X Y Z -specficates the home/dropping position(home# variables)
s X Y Z -specficates the final starting(min# variables)
f X Y Z -specficates the final position(max# variables)
Example:miner h 0 0 -1 s -2 0 0 f 2 4 2

How to configure the hole measures:

The program has 9 variables for measures: homeX,homeY,hameZ to specify the actual position of the turtle. This position will be used to drop the ores and as starting position. The other 6 are the measures of the hole, and are relative to the home variables, to make a hole from minX,minY,minZ to maxX,maxY,maxZ. You can use negative coordinates to dig wherever you want to, but be careful of mining your drop location!
It doesn't uses the GPS api, the place you put the turtle will be the coordinates specified with the home variables.
The image above has been done with the default config, so you can imagine how it works :)/>/>

How to configure the slots for each ore:
It is one array, with 9 values, one for each slot. Yo can group the slots, and when the group is full(full stacks of items) the turtle will go to home coordinates.

This default config has 3 groups of 2 slots: slot1+slot2, slot3+slot4, slot5+slot6, slot7, slot8, slot9:

-- Default config with example of materials:
sums[9]=1 -- Diamond(item)
sums[8]=1 -- Gold ore
sums[7]=1 -- Lapislazulli(Item)
sums[6]=2 -- Redstone dust
sums[5]=1 -- Redstone dust
sums[4]=2 -- Iron ore
sums[3]=1 -- Iron ore
sums[2]=2 -- Coal(item)
sums[1]=1-- Coal(item)
I'm not sure how to explain this, but… the number in the variable determinates the numer of slots below to group, included itself. So, with "sums[2]=2" and "sums[1]=1" your are configuring one group formed with the slots 2 and 1. (You need to put "1" instead of "0" even if that slot is alredy in a group), If you want only one group(useful for mining only one kind of items), you can do:

-- Default config:
sums[9]=9 -- Sand
sums[8]=1 -- Sand
sums[7]=1 -- Sand
sums[6]=1 -- Sand
sums[5]=1 -- Sand
sums[4]=1-- Sand
sums[3]=1 -- Sand
sums[2]=1 -- Sand
sums[1]=1 -- Sand
I almost foreget: you need to put in each slot of each group one item to define the kind of item that the groups will contain. You have an example in the example of the config above.

Here is the updated code:
Spoiler

-- Min coords:
minX = 0
minY = 0 -- Must be a number divisible by 2!
minZ = 0
--Max coords:
maxX = 5
maxY = 4 -- Must be a number divisible by 2!
maxZ = 5

-- Start / Cargo drop:
homeX=0
homeY=0
homeZ=-2
-- Slots config
sums = {}
sums[9]=1
sums[8]=1
sums[7]=1
sums[6]=2
sums[5]=1 --
sums[4]=2
sums[3]=1 --
sums[2]=2
sums[1]=1 --

-- Do not change anything below this comment or something could go wrong.

local tArgs = { ... }
term.clear()
term.setCursorPos(1,1)
print("   ---  Mining program  ---")

sums[0]=0
finaliza = false
help = false

function setInicial()
		-- MiddlePass coords
		partX = homeX
		partY = homeY
		partZ = homeZ + 2
		if minZ>homeZ then
				partZ = minZ
		end
		-- Current coords:
		x = homeX
		y = homeY
		z = homeZ
		lado = 1 -- Starting direction. 0=l 1=f 2=r 3=b
		-- last mining coords / mining taring coords:
		xw = minX
		zw = minZ
		yw = minY
		if math.fmod(minY,4) ~= 0 then
				xw = maxX
				zw = maxZ
		end
		ladow = 1
end

function readAndSetArg(num)
		if #tArgs >=num+3 then
				if tonumber(tArgs[num+1]) ~= nil and tonumber(tArgs[num+2]) ~= nil and tonumber(tArgs[num+3]) ~= nil then
						if tArgs[num] == "h" then
								homeX=tonumber(tArgs[num+1])
								homeY=tonumber(tArgs[num+2])
								homeZ=tonumber(tArgs[num+3])
								print("Read home position:  x"..homeX.." y"..homeY.." z"..homeZ)
						elseif tArgs[num] == "s" then
								minX=tonumber(tArgs[num+1])
								minY=tonumber(tArgs[num+2])
								minZ=tonumber(tArgs[num+3])
								print("Read start position: x"..minX.." y"..minY.." z"..minZ)
						elseif tArgs[num] == "f" then
								maxX=tonumber(tArgs[num+1])
								maxY=tonumber(tArgs[num+2])
								maxZ=tonumber(tArgs[num+3])
								print("Read final position: x"..maxX.." y"..maxY.." z"..maxZ)
						end
				end
		end
end
function readArgs()
-- Reads the arguments
		if #tArgs > 0 then
				if tArgs[1] == "help" or tArgs[1] == "Help" then
						print("Usage: miner [help]")
						print("Usage: miner [h X Y Z] [s X Y Z] [f X Y Z]")
						print()
						print("Where 'h' is the home position, 's' is the start position and 'f' is the finish position. And X Y Z are the coordinates.")
						print()
						print("Example:")
						print(" miner h 0 0 -1 s -2 0 0 f 2 4 2")
						help = true
				elseif #tArgs >= 4 then
						readAndSetArg(1)
						readAndSetArg(5)
						readAndSetArg(9)
				end
		end
						setInicial()
end

function askStarting()
		print()
		print("Home position:   x"..homeX.." y"..homeY.." z"..homeZ)
		print("Start position:  x"..minX.." y"..minY.." z"..minZ)
		print("Finish position: x"..maxX.." y"..maxY.." z"..maxZ)
		print()
		print("Are these numbrers correct? [S/Y/N]")
		while true do
				event, param1 = os.pullEvent()
				if event == "char" then
						if param1 == "S" or param1 == "s" or param1 == "Y" or param1 == "y"  then
								print("Ok! Turtle starting...")
								return true
						elseif param1 == "N" or param1 == "n" then
								print("Try again!")
								return false
						end
				elseif event == "key" and param1==28 then
						print("Ok! Turtle starting...")
						return true
				end
		end
		return false
end
function gira(l)
-- Receive an absolute directon and does the propiate turns
		local resta = math.abs(lado -l)
		while lado ~= l do
				if (resta > 2 and lado < l) or (resta <= 2 and lado > l) then
						turtle.turnLeft()
						lado = lado-1
				else  
						turtle.turnRight()
						lado = lado+1
				end
				if lado>3 then
						lado=0
				elseif lado<0 then
						lado=3
				end
		end
end
function movX(tox)
		-- Moves the turle to tox in X axix
		if x > tox then
				gira(0)
		elseif x < tox then
				gira(2)
		end
		while x ~= tox do
				while turtle.detect() do
						turtle.dig()
				end
				turtle.forward()
				if lado == 0 then
						x=x-1
				else
						x=x+1
				end
		end
end
function movY(toy)
		-- Moves the turle to toy in Y axix
		while y < toy do
				if turtle.detectDown() then
						turtle.digDown()
				end
						turtle.down()
						y=y+1;
		end
		while y > toy do
				while turtle.detectUp() do
						turtle.digUp()
				end
				if turtle.up() then
						y=y-1;
				else
						finaliza=true
						break;
				end
		end
end
function movZ(toz)
		-- Moves the turle to toz in Z axix
		if z > toz then
				gira(3)
		elseif z < toz then
				gira(1)
		end
		while z ~= toz do
				while turtle.detect() do
						turtle.dig()
				end
				turtle.forward()
				if lado == 1 then
						z=z+1
				else
						z=z-1
				end
		end
end
function mueveCords(tox,toy,toz,dir)
		-- Moves the turtle to the spcified coords mining everithing in its way.
		modY = 0
		if dir == "home" then
				if y-2 >= toy and y-2 >= minY then
						modY=2
						movY(y-modY)
				end
				-- x:
				movX(tox)
				-- z:
				movZ(toz)
				-- y:
				movY(toy)
		else
				if y <= toy-2 and toy-2 >= minY then
						modY=2;
				end
				movY(toy-modY)
				-- z:
				movZ(toz)
				-- x:
				movX(tox)
				-- y:
				movY(toy)
		end
end
function checkInventario()
-- Checks the slots. If some slot is full, it will go home to drop everihing
		local tmp=9
		local lleno=false
		while tmp >0 do
						if turtle.getItemSpace(tmp) == 0 then
								turtle.select(tmp)
								--if turtle.compare() or turtle.compare() then
										lleno=true
										tmp=0
								--end
						end
						tmp=tmp-sums[tmp]
		end
		if lleno then
		--rednet.open("Right")
				xw=x
				yw=y
				zw=z
				ladow=lado
				goHome()
				descarga()
				goWork()
		end
end
function cava()
-- mine forward and up
		while (turtle.detect() or turtle.detectUp()) and not finaliza do
				cavado=true
				if turtle.detect() then
						if not turtle.dig() then
								finaliza=true
						end
				end
				if turtle.detectUp() then
						if not turtle.digUp() then
								finaliza=true
						end
				end
		end
end
function workX(num)
		-- mine in X axis
		gira(num+1)
		local fin = false
		while not fin and not finaliza do
				if (x > minX and num==-1) or (x < maxX and num==1) then
						checkInventario()
						cava()
						if turtle.forward() then
								x=x+num
						else
								finaliza=true
						end
				else
						fin=true
				end
		end
end
function workZ(num)
		-- mine a entire level
		local fin = false
		while not fin and not finaliza do
				if math.fmod(z,2) == 0 then
						workX(1*num)
				else
						workX(-1*num)
				end
				if (z > minZ and num==-1) or (z < maxZ and num == 1) then
						gira(2-num)
						cava()
						if turtle.forward() then
								z = z+num
						else
								finaliza=true
						end
				else
						fin = true
				end
		end
end
function goHome()
-- Go to home coords
		mueveCords(partX,partY,partZ,"home")
		mueveCords(homeX,homeY,homeZ,"home")
end
function descarga()
		-- Drops everithing but 1 block
		print("Dropping items...")
		local tmp2=9
		while tmp2 > 0 do
  turtle.select(tmp2)
		if turtle.getItemCount(tmp2) > 0 then
				turtle.drop(turtle.getItemCount(tmp2)-1)
				end
				tmp2=tmp2-1
		end
end
function goWork()
		-- Moves the turtle to the last mining coordinates
		mueveCords(partX,partY,partZ,"work")
		mueveCords(xw,yw,zw,"work")
		gira(ladow)
end
function mineria()
-- Starts everithing.
		print("Starting from x:"..minX.." y:"..minY.." z:"..minZ)
		print("To x:"..maxX.." y:"..maxY.." z:"..maxZ)
		goWork()
		checkInventario()
		while y <= maxY and not finaliza do
				if math.fmod(y/2,2) == 0 then
						workZ(1)
				else
						workZ(-1)
				end
				if y < maxY and not finaliza then
						turtle.digUp()
						turtle.digDown()
						if  turtle.down() then
								y=y+1
						else
								finaliza=true
						end
						turtle.digUp()
						turtle.digDown()
						if turtle.down() and not finaliza then
								y=y+1
						else
								turtle.digUp()
								finaliza=true
						end
				else
						maxY=maxY-1
				end
		end
end

readArgs()
if not help then
		if askStarting() then
		mineria()
		if finaliza then
				print("Something went wrong...(bedrock?player?mob?)")
		else
				print("Finish!!")
		end
		goHome()
		descarga()
		gira(1)
		end
end
-- By RODLON


Here is the outdatd code without command arguments and two bugs:
Spoiler

-- Min coords:
minX = 0
minY = 0 -- Must be a number divisible by 4!
minZ = 0
--Max coords:
maxX = 5
maxY = 4 -- Must be a number divisible by 4!
maxZ = 5
-- Start / Cargo drop:
homeX=0
homeY=0
homeZ=-1
-- Slots config
sums = {}
sums[9]=1
sums[8]=1
sums[7]=1
sums[6]=2
sums[5]=1 --
sums[4]=2
sums[3]=1 --
sums[2]=2
sums[1]=1 --
sums[0]=0
-- Do not change anything below this comment or something could go wrong.
-- MiddlePass coords
partX = homeX
partY = homeY
partZ = homeZ + 2
if minZ>homeZ then
partZ = minZ
end
-- Current coords:
x = homeX
y = homeY
z = homeZ
lado = 1 -- Starting direction. 0=l 1=f 2=r 3=b
-- last mining coords / mining taring coords:
xw = minX
yw = minY
zw = minZ
if math.fmod(minY,4) ~= 0 then
	xw = maxX
	zw = maxZ
end
ladow = 1
finaliza = false
function gira(l)
-- Receive an absolte directon and does the propiate turns
local resta = math.abs(lado -l)
while lado ~= l do
  if (resta > 2 and lado < l) or (resta <= 2 and lado > l) then
   turtle.turnLeft()
   lado = lado-1
  else
   turtle.turnRight()
   lado = lado+1
  end
  if lado>3 then
   lado=0
  elseif lado<0 then
   lado=3
  end
end
end
function movX(tox)
-- Moves the turle to tox in X axix
if x > tox then
  gira(0)
elseif x < tox then
  gira(2)
end
while x ~= tox do
  while turtle.detect() do
   turtle.dig()
  end
  turtle.forward()
  if lado == 0 then
   x=x-1
  else
   x=x+1
  end
end
end
function movY(toy)
-- Moves the turle to toy in Y axix
while y < toy do
  if turtle.detectDown() then
   turtle.digDown()
  end
   turtle.down()
   y=y+1;
end
while y > toy do
  while turtle.detectUp() do
   turtle.digUp()
  end
  turtle.up()
  y=y-1;
end
end
function movZ(toz)
-- Moves the turle to toz in Z axix
if z > toz then
  gira(3)
elseif z < toz then
  gira(1)
end
while z ~= toz do
  while turtle.detect() do
   turtle.dig()
  end
  turtle.forward()
  if lado == 1 then
   z=z+1
  else
   z=z-1
  end
end
end
function mueveCords(tox,toy,toz,dir)
-- Moves the turtle to the spcified coords mining everithing in its way.
modY = 0
if dir == "home" then
  if y-2 >= toy and y-2 <= minY then
   modY=2
  end
  -- x:
  movX(tox)
  -- z:
  movZ(toz)
  -- y:
  movY(toy)
else
  if y <= toy-2 and toy-2 >= minY then
   modY=2;
  end
  movY(toy-modY)
  -- z:
  movZ(toz)
  -- x:
  movX(tox)
  -- y:
  movY(toy)
end
end
function checkInventario()
-- Checks the slots. If some slot is full, it will go home to drop everihing
local tmp=9
local lleno=false
while tmp >0 do
   if turtle.getItemSpace(tmp) == 0 then
	turtle.select(tmp)
	--if turtle.compare() or turtle.compare() then
	 lleno=true
	 tmp=0
	--end
   end
   tmp=tmp-sums[tmp]
end
if lleno then
--rednet.open("Right")
  xw=x
  yw=y
  zw=z
  ladow=lado
  goHome()
  descarga()
  goWork()
end
end
function cava()
-- mine forward and up
while (turtle.detect() or turtle.detectUp()) and not finaliza do
  cavado=true
  if turtle.detect() then
   if not turtle.dig() then
	finaliza=true
   end
  end
  if turtle.detectUp() then
   if not turtle.digUp() then
	finaliza=true
   end
  end
end
end
function workX(num)
-- mine in X axis
gira(num+1)
local fin = false
while not fin and not finaliza do
  if (x > minX and num==-1) or (x < maxX and num==1) then
   checkInventario()
   cava()
   if turtle.forward() then
	x=x+num
   else
	finaliza=true
   end
  else
   fin=true
  end
end
end
function workZ(num)
-- mine a entire level
local fin = false
while not fin and not finaliza do
  if math.fmod(z,2) == 0 then
   workX(1*num)
  else
   workX(-1*num)
  end
  if (z > minZ and num==-1) or (z < maxZ and num == 1) then
   gira(2-num)
   cava()
   if turtle.forward() then
	z = z+num
   else
	finaliza=true
   end
  else
   fin = true
  end
end
end
function goHome()
-- Go to home coords
mueveCords(partX,partY,partZ,"home")
mueveCords(homeX,homeY,homeZ,"home")
end
function descarga()
-- Drops everithing but 1 block
print("Dropping items...")
local tmp2=9
while tmp2 > 0 do
  turtle.select(tmp2)
if turtle.getItemCount(tmp2) > 0 then
  turtle.drop(turtle.getItemCount(tmp2)-1)
  end
  tmp2=tmp2-1
end
end
function goWork()
-- Moves the turtle to the last mining coordinates
mueveCords(partX,partY,partZ,"work")
mueveCords(xw,yw,zw,"work")
gira(ladow)
end
function mineria()
-- Starts everithing.
goWork()
checkInventario()
while y < maxY and not finaliza do
  if math.fmod(y/2,2) == 0 then
   workZ(1)
  else
   workZ(-1)
  end
  if y < maxY and not finaliza then
   turtle.digUp()
   turtle.digDown()
   if  turtle.down() then
	y=y+1
   else
	finaliza=true
   end
   turtle.digUp()
   turtle.digDown()
   if turtle.down() and not finaliza then
	y=y+1
   else
	finaliza=true
   end
  end
end
end
mineria()
if finaliza then
print("Something went wrong...(bedrock?)")
else
print("Finish!!")
end
goHome()
descarga()
gira(1)
-- By RODLON

Maybe my english is bad, but I'm learning :)/>/>
Edited on 07 May 2012 - 09:31 PM
darkgreen6 #2
Posted 07 May 2012 - 08:44 PM
So, I launched the program on my mining turtle and it says "These numbers correct? [S/Y/N]" and if I press S or Y it displays what I believe is an error:
"Ok! Turtle starting…
Starting from x:0 y:0 z:0
To x:5 y:4 z:5
miner.txt:220: attempt to perform
arithmetic __sub on nil and number"
and then the turtle does nothing.. how do I fix this?

Picture:
Spoiler
RODLON #3
Posted 07 May 2012 - 11:15 PM
I'm sorry, I forgot to call a function at the begining if you don't write any arguments!
It's fixed now, thanks!

If you want to fix it by yourself, move the line 99 "setInicial()" to line 101, before the "end" of the function.
Also, the new version is almost finished… but it's taking more time than I thought.
Sitanel #4
Posted 08 May 2012 - 08:41 AM
Thanks for the very nice program! I used it tonight and I found it almost perfect to my needs.
There were some issues with tall columns of gravel (I started mining from underground) that made the turtle go one then two blocks right from the dropping point (I just changed the Finish variables to 16 16 16).
Is it possible to disable the slots configuration and make it similar to the excavate program? A modified version, maybe?
Ah I'm using technic pack and I modified the function descarga() to make it send redstone signals to my RedPower Filter instead of dropping the items (in a noob way, since I don't know lua).
RODLON #5
Posted 10 May 2012 - 09:01 PM
I will check the issues with gravel if start mining underground, maybe I forgot to check if there is a column or something. It's posible to disable the slots configuration, I don't know the excavate program but it comes with computercraft, no?

Anyway, I been sick all the week, and I can't program anything now…
Sitanel #6
Posted 13 May 2012 - 10:34 PM
Excavate comes with computercraft but has only the radius parameter. I hope you get well soon.
Philips_Cube #7
Posted 23 July 2012 - 11:19 AM
Is it possible to disable the slots configuration and make it similar to the excavate program? A modified version, maybe?

Please make this.
Lasere123456 #8
Posted 29 July 2012 - 02:57 AM
whit this config it just runs strait and then goes to the surface….


-- Min coords:
minX = -180
minY = 10 -- Must be a number divisible by 2!
minZ = 136
--Max coords:
maxX = -100
maxY = 40 -- Must be a number divisible by 2!
maxZ = 56
-- Start / Cargo drop:
homeX= -100
homeY= 40
homeZ= 56
Thecakeguy #9
Posted 04 September 2012 - 01:45 AM
Really great program! But i have a slight problem, my turtle dosent drop the items in the inventory when he goes home to drop them. He just stands still for a second then goes away to his last mined spot and then goes back to the home cords and keeps doing that. Solution?
deactivated1712 #10
Posted 08 September 2012 - 02:11 PM
Add a pastebin :D/>/>
Jason_McRay #11
Posted 08 September 2012 - 11:54 PM
Really great program! But i have a slight problem, my turtle dosent drop the items in the inventory when he goes home to drop them. He just stands still for a second then goes away to his last mined spot and then goes back to the home cords and keeps doing that. Solution?

Same problem for me… I was trying to get some solution myself. I tried to dig around "start/drop" point. But no help. Wanted to look into the program and try to fix it. But then i realized i even don't know how to program a turtle for moving forward x block
I used: "Mining h 0 0 0 s 0 0 0 f 38 0 16" - maybe same Home and Start point is a problem? Will try it tommorow. If it will help, i post in here. If it won't help… well i post it in here anyway :D/>/>
RayceFarelle #12
Posted 13 November 2012 - 01:12 AM
Hey Rodlon, amazing program you've made here :P/>/> I've tested straight away on ssp and smp and it works perfectly. Unfortunately, I do also have the same request as some of the lads here already mentioned, as to whether it is "possible to disable the slots configuration and make it similar to the excavate program". I wouldn't have mind if I was running only computer craft on the server, but with tekkit there are a lot more resources to consider. 9 slots would mean that the rest of the resources would be left out which wouldn't be efficient.

Again, thanks for the great program and I look forward to your response. Keep up the good work.

Best regards.
Modernkennnern #13
Posted 11 December 2012 - 03:56 AM
Add a pastebin ;)/>
25hz #14
Posted 07 October 2013 - 06:47 PM
Exactly what is this?

"%AppData%Roaming.minecraftsavesworldnamecomputercomputerID"

I have an "AppData" folder, as well as "roaming", ".minecraft" and "saves". So what is "worldnamecomputercomputerID"? Is that supposed to be a folder or a file name? Are you even talking about folders at all? Nothing exists under the saves folder and any file I save in there doesn't come up anywhere to use in the turtle script or interface window.

Same goes for this string: "%AppData%Roaming.minecraftmodsComputerCraftluaromprogramsturtle".

Are the percentage signs actually forward slashes? Nothing after "roaming" exists in the directory structure. Are they all supposed to be created individually as folders, as a file name or as a folder name?
Lyqyd #15
Posted 14 October 2013 - 08:54 PM
It's a series of folders. If you don't have any folders under the saves folder, you're looking in the wrong place.
25hz #16
Posted 15 October 2013 - 10:24 PM
So, I got a reply, but already figured out the folder based on posts in other fora where they actually used real directory structure with punctuation. There are no "saves" folders anymore as I reinstalled the client, and am playing primarily on a server - not a single player game. No "saves" folders under the server folders either.

In the server directory structure, there is a "mods" folder and I hand created the children directories under it, including the initial ComputerCraft folder. Did the same under .minecraft.

We're running FTB Ultimate, which has the turtles, and I have spent some time getting, writing and modding some scripts to do some basic things like tree harvesting, refueling with lava, and cutting 3 x 3 and 1 x 3 tunnels (and having the turtles return). The files (without suffixes) containing the lua script are saved in the /programs/turtle folder, but don't show up in any of the turtles when I do a "dir" command. The directory structure is like working in old DOS or Unix/Linux, so I poked around and found a bunch of dirs. and files, but none of the ones I've saved like chimra's. I saved the file in both the client and the server's hand-made directory structure in the "turtle" directory. Even a turtle reboot doesn't locate the file.

EDIT: Ok, with a bunch of trial and error, I found out how to make any turtle program available to all your turtles. I'll post it in a separate thread. http://www.computercraft.info/forums2/index.php?/topic/15605-how-to-make-turtle-programs-available-to-all-turtles/
hockeybuster #17
Posted 16 October 2013 - 07:53 PM
NOTE: Code updated! Two bugfixes and new command with optional arguments to choose the coordinates.
A new update is coming soon, maybe this weekend if I have enough time… it will include, at least:
- Menu to control/configue the program, remotely controlable by a computer server program.
- Real time monitorization of the turtle with external screen (maybe support for several turtles simuntaniously). And with password to sync the turtle with new computer from the distance.
- Persistent variables and autostartup: if you close minecraft or the chunk unloads, the program will auto-continue the task in progres exactly where it was before.
- Eaisier to configure, keeping the command arguments to configurate and new option to skip the menu and mine directly.
- Configure it with minecraft world coordinates (needs a small calibration, once)
- Inverting the Y axis: now will be like the minecraft world.

You can give me some feedback or ideas :)/>/>
——————————————————————-

Hi!
I'm new in computercraft, and this is my firs program for computers(and my first program in lua).

What it does: The turtle digs a hole(configurable measures). You can configure it to only collect specific ores, and when cannot carry more ores of that kind, it comes back to the starting point, empty the slots and goes back to mining.

Changelog:
SpoilerV2:
Comming soon…

V1.1
- Two bugs fixed.
- Added input arguments to configure the home and measures of the mining zone.

v1:
- Initial release.
Instructions:
SpoilerInstallation - Copy the script to your turtle. To do it, you can copy&amp;paste line by line directly to the text editor or…
Goto "%AppData%Roaming.minecraftsavesworldnamecomputercomputerID" and paste the code in a new text file without extension( for example: "miner"). Do it after switch on your turtle.
You also can put that text fie into "%AppData%Roaming.minecraftmodsComputerCraftluaromprogramsturtle" and it will be available for every turtle in your game.

Usage:
1- Put the turtle somewhere, like the picture(ignore the hole xD). switch it on and copy the script:

Note that the Y axis is has the + below and the - above.

2- Configure the variables editing the file(if you want) and put the ores in the slots.
3- Start the program and wait until the program finishes the hole.

You can use the optional arguments:
help -Show how to use the other arguments.
h X Y Z -specficates the home/dropping position(home# variables)
s X Y Z -specficates the final starting(min# variables)
f X Y Z -specficates the final position(max# variables)
Example:miner h 0 0 -1 s -2 0 0 f 2 4 2

How to configure the hole measures:

The program has 9 variables for measures: homeX,homeY,hameZ to specify the actual position of the turtle. This position will be used to drop the ores and as starting position. The other 6 are the measures of the hole, and are relative to the home variables, to make a hole from minX,minY,minZ to maxX,maxY,maxZ. You can use negative coordinates to dig wherever you want to, but be careful of mining your drop location!
It doesn't uses the GPS api, the place you put the turtle will be the coordinates specified with the home variables.
The image above has been done with the default config, so you can imagine how it works :)/>/>

How to configure the slots for each ore:
It is one array, with 9 values, one for each slot. Yo can group the slots, and when the group is full(full stacks of items) the turtle will go to home coordinates.

This default config has 3 groups of 2 slots: slot1+slot2, slot3+slot4, slot5+slot6, slot7, slot8, slot9:

-- Default config with example of materials:
sums[9]=1 -- Diamond(item)
sums[8]=1 -- Gold ore
sums[7]=1 -- Lapislazulli(Item)
sums[6]=2 -- Redstone dust
sums[5]=1 -- Redstone dust
sums[4]=2 -- Iron ore
sums[3]=1 -- Iron ore
sums[2]=2 -- Coal(item)
sums[1]=1-- Coal(item)
I'm not sure how to explain this, but… the number in the variable determinates the numer of slots below to group, included itself. So, with "sums[2]=2" and "sums[1]=1" your are configuring one group formed with the slots 2 and 1. (You need to put "1" instead of "0" even if that slot is alredy in a group), If you want only one group(useful for mining only one kind of items), you can do:

-- Default config:
sums[9]=9 -- Sand
sums[8]=1 -- Sand
sums[7]=1 -- Sand
sums[6]=1 -- Sand
sums[5]=1 -- Sand
sums[4]=1-- Sand
sums[3]=1 -- Sand
sums[2]=1 -- Sand
sums[1]=1 -- Sand
I almost foreget: you need to put in each slot of each group one item to define the kind of item that the groups will contain. You have an example in the example of the config above.

Here is the updated code:
Spoiler

-- Min coords:
minX = 0
minY = 0 -- Must be a number divisible by 2!
minZ = 0
--Max coords:
maxX = 5
maxY = 4 -- Must be a number divisible by 2!
maxZ = 5

-- Start / Cargo drop:
homeX=0
homeY=0
homeZ=-2
-- Slots config
sums = {}
sums[9]=1
sums[8]=1
sums[7]=1
sums[6]=2
sums[5]=1 --
sums[4]=2
sums[3]=1 --
sums[2]=2
sums[1]=1 --

-- Do not change anything below this comment or something could go wrong.

local tArgs = { ... }
term.clear()
term.setCursorPos(1,1)
print("   ---  Mining program  ---")

sums[0]=0
finaliza = false
help = false

function setInicial()
		-- MiddlePass coords
		partX = homeX
		partY = homeY
		partZ = homeZ + 2
		if minZ>homeZ then
				partZ = minZ
		end
		-- Current coords:
		x = homeX
		y = homeY
		z = homeZ
		lado = 1 -- Starting direction. 0=l 1=f 2=r 3=b
		-- last mining coords / mining taring coords:
		xw = minX
		zw = minZ
		yw = minY
		if math.fmod(minY,4) ~= 0 then
				xw = maxX
				zw = maxZ
		end
		ladow = 1
end

function readAndSetArg(num)
		if #tArgs >=num+3 then
				if tonumber(tArgs[num+1]) ~= nil and tonumber(tArgs[num+2]) ~= nil and tonumber(tArgs[num+3]) ~= nil then
						if tArgs[num] == "h" then
								homeX=tonumber(tArgs[num+1])
								homeY=tonumber(tArgs[num+2])
								homeZ=tonumber(tArgs[num+3])
								print("Read home position:  x"..homeX.." y"..homeY.." z"..homeZ)
						elseif tArgs[num] == "s" then
								minX=tonumber(tArgs[num+1])
								minY=tonumber(tArgs[num+2])
								minZ=tonumber(tArgs[num+3])
								print("Read start position: x"..minX.." y"..minY.." z"..minZ)
						elseif tArgs[num] == "f" then
								maxX=tonumber(tArgs[num+1])
								maxY=tonumber(tArgs[num+2])
								maxZ=tonumber(tArgs[num+3])
								print("Read final position: x"..maxX.." y"..maxY.." z"..maxZ)
						end
				end
		end
end
function readArgs()
-- Reads the arguments
		if #tArgs > 0 then
				if tArgs[1] == "help" or tArgs[1] == "Help" then
						print("Usage: miner [help]")
						print("Usage: miner [h X Y Z] [s X Y Z] [f X Y Z]")
						print()
						print("Where 'h' is the home position, 's' is the start position and 'f' is the finish position. And X Y Z are the coordinates.")
						print()
						print("Example:")
						print(" miner h 0 0 -1 s -2 0 0 f 2 4 2")
						help = true
				elseif #tArgs >= 4 then
						readAndSetArg(1)
						readAndSetArg(5)
						readAndSetArg(9)
				end
		end
						setInicial()
end

function askStarting()
		print()
		print("Home position:   x"..homeX.." y"..homeY.." z"..homeZ)
		print("Start position:  x"..minX.." y"..minY.." z"..minZ)
		print("Finish position: x"..maxX.." y"..maxY.." z"..maxZ)
		print()
		print("Are these numbrers correct? [S/Y/N]")
		while true do
				event, param1 = os.pullEvent()
				if event == "char" then
						if param1 == "S" or param1 == "s" or param1 == "Y" or param1 == "y"  then
								print("Ok! Turtle starting...")
								return true
						elseif param1 == "N" or param1 == "n" then
								print("Try again!")
								return false
						end
				elseif event == "key" and param1==28 then
						print("Ok! Turtle starting...")
						return true
				end
		end
		return false
end
function gira(l)
-- Receive an absolute directon and does the propiate turns
		local resta = math.abs(lado -l)
		while lado ~= l do
				if (resta > 2 and lado < l) or (resta <= 2 and lado > l) then
						turtle.turnLeft()
						lado = lado-1
				else  
						turtle.turnRight()
						lado = lado+1
				end
				if lado>3 then
						lado=0
				elseif lado<0 then
						lado=3
				end
		end
end
function movX(tox)
		-- Moves the turle to tox in X axix
		if x > tox then
				gira(0)
		elseif x < tox then
				gira(2)
		end
		while x ~= tox do
				while turtle.detect() do
						turtle.dig()
				end
				turtle.forward()
				if lado == 0 then
						x=x-1
				else
						x=x+1
				end
		end
end
function movY(toy)
		-- Moves the turle to toy in Y axix
		while y < toy do
				if turtle.detectDown() then
						turtle.digDown()
				end
						turtle.down()
						y=y+1;
		end
		while y > toy do
				while turtle.detectUp() do
						turtle.digUp()
				end
				if turtle.up() then
						y=y-1;
				else
						finaliza=true
						break;
				end
		end
end
function movZ(toz)
		-- Moves the turle to toz in Z axix
		if z > toz then
				gira(3)
		elseif z < toz then
				gira(1)
		end
		while z ~= toz do
				while turtle.detect() do
						turtle.dig()
				end
				turtle.forward()
				if lado == 1 then
						z=z+1
				else
						z=z-1
				end
		end
end
function mueveCords(tox,toy,toz,dir)
		-- Moves the turtle to the spcified coords mining everithing in its way.
		modY = 0
		if dir == "home" then
				if y-2 >= toy and y-2 >= minY then
						modY=2
						movY(y-modY)
				end
				-- x:
				movX(tox)
				-- z:
				movZ(toz)
				-- y:
				movY(toy)
		else
				if y <= toy-2 and toy-2 >= minY then
						modY=2;
				end
				movY(toy-modY)
				-- z:
				movZ(toz)
				-- x:
				movX(tox)
				-- y:
				movY(toy)
		end
end
function checkInventario()
-- Checks the slots. If some slot is full, it will go home to drop everihing
		local tmp=9
		local lleno=false
		while tmp >0 do
						if turtle.getItemSpace(tmp) == 0 then
								turtle.select(tmp)
								--if turtle.compare() or turtle.compare() then
										lleno=true
										tmp=0
								--end
						end
						tmp=tmp-sums[tmp]
		end
		if lleno then
		--rednet.open("Right")
				xw=x
				yw=y
				zw=z
				ladow=lado
				goHome()
				descarga()
				goWork()
		end
end
function cava()
-- mine forward and up
		while (turtle.detect() or turtle.detectUp()) and not finaliza do
				cavado=true
				if turtle.detect() then
						if not turtle.dig() then
								finaliza=true
						end
				end
				if turtle.detectUp() then
						if not turtle.digUp() then
								finaliza=true
						end
				end
		end
end
function workX(num)
		-- mine in X axis
		gira(num+1)
		local fin = false
		while not fin and not finaliza do
				if (x > minX and num==-1) or (x < maxX and num==1) then
						checkInventario()
						cava()
						if turtle.forward() then
								x=x+num
						else
								finaliza=true
						end
				else
						fin=true
				end
		end
end
function workZ(num)
		-- mine a entire level
		local fin = false
		while not fin and not finaliza do
				if math.fmod(z,2) == 0 then
						workX(1*num)
				else
						workX(-1*num)
				end
				if (z > minZ and num==-1) or (z < maxZ and num == 1) then
						gira(2-num)
						cava()
						if turtle.forward() then
								z = z+num
						else
								finaliza=true
						end
				else
						fin = true
				end
		end
end
function goHome()
-- Go to home coords
		mueveCords(partX,partY,partZ,"home")
		mueveCords(homeX,homeY,homeZ,"home")
end
function descarga()
		-- Drops everithing but 1 block
		print("Dropping items...")
		local tmp2=9
		while tmp2 > 0 do
  turtle.select(tmp2)
		if turtle.getItemCount(tmp2) > 0 then
				turtle.drop(turtle.getItemCount(tmp2)-1)
				end
				tmp2=tmp2-1
		end
end
function goWork()
		-- Moves the turtle to the last mining coordinates
		mueveCords(partX,partY,partZ,"work")
		mueveCords(xw,yw,zw,"work")
		gira(ladow)
end
function mineria()
-- Starts everithing.
		print("Starting from x:"..minX.." y:"..minY.." z:"..minZ)
		print("To x:"..maxX.." y:"..maxY.." z:"..maxZ)
		goWork()
		checkInventario()
		while y <= maxY and not finaliza do
				if math.fmod(y/2,2) == 0 then
						workZ(1)
				else
						workZ(-1)
				end
				if y < maxY and not finaliza then
						turtle.digUp()
						turtle.digDown()
						if  turtle.down() then
								y=y+1
						else
								finaliza=true
						end
						turtle.digUp()
						turtle.digDown()
						if turtle.down() and not finaliza then
								y=y+1
						else
								turtle.digUp()
								finaliza=true
						end
				else
						maxY=maxY-1
				end
		end
end

readArgs()
if not help then
		if askStarting() then
		mineria()
		if finaliza then
				print("Something went wrong...(bedrock?player?mob?)")
		else
				print("Finish!!")
		end
		goHome()
		descarga()
		gira(1)
		end
end
-- By RODLON


Here is the outdatd code without command arguments and two bugs:
Spoiler

-- Min coords:
minX = 0
minY = 0 -- Must be a number divisible by 4!
minZ = 0
--Max coords:
maxX = 5
maxY = 4 -- Must be a number divisible by 4!
maxZ = 5
-- Start / Cargo drop:
homeX=0
homeY=0
homeZ=-1
-- Slots config
sums = {}
sums[9]=1
sums[8]=1
sums[7]=1
sums[6]=2
sums[5]=1 --
sums[4]=2
sums[3]=1 --
sums[2]=2
sums[1]=1 --
sums[0]=0
-- Do not change anything below this comment or something could go wrong.
-- MiddlePass coords
partX = homeX
partY = homeY
partZ = homeZ + 2
if minZ>homeZ then
partZ = minZ
end
-- Current coords:
x = homeX
y = homeY
z = homeZ
lado = 1 -- Starting direction. 0=l 1=f 2=r 3=b
-- last mining coords / mining taring coords:
xw = minX
yw = minY
zw = minZ
if math.fmod(minY,4) ~= 0 then
	xw = maxX
	zw = maxZ
end
ladow = 1
finaliza = false
function gira(l)
-- Receive an absolte directon and does the propiate turns
local resta = math.abs(lado -l)
while lado ~= l do
  if (resta > 2 and lado < l) or (resta <= 2 and lado > l) then
   turtle.turnLeft()
   lado = lado-1
  else
   turtle.turnRight()
   lado = lado+1
  end
  if lado>3 then
   lado=0
  elseif lado<0 then
   lado=3
  end
end
end
function movX(tox)
-- Moves the turle to tox in X axix
if x > tox then
  gira(0)
elseif x < tox then
  gira(2)
end
while x ~= tox do
  while turtle.detect() do
   turtle.dig()
  end
  turtle.forward()
  if lado == 0 then
   x=x-1
  else
   x=x+1
  end
end
end
function movY(toy)
-- Moves the turle to toy in Y axix
while y < toy do
  if turtle.detectDown() then
   turtle.digDown()
  end
   turtle.down()
   y=y+1;
end
while y > toy do
  while turtle.detectUp() do
   turtle.digUp()
  end
  turtle.up()
  y=y-1;
end
end
function movZ(toz)
-- Moves the turle to toz in Z axix
if z > toz then
  gira(3)
elseif z < toz then
  gira(1)
end
while z ~= toz do
  while turtle.detect() do
   turtle.dig()
  end
  turtle.forward()
  if lado == 1 then
   z=z+1
  else
   z=z-1
  end
end
end
function mueveCords(tox,toy,toz,dir)
-- Moves the turtle to the spcified coords mining everithing in its way.
modY = 0
if dir == "home" then
  if y-2 >= toy and y-2 <= minY then
   modY=2
  end
  -- x:
  movX(tox)
  -- z:
  movZ(toz)
  -- y:
  movY(toy)
else
  if y <= toy-2 and toy-2 >= minY then
   modY=2;
  end
  movY(toy-modY)
  -- z:
  movZ(toz)
  -- x:
  movX(tox)
  -- y:
  movY(toy)
end
end
function checkInventario()
-- Checks the slots. If some slot is full, it will go home to drop everihing
local tmp=9
local lleno=false
while tmp >0 do
   if turtle.getItemSpace(tmp) == 0 then
	turtle.select(tmp)
	--if turtle.compare() or turtle.compare() then
	 lleno=true
	 tmp=0
	--end
   end
   tmp=tmp-sums[tmp]
end
if lleno then
--rednet.open("Right")
  xw=x
  yw=y
  zw=z
  ladow=lado
  goHome()
  descarga()
  goWork()
end
end
function cava()
-- mine forward and up
while (turtle.detect() or turtle.detectUp()) and not finaliza do
  cavado=true
  if turtle.detect() then
   if not turtle.dig() then
	finaliza=true
   end
  end
  if turtle.detectUp() then
   if not turtle.digUp() then
	finaliza=true
   end
  end
end
end
function workX(num)
-- mine in X axis
gira(num+1)
local fin = false
while not fin and not finaliza do
  if (x > minX and num==-1) or (x < maxX and num==1) then
   checkInventario()
   cava()
   if turtle.forward() then
	x=x+num
   else
	finaliza=true
   end
  else
   fin=true
  end
end
end
function workZ(num)
-- mine a entire level
local fin = false
while not fin and not finaliza do
  if math.fmod(z,2) == 0 then
   workX(1*num)
  else
   workX(-1*num)
  end
  if (z > minZ and num==-1) or (z < maxZ and num == 1) then
   gira(2-num)
   cava()
   if turtle.forward() then
	z = z+num
   else
	finaliza=true
   end
  else
   fin = true
  end
end
end
function goHome()
-- Go to home coords
mueveCords(partX,partY,partZ,"home")
mueveCords(homeX,homeY,homeZ,"home")
end
function descarga()
-- Drops everithing but 1 block
print("Dropping items...")
local tmp2=9
while tmp2 > 0 do
  turtle.select(tmp2)
if turtle.getItemCount(tmp2) > 0 then
  turtle.drop(turtle.getItemCount(tmp2)-1)
  end
  tmp2=tmp2-1
end
end
function goWork()
-- Moves the turtle to the last mining coordinates
mueveCords(partX,partY,partZ,"work")
mueveCords(xw,yw,zw,"work")
gira(ladow)
end
function mineria()
-- Starts everithing.
goWork()
checkInventario()
while y < maxY and not finaliza do
  if math.fmod(y/2,2) == 0 then
   workZ(1)
  else
   workZ(-1)
  end
  if y < maxY and not finaliza then
   turtle.digUp()
   turtle.digDown()
   if  turtle.down() then
	y=y+1
   else
	finaliza=true
   end
   turtle.digUp()
   turtle.digDown()
   if turtle.down() and not finaliza then
	y=y+1
   else
	finaliza=true
   end
  end
end
end
mineria()
if finaliza then
print("Something went wrong...(bedrock?)")
else
print("Finish!!")
end
goHome()
descarga()
gira(1)
-- By RODLON

Maybe my english is bad, but I'm learning :)/>/>
Cool program :)/>