New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add turtle.getTurn() #473

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
7 participants
@Wilma456
Contributor

Wilma456 commented Oct 4, 2017

With this function you can get the Direction of a Turtle. The return value is a number, because it can be used in Loops. Here are the return value:
1
4 2
3

Note:
This is not compatible to #462. If it get merged, I will change case 42 to case 44.

@SquidDev

This comment has been minimized.

Contributor

SquidDev commented Oct 4, 2017

It might be worth looking at the discussion in #383. I'm won't re-iterate what was said there, but it does highlight some conceptual problems with such a function.

@hugeblank

This comment has been minimized.

hugeblank commented Oct 4, 2017

What essentially was said in that PR was turtles having the ability to get their direction is giving them "magic" knowledge. And I have to agree with this, this doesn't seem like something that belongs in a turtle, as they don't have any sort of "compass" built in.

Think of it this way: a player get's teleported randomly in a radius 10000 blocks away from his base, and has to find his way back. Assuming the player is unfamiliar with the land around him, how is he supposed to know which way to start walking? Players aren't given a direction unless they open the debug screen, which is comparable to a GPS. And even then, the player has to do some small movements to figure out which way is +X, and +Z (the rest from there can be assumed).

One of the things brought up in #383 was turtles should be able to do what players can do, I.E. read a compass. And I absolutely agree with this. If a player can get their direction just by looking at a compass, then so should a turtle.

So what I would recommend is turning a compass into a peripheral, and THEN if it is equipped, provide this as a method (and maybe a radiusFromSpawn method too? ;D).

EDIT: radiusFromSpawn would be much, maybe just directionToSpawn, which just gives the general direction towards spawn.

@xAnavrins

This comment has been minimized.

xAnavrins commented Oct 9, 2017

I don't support this, getting a turtle orientation pretty much falls in the same category as getting a turtle coordinate, which you can only get with GPS.
You can get turtle orientation using two GPS calls and some maths.

@absolument

This comment has been minimized.

absolument commented Dec 9, 2017

Without GPS and since ComputerCraft 1.76 you can get Direction of a Turtle, by placing a block with facing block.state and then inspect it :
pastebin get KE8cUP8x compas
https://pastebin.com/KE8cUP8x

ex:
Put a chest in the first slot of Turtle inventory, then run this command
compas 1

@SuperDyl

This comment has been minimized.

SuperDyl commented Mar 1, 2018

Two parts:

  1. Turtles could have knowledge of world direction because blocks in Minecraft all have world direction knowledge. The cracks of breaking blocks and the textures of the tops of blocks can be used to find cardinal directions.

  2. A turtle.getTurn() function ought to use the same system as math for angle measure. That means either 1, 2, 3, and 4 (for the four cardinal directions) or 0, 90, 180, and 270 (for angle measures) would be returned, but most to follow conventions, rotations in math are done counterclockwise. That means the output should be:

..1..
2..4
..3..

@thatcraniumguy

This comment has been minimized.

thatcraniumguy commented May 23, 2018

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment