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

Simple stair mining program (Handles sand/gravel as well)

Started by rob5251, 26 December 2012 - 07:20 AM
rob5251 #1
Posted 26 December 2012 - 08:20 AM
This is just a fairly simple stairs program I made up to dig stairs, feel free to mess around with it and modify it for your needs.
(This is my first program :)/>)

Features:

-The program digs stairs going down as far as the user inputs.
-Detects if sand or gravel has fallen on it's head (good for if you are using this in a desert) also handles sand/gravel that falls in front of it.
-The stairs it digs leaves a four block high clearance.

Code:
SpoilerAlso available at:
http://pastebin.com/9E7Tmgrj


--Ask the user how far to go

print("How far?")

--Take input from the user
--and make dist equal to it

dist = read()

--Starting program...
--Detect if something is above
--if so then dig it
--(to handle gravel/sand)

function dSand()

while turtle.detectUp() do
  turtle.digUp()
	sleep(0.50)
	  end
end

dSand()	
turtle.digDown()

--Add +1 till dist is met
--As long as dist is not met do
--what follows

for i = 1, dist do

--Call function to handle sand if it
--falls on top of the turtle during operation

dSand()
	
turtle.dig()
  
--This handles sand/gravel infront
--of the turtle

  while not turtle.forward() do
	turtle.dig()
	  end
	
dSand()

	turtle.digDown()
	turtle.down()
	turtle.digDown()
end

Example of what this program does in-game (minus the torch placement of course):
Spoiler

For simple in-game installation just type/paste this in:

pastebin get 9E7Tmgrj <SaveFileAs>

ex)
pastebin get 9E7Tmgrj stairs


*NOTE:

Make sure your HTTP API is enabled. :P/>
Jack #2
Posted 27 December 2012 - 06:00 AM
This is nice. It's simple and straightforward and useful. Well done.