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

[Lua]Working on a turtle Quarry but i'm stuck now

Started by TheDarkVoid, 31 December 2012 - 01:24 PM
TheDarkVoid #1
Posted 31 December 2012 - 02:24 PM
So i'm making a turtle quarry that will be able to mine an area of space i define, it uses 2 chests one for drop off, and the other for getting fuel.
Here is the code i have: http://pastebin.com/2mA6AMRK
I'm not sure why it's not working, i really confused as to why the turtle is going in strange directions and also sometimes continueing in a direction in-defiantly. i'm not that great with lua, I'm much more used to c#…
To my understanding of lua it should not be doing these things but it is. can you guys take a look at it and tell me what i'm doing wrong.

The turtle should mine the 5x5 red area when set to 5x5 but as you can see by the mess it's doesn't
The top chest is the fuel chest, the bottom is the drop off.
The turtle faces the home chest initially
the block the turtle is in is "home".
I hope you guys can help me.



Edit: The link has been updated with the edited code.
Here are the problems i'm currently experiencing, all the mining is working correctly but the problem i have is with resuming, after the turtle's inventory is full, the way I have right not is not working at all, in some cases it would get the turtle back to the right spot but from there it breaks, any suggestions.
Edited on 01 January 2013 - 12:57 PM
KaoS #2
Posted 31 December 2012 - 07:29 PM
while taking a cursory look at your code I notice that you are calling functions like checkFuel() before you have defined the function… this will cause errors
ChunLing #3
Posted 31 December 2012 - 11:07 PM
Actually not, because all the functions are global scope and the start function doesn't get called until after all of them have been defined.

But that's still not best practice for CC programming. When you get more advanced, you are going to want to be able to run programs from inside other programs, and defining all your functions globally is going to cause you problems.

Your movement and tracking systems are pretty cumbersome, if we're going to be very helpful you should describe exactly what you think the turtle should be doing and exactly what it's doing instead.

You can also intersperse some more debug prints in the move and turn functions, and tell us what they say. That might let you track this down yourself.
TheDarkVoid #4
Posted 01 January 2013 - 05:47 AM
I'll try that, as i work on it today
TheDarkVoid #5
Posted 01 January 2013 - 01:59 PM
I've updated the post with the new situation, the digging and everything has been solved all thats left is the resume, i have no idea of how to go about doing it so this is really a challenge. Hope you guys can point me in the right direction.
ChunLing #6
Posted 02 January 2013 - 02:41 AM
It really would help you a lot to make your functions local and arrange them by dependency (those that do not require the other functions being defined first).

Also, insert some prints in all areas of conditional execution so that you know whether or not those chunks are being executed. Also, have a print somewhere that periodically outputs the current values of your variables, particularly those that track position/facing. You will be able to get (and relay to us) a far better idea of what is going on.
TheDarkVoid #7
Posted 02 January 2013 - 07:09 AM
Yea, i'll do that