Jump to content




Getting turtle direction

turtle

7 replies to this topic

#1 k1ll3rM

  • Members
  • 7 posts

Posted 06 January 2016 - 09:40 PM

I have been looking for a while for a working function to get the direction my turtle is facing with no luck. So now I gave up on looking for it and decided to ask it here! Is there any easy code for getting the direction as a number (like in the F3 menu)? I'm still fairly new to this so I would like a bit of an explanation/example on how I would use it combined with my own code. Thank you in advance

#2 KingofGamesYami

  • Members
  • 2,995 posts
  • LocationUnited States of America

Posted 06 January 2016 - 09:44 PM

There is no function in computercraft that tells a turtle which way it is facing. You can find which way you are facing by setting up a GPS cluster and using gps.locate(), then moving forward and using gps.locate() again. Depending on the variable which changed, and if it incremented or decremented, you can find if you are moving north / south / east / west.

GPS API

GPS Tutorial

Example of figuring out which way the turtle is facing

Edited by KingofGamesYami, 06 January 2016 - 09:50 PM.


#3 k1ll3rM

  • Members
  • 7 posts

Posted 06 January 2016 - 09:46 PM

View PostKingofGamesYami, on 06 January 2016 - 09:44 PM, said:

There is no function in computercraft that tells a turtle which way it is facing. You can find which way you are facing by setting up a GPS cluster and using gps.locate(), then moving forward and using gps.locate() again. Depending on the variable which changed, and if it incremented or decremented, you can find if you are moving north / south / east / west.
I know that and that is why I am asking if someone has some code for it. The only code which seemed to look full and would fit my program didn't have any explanation meaning I had no idea how to use it and it kept returning 0

#4 KingofGamesYami

  • Members
  • 2,995 posts
  • LocationUnited States of America

Posted 06 January 2016 - 09:51 PM

I've edited my above post to add a bit more information.

#5 k1ll3rM

  • Members
  • 7 posts

Posted 06 January 2016 - 11:05 PM

View PostKingofGamesYami, on 06 January 2016 - 09:51 PM, said:

I've edited my above post to add a bit more information.
Thank you for your reply! It's currently late for me so I will try this tomorrow but if I can't get it to work then I'll reply back in this thread again.

#6 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,067 posts
  • LocationTasmania (AU)

Posted 06 January 2016 - 11:25 PM

Alternatively, Lion4ever came up with a clever solution here.

#7 k1ll3rM

  • Members
  • 7 posts

Posted 07 January 2016 - 03:33 PM

View PostBomb Bloke, on 06 January 2016 - 11:25 PM, said:

Alternatively, Lion4ever came up with a clever solution here.
I don't want to use a method where I need to have things in my mining turtles inventory because It's a harvester and it could fill up a lot of it's inventory. But thanks anyways!

#8 Lupus590

  • Members
  • 1,932 posts
  • LocationUK

Posted 07 January 2016 - 05:20 PM

Will LAMA do what you need? You will need to tell your turtle it's direction once, but it will be independent from then onwards (even across server restarts).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users