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

Help finishing mining program

Started by Minixiri, 27 December 2012 - 05:13 AM
Minixiri #1
Posted 27 December 2012 - 06:13 AM
right now i have this:

local function compare()
turtle.select(2)
a = turtle.compare()
turtle.select(3)
b = turtle.compare()
turtle.select(4)
c = turtle.compare()
turtle.select(5)
d = turtle.compare()
turtle.select(6)
e = turtle.compare()
end

local function block()
compare()
while a or b or c or d or e do
turtle.dig()
compare()
end
end

local function row()
for i=1,2 do
block()
turtle.up()
end
block()
turtle.down()
turtle.down()
end

local function section()
for i=1,2 do
row()
turtle.turnRight()
turtle.forward()
turtle.turnLeft()
end
row()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnRight()
end

for i=1,5 do
section()
turtle.forward()
end

and what i want to do is to add a return function by counting how many sections it made and to make it do it if it encounters any ore, or even better do go around the ore and keep going, not sure if it is possible
Archimedes #2
Posted 27 December 2012 - 01:31 PM
Put it in pastebin and indent it so we can see it better.
ChunLing #3
Posted 27 December 2012 - 03:51 PM
It's certainly possible. There are a variety of programs on the Turtle Programs forum that are designed to do this kind of thing. You should look them over.
Minixiri #4
Posted 27 December 2012 - 05:35 PM
is this what you mean by pastebin and indent? http://pastebin.com/NpFdK1tJ sorry i'm a newbie at this

<script src="http://pastebin.com/embed_js.php?i=NpFdK1tJ"></script>


i changed a few things because of gravel issues, just made the turtle go from up to down instead.

i already been looking at the forums but most programs are to collect ores, and i want the exact opposite. Besides they seem to use gps and i dont know how that works. the code i did was basically made from trial and error after watching LP from FTB packs and trying to figure it out.
Luanub #5
Posted 27 December 2012 - 05:42 PM
You dont really need to put it on pastebin(which is a site that people share their scripts on) its best to just put code tags [*code][*/code] without the * (spoiler tags as well for larger scripts) around the code.

Indentation is like this…


local function row()
for i=1,2 do
  block()
  turtle.up()
end
block()
turtle.down()
turtle.down()
end

There's very little room for indentation in your scripts. It is mainly used for if statements, loops etc to make it easier to tell where they start and where they end.
Minixiri #6
Posted 27 December 2012 - 05:47 PM
i edited and got it :D/> not sure how to make it appear on post though
ChunLing #7
Posted 27 December 2012 - 10:51 PM
use code tags, [CODE] your code goes here [/CODE], or just click the little <> icon to bring up the code entry window and paste your code into it.
Minixiri #8
Posted 28 December 2012 - 01:50 AM

	local function compare()
			turtle.select(2)
			a = turtle.compare()
			turtle.select(3)
			b = turtle.compare()
			turtle.select(4)
			c = turtle.compare()
			turtle.select(5)
			d = turtle.compare()
			turtle.select(6)
			e = turtle.compare()
	end
	
	local function block()
			compare()
			while a or b or c or d or e do
			turtle.dig()
			compare()
			end
	end
	
	local function row()
			for i=1,2 do
					block()
					turtle.down()
			end
			block()
			turtle.up()
			turtle.up()
	end
	
	local function section()
			for i=1,2 do
					row()
					turtle.turnRight()
					turtle.forward()
					turtle.turnLeft()
			end
			row()
			turtle.turnLeft()
			turtle.forward()
			turtle.forward()
			turtle.turnRight()
	end
	
	for i=1,5 do
	section()
	turtle.forward()
	end