Jump to content




Tunnel... (Default program.)


  • You cannot reply to this topic
5 replies to this topic

#1 Lost Ninja

  • Members
  • 39 posts

Posted 16 October 2012 - 09:26 AM

Newish user of CC here, done a bit of programming in the past some of it with lua so can read the structure of a program even if I don't quite get what is going on 100%. Been playing with the default (included) Tunnel program trying to get a couple more features into it. Specifically a RTB feature that in the original is commented out. I got it to work but am having issues with fueling. Can anyone give me some help?

Spoiler
((Apologies for all the eroneous comments they're mostly to make it clear to me what I'm doing...))
http://pastebin.com/xJ7VMe40

I thought by using the tryForward function that would handle the fuelling as it does in the rest script but it still runs out of fuel. Next I figured I could just call the refuel function (which works) but if the turtle is either a long way off (100+) it still stops short of the full RTB, while if it's close it wastes the fuel when it is inevitably broken to reposition.

While any help is of course appreciated I'd really appreciate if you don't suggest adding an additional API because I'd much rather get it working with just the code you start out with.

#2 Ditto8353

  • New Members
  • 138 posts

Posted 16 October 2012 - 02:07 PM

I suggest you start writing the program from scratch. You will be able to easily understand what all of the code does and you can improve on algorithms where needed. The original code could work as a handy reference, but adding new features to code that isn't yours is always a pain.

Note: A more efficient digging algorithm starts bottom center and turns to the side. It digs out the side while it digs up, then turns around and moves down while it digs out the other side.

#3 Lost Ninja

  • Members
  • 39 posts

Posted 16 October 2012 - 02:14 PM

View PostDitto8353, on 16 October 2012 - 02:07 PM, said:

I suggest you start writing the program from scratch. You will be able to easily understand what all of the code does and you can improve on algorithms where needed. The original code could work as a handy reference, but adding new features to code that isn't yours is always a pain.
I'll give it a shot but don't think I understand the turtle well enough to mange it.

Quote

Note: A more efficient digging algorithm starts bottom center and turns to the side. It digs out the side while it digs up, then turns around and moves down while it digs out the other side.
Which is the way I had it to start with - crap coder I may be, stupid... I am too... :D/> - However I want the floor added in too, eventually I'll have it add walls/ceiling. Seems that the only block it doesn't need to travel through is the centre block, hence the way I have it set up now. I would prefer a more adaptable method for working this out so I could handle bigger tunnels... but that will come as I gain more confidence... maybe. :P/>

TY for the help anyway.

#4 Ditto8353

  • New Members
  • 138 posts

Posted 16 October 2012 - 02:40 PM

View PostLost Ninja, on 16 October 2012 - 02:14 PM, said:

I'll give it a shot but don't think I understand the turtle well enough to mange it.
...
TY for the help anyway.

Just play around with it for a bit. Learn the use of for loops like the back of your hand and you should have all the tools you need. The hardest part of turtles I have run into is dealing with variable dimensions for tunneling and tracking relative positions without GPS so the turtle knows how to get home.

Good luck!

#5 Lost Ninja

  • Members
  • 39 posts

Posted 16 October 2012 - 09:14 PM

Digging a straight tunnel as long as each full clear (that is the cross section) has the turtle end in the same spot (or a spot you know beforehand) getting back to the start is just a matter of recording how far 'in' it's dug. That's the easy bit. Knowing the the rest is where I get stuck... :D/>

Thanks for the help...

I'm going inside... I will be some time... :P/>

#6 slymon99

  • New Members
  • 2 posts

Posted 10 December 2012 - 02:01 PM

How do you edit the default programs? I tried cp rom/programs/excavate myExcavate but it didn't work.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users