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

Volcano/Taint block Remover

Started by Falk, 01 November 2012 - 11:24 PM
Falk #1
Posted 02 November 2012 - 12:24 AM
Tekkit mod. No idea of the CC version - most recent I assume since the turtle has 16 inventory slots.

Place a single item (or a stack – all the same to me) in slot 1 of the turtle. It will mine# that block exclusively*, leaving everything* else unmolested.

I made this to clear the basalt left behind once you're done pumping out volcanoes in Tekkit without damaging the underlying topography. Its utility beyond this and removing taint blocks (if you're using Thaumcraft) is limited.

Until this afternoon, I'd not heard of LUA, so if you have any pointers, please share. Based on Lettuce's improved land clearing program.

Note that it gets a bit flustered if it tries to work over a ravine. I'd fix it, but (a) I don't have any ravines that I need to worry about clearing and (:D/>/> I'm lazy.

Note that I don't use fuel in my turtles.

Spoiler
x=0
y=0
z=0 --[this is called globally because it's used and shared in all subs; it is used to return the turtle to ground level after completing its task.]--
function forward()
local count = 0
repeat
turtle.select(1)
if turtle.compare() then
  turtle.dig()
else
  if turtle.detect() then
   while turtle.detectUp() do
	turtle.back()
   end
   turtle.up()
   z = z + 1
  end
end
until turtle.forward()
for count=0,3 do
  turtle.select(1)
  if turtle.compare() then
   turtle.dig()
  end
  turtle.turnLeft()
end
--[The turtle will check if the block in front of it is the target blocktype and mine it if it is. If it is a nontarget block, the turtle will reverse until it is able to climb a level]--
end
function up()
turtle.select(1)
local alt=0
local count=0
repeat
  if turtle.detectUp() then
   turtle.digUp()
   turtle.up()
  else
   turtle.up()
   alt=alt+1
   z=z+1
  end
   --[If the turtle has free air above it, it will ascend. It will increment 'alt' only when it ascends in free air. If it does not have free air, it will break the block above it (no matter the block) and move up. This behaviour is to help it escape caves, if required.]--
  for count=0,3 do
   turtle.select(1)
   if turtle.compare() then
	alt=0
	turtle.dig()
   end
   turtle.turnLeft()
  end --[the turtle will check each facing for target blocks. If it finds one, it will mine it and set 'alt' to zero.]--
  if alt==2 then
   turtle.down()
   turtle.down()
   z=z-2
  end
until alt==2 --[if the turtle has gone up through free air 3 blocks and found no minable blocks or is sitting under a non-target block, it will end the sub.]--
end
function down()
local cave = 0
local count = 0
repeat
  if turtle.detectDown() then
   turtle.select(1)
   if turtle.compareDown() then
	turtle.digDown()
   end
  else
   turtle.down()
   if turtle.compareDown() then
	turtle.digDown()
   end
   z = z - 1
   cave = cave + 1
   if cave == 3 then
	for count=0,4 do
	 turtle.up()
	 z=z+1
	end
	break --[If turtle thinks it's in a cave, it'll go back to the last known surface and quit the sub, returning to the For loop at forward()]--
   end
  end
  for count = 0,3 do
   turtle.select(1)
   if turtle.compare() then
	turtle.dig()
	cave = 0
   end
  turtle.turnLeft()
  end
  --[If the turtle finds target blocks on any of its 4 facings, it will mine them and reset the 'cave' counter to zero. Suspect it will check twice for every downward movement.]--
until turtle.detectDown() --[Ends the sub (if it hasn't been ended by being in a cave) when the turtle is sitting on a block.]--
end
print "Width (chunk is 16)"
x = tonumber(read())
print "Depth (chunk is 16)"
y = tonumber(read())
print "And we're off. If your code doesn't work as intended, I'll be mining the clouds."
os.pullEvent("key")
leftright = "left" --[global because it's used in the harness.]--
x=x/2
y=y/2
--[since the turtle moves forward twice for each iteration of the loop]--
for count = 1,x do
for notcount = 1, y do
  down()
  forward()
  up()
  forward()
end
if leftright=="right" then
  turtle.turnRight()
  forward()
  forward()
  forward()
  turtle.turnRight()
  leftright="left"
else
  turtle.turnLeft()
  forward()
  forward()
  forward()
  turtle.turnLeft()
  leftright="right"
end

end --[Will run the turtle down until it hits a non-target block or a cave, advance it one block, run it up until alt=3 or non target block, forward and repeat. 'If' statement should make the turtle alternate left-right turns at end of y-rows.]--
repeat
if z>0 then
  turtle.down()
else
  turtle.up()
end
until z == 0

#: chew up and spit out.

*: unless it's trying to move up. Then it smashes everything, since I got sick of chasing it through caves.
Lemmypemmy #2
Posted 21 March 2013 - 02:06 AM
Nice program
oxgon #3
Posted 06 April 2013 - 06:04 PM
can't get this to work