Jump to content




Turtle Walking Lib

turtle utility

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

#1 steffomio

  • New Members
  • 2 posts

Posted 05 May 2014 - 12:55 PM

As I started programming a Turtle I found, that the most serious Problem is to move that Machine around.
So a walking lib has to be. An OOP Class for better flexibility.

http://pastebin.com/SEb21e4v

What it can do:
Just say where to go. Don't care about turning the Turtle, that works automatic.

(Please note the . and : Notations which are necessary in OOP context!)
First include the Lib (or Class) like this:
shell.run("myDownloadedFile")

Then create an Object with:
myWalk = tWalk:new()

The Turtle start position is always x:1, z:1, y:1 what you can change from start with:
myWalk = tWalk:new({_x=5, _y=15, _z=-10})

or later with:
myWalk._y = 25
...

Then just say where to go and don't care about turning. Walk to x 5:
myWalk:x(5)
myWalk:y(-10)


Or handle with its Position like that:
if myWalk:x() > 5 then ...

Of course you can turn the Turtle with:
myWalk:turn(2)

Direction IDs are:
1:forward, 2:right, 3:back, 4:left


That's all for now. Have fun!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users