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

A simple Strip Mining Program [GRAVEL PROOF]

Started by Daniel_Kerman, 25 July 2015 - 06:28 PM
Daniel_Kerman #1
Posted 25 July 2015 - 08:28 PM
Hey Guys!

I programmed a program (How obvious).
The mining is variable by the user.
It will place torches if you put some in slot 16.

Downloads:
Version 1.0.5: http://pastebin.com/wuNdXM6w
Enter this in your turtle to download the program.
pastebin get wuNdXM6w stripmine

Images:
SpoilerProgram startup interface:

Changelogs:
SpoilerVersion 1.0.5:
- Fixed Bugs
- Source code improved

Known Bugs:
Spoiler- If entities stand in front of the moving turtle, the turtle will overwrite the distance. - FIXED with help from user Foogles

Planned:
SpoilerGreen: In Developement | Yellow: Prepared | Red: Planned for the Future | Blue: Nearly Done
- A complete rewrite of the source code with an own API.
- A turtle OS for better looks. –> http://www.computerc...__fromsearch__1
- Rednet Feature to stream the status on a monitor/computer.

Special Thanks:
Spoiler- Foogles, for helping me out with a bug.

Please report bugs to danielthekerbal22@gmail.com
Help is always well-deemed and every person that helps with my program gets a Credit in my post. (Usually in "Special Thanks")

With kind regards,
Daniel_Kerman
Edited on 17 August 2015 - 01:21 PM
Foogles #2
Posted 28 July 2015 - 03:56 PM
Hello Daniel. Your program looks great! It's a few ballparks ahead of mine in sophistication XD

First off, thank you for sharing it. I'm looking forward to installing it to my legion of turtles in survival. (4 turtles, a small legion)

I was looking at your Known Bugs spoiler and noticed that you had an issue I used to have with my simpler mining program.
When an entity stands in front of the turtle, it doesn't move forward but it thinks it did, so it doesn't go as far as it is supposed to.
Maybe you'd like to know how I resolved it in my program?

SpoilerInitially I did something similar to you (dig, forward, digup <you do digdown>).
Then I realized that by calling this from my mine/dig function, I was screwing up the distance that the turtle was mining,
which in turn affected where it came back to on the return sequence.

Because turtle.forward() returns a boolean for success/fail, you can call a method to mine and move forward again if it fails.
In order to save time and space, I wrote a short and simple tail-calling function for my own code to fix it:


function Continue()
  turtle.dig()
  local x = turtle.forward()
  turtle.digUp() --Here you would do turtle.digDown()
  if (x == false) then
    return Continue()
  end
end

So I call this method once per time that I intend to move the turtle forward.
If it fails to move forward, then it will repeat the steps, mining forward and then moving forward.
This function handles keeping count when any entity or falling block obstructs its path.

One thing to note is sometimes it is able to move past falling gravel before it lands, leaving it's path obstructed.
That is why I also use Continue() in my Return() function.
Edited on 29 July 2015 - 08:37 PM
Daniel_Kerman #3
Posted 14 August 2015 - 05:48 PM
Hello Daniel. Your program looks great! It's a few ballparks ahead of mine in sophistication XD

First off, thank you for sharing it. I'm looking forward to installing it to my legion of turtles in survival. (4 turtles, a small legion)

I was looking at your Known Bugs spoiler and noticed that you had an issue I used to have with my simpler mining program.
When an entity stands in front of the turtle, it doesn't move forward but it thinks it did, so it doesn't go as far as it is supposed to.
Maybe you'd like to know how I resolved it in my program?

SpoilerInitially I did something similar to you (dig, forward, digup <you do digdown>).
Then I realized that by calling this from my mine/dig function, I was screwing up the distance that the turtle was mining,
which in turn affected where it came back to on the return sequence.

Because turtle.forward() returns a boolean for success/fail, you can call a method to mine and move forward again if it fails.
In order to save time and space, I wrote a short and simple tail-calling function for my own code to fix it:


function Continue()
  turtle.dig()
  local x = turtle.forward()
  turtle.digUp() --Here you would do turtle.digDown()
  if (x == false) then
	return Continue()
  end
end

So I call this method once per time that I intend to move the turtle forward.
If it fails to move forward, then it will repeat the steps, mining forward and then moving forward.
This function handles keeping count when any entity or falling block obstructs its path.

One thing to note is sometimes it is able to move past falling gravel before it lands, leaving it's path obstructed.
That is why I also use Continue() in my Return() function.

Sorry, that I didn't read your post until yet! I had holidays for five weeks and was very inactive.

Well, I feel a little bit dumb now, because of that simple solution but thank you very much for the help! I will make a little Credit for you in my program so you don't feel used.

print("Have a nice day! \nDaniel Kerman")
Edited on 14 August 2015 - 04:05 PM
Hawkertech #4
Posted 15 September 2015 - 07:48 AM
anyway to make this work on servers that dont require fuel?
Aylin94 #5
Posted 19 October 2015 - 06:02 PM
Hello Daniel.

I have a problem with running your program. To be honest, I don't have much experience with turtles, except for excavation and tunnel. Only used one other program (from someone else) before I found this link.

I can't run the stripmine program. It always says stripmine:15: attempt to call nil

Spoiler

Am I doing something wrong? I can edit stripmine, so the loading didn't seem to went wrong.
Lyqyd #6
Posted 19 October 2015 - 08:06 PM
What version of ComputerCraft are you using? It is likely prior to turtle.getFuelLimit being implemented.
Bomb Bloke #7
Posted 19 October 2015 - 10:42 PM
… in which case, substituting "turtle.getFuelLimit()" with "math.huge" should sort it out.
Aylin94 #8
Posted 25 October 2015 - 10:19 AM
What version of ComputerCraft are you using? It is likely prior to turtle.getFuelLimit being implemented.
I am using the modpack Ultimate (the recommended version). Don't know where to find which version of ComputerCraft it is using
mineturtl3 #9
Posted 28 March 2017 - 02:12 AM
I typed this up and I got bios:14: [string "strip"]:12: '=' expected
Bomb Bloke #10
Posted 28 March 2017 - 05:57 AM
Most odd; I don't believe the script provided could throw that particular error. Assuming you've quoted it correctly, I recommend deleting and then redownloading the original file.