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

Strip mining program unstable

Started by iWantcoal, 13 December 2013 - 07:46 PM
iWantcoal #1
Posted 13 December 2013 - 08:46 PM
<This might not be something that belongs in this forum>

Recently in a server I play on, quarries and other mining structs are disabled, so I hugged onto computercraft for lazy mining…

I first wrote a simple script to mine tunnels in a spiral formation, but ended up making it auto-harvest the ores by including a sub-program by GOPHERATL (linked to TurleX thread for copyright requirements) which I modified.

The problem is after successfully returning to home a few times, the turtle started drifting off course after mining a vein of ore sometimes, and I spent loads of time trying to fix it–didn't work a bit.

The code

(I'm not sure if "ask a pro" accept questions like this)

To debug:
Place the turtle underground;
Put an ender chest in the first slot, fuel in third slot, and block samples to ignore from slot 4+;
Refuel the turtle manually before the first time using it;
When it asks you the "ignore value", enter the amount of samples you put in;
Supervise the turtle from above.

When it hits a large vein, it usually returns to one block above the block it started digging in, causing the tunnel to slowly shift upwards, sometimes it may shift dramatically sideways as well. Though it has never shifted upwards, which is interesting.
Ajt86 #2
Posted 14 December 2013 - 01:41 AM
If you keep a record of the x y z coordinates and it's orientation by for example saying that the turtle was placed at (0,0,0,0) well you could rewrite your method to make the turtle go back to the last place it was. For example when you call the method it registers a last mine position and then tries to head back to it. If it knows two positions, get it to think it is at one of the positions and you can make it go to the other. If that's not working for you you could try to check which part it's failing or register every movement of the turtle (which I don't recommend). If it's still not working then maybe sometimes the turtle is offset in it's position because you're not "getting rid" of the block infront. If you don't want to break the block infront, there is another way, the methods inside the turtle API return a boolean (true or false) so if inside your method, the boolean results to true, then change the coordinates of the turtle. For now I cannot think of any other solutions to help you, sorry if none of these work.
iWantcoal #3
Posted 17 December 2013 - 11:33 PM
If you keep a record of the x y z coordinates and it's orientation by for example saying that the turtle was placed at (0,0,0,0) well you could rewrite your method to make the turtle go back to the last place it was. For example when you call the method it registers a last mine position and then tries to head back to it. If it knows two positions, get it to think it is at one of the positions and you can make it go to the other. If that's not working for you you could try to check which part it's failing or register every movement of the turtle (which I don't recommend). If it's still not working then maybe sometimes the turtle is offset in it's position because you're not "getting rid" of the block infront. If you don't want to break the block infront, there is another way, the methods inside the turtle API return a boolean (true or false) so if inside your method, the boolean results to true, then change the coordinates of the turtle. For now I cannot think of any other solutions to help you, sorry if none of these work.

Thank you for the reply but the auto return script is already embedded in the mine vein function, and from my testing it returns to the exact position and facing every time when I test it alone. What I'm having trouble is probably the main code interfering with the ore function, making it unable to finish, or the going forward part messing up with height data…