Posted 11 December 2015 - 08:48 PM
I tried to write a strip mining program for a mining turtle, and it's making really weird errors.
The errors are so strange, that I think it might be a bug with computercraft, rather than my own code. I am by no means an experienced programmer though, so I figured I'd ask for some help here.
This is my code.
I didn't comment the code, so here's how my code works:
The goal is for it to dig a branch-/strip-mine, with two non-dug blocks between each branch, similar to this layout.
This is the procedure I tried to implement:
- dig forward three blocks
- turn left
- dig leng blocks (leng being a variable equal to 10)
- turn around and move back leng blocks
- dig leng blocks again (this time to the right)
- turn around and move back leng blocks again
- turn right
- rinse and repeat
The function OneForward() should dig forward a 2x1x1 chunk.
The while-loops on line 6 and 10 are to check for falling gravel/sand.
The function digleng() should excecute OneForward() leng times, and then walk back leng blocks.
Here's what goes wrong:
The errors aren't regular at all, but what I've seen happen most of the time is that it digs the first one or two rows (left and right) perfectly, but then on one of its digs fails to return all the way to the center, and turns in the middle of the branch and continues digging in the forward direction. The result is a jagged mine that looks something like this.
Sometimes it does weirder or messier things though.
Here's what I've tried:
I've tried walking directly behind it while it runs, if it was an issue with not loading when too far away from the player.
I've tried standing completely still while it runs.
I've tried reducing leng from 10 to 3.
I've tried testing it on a mound of player placed dirt and cobble blocks above ground.
Thinking it might be an issue with the low-power server I made it on, I tried it in single player creative as well.
Obviously none of them did the trick, they all yielded the same errors.
The weirdest thing is that the code can execute an entire row fine, and then screw up on the next one. It seems to me that it would be excecuting the same code. This is what leads me to believe it might be an issue with computercraft.
I don't run the latest version of computercraft, I run the latest version of tekkit (via the technic launcher), which only has computercraft v1.58.
I was really hyped at the idea of having an empire of turtles working for me on our server, so this first test not working is a huge bummer for me.
Any help is much appreciated.
Thanks in advance.
The errors are so strange, that I think it might be a bug with computercraft, rather than my own code. I am by no means an experienced programmer though, so I figured I'd ask for some help here.
This is my code.
I didn't comment the code, so here's how my code works:
The goal is for it to dig a branch-/strip-mine, with two non-dug blocks between each branch, similar to this layout.
This is the procedure I tried to implement:
- dig forward three blocks
- turn left
- dig leng blocks (leng being a variable equal to 10)
- turn around and move back leng blocks
- dig leng blocks again (this time to the right)
- turn around and move back leng blocks again
- turn right
- rinse and repeat
The function OneForward() should dig forward a 2x1x1 chunk.
The while-loops on line 6 and 10 are to check for falling gravel/sand.
The function digleng() should excecute OneForward() leng times, and then walk back leng blocks.
Here's what goes wrong:
The errors aren't regular at all, but what I've seen happen most of the time is that it digs the first one or two rows (left and right) perfectly, but then on one of its digs fails to return all the way to the center, and turns in the middle of the branch and continues digging in the forward direction. The result is a jagged mine that looks something like this.
Sometimes it does weirder or messier things though.
Here's what I've tried:
I've tried walking directly behind it while it runs, if it was an issue with not loading when too far away from the player.
I've tried standing completely still while it runs.
I've tried reducing leng from 10 to 3.
I've tried testing it on a mound of player placed dirt and cobble blocks above ground.
Thinking it might be an issue with the low-power server I made it on, I tried it in single player creative as well.
Obviously none of them did the trick, they all yielded the same errors.
The weirdest thing is that the code can execute an entire row fine, and then screw up on the next one. It seems to me that it would be excecuting the same code. This is what leads me to believe it might be an issue with computercraft.
I don't run the latest version of computercraft, I run the latest version of tekkit (via the technic launcher), which only has computercraft v1.58.
I was really hyped at the idea of having an empire of turtles working for me on our server, so this first test not working is a huge bummer for me.
Any help is much appreciated.
Thanks in advance.