ID:268640
 
A person or something, not diagonal... Oview(1) makes it so you can talk to them diagnonall.. so... I dunno'...
Here's what I mean:
turf
Bob
icon = 'ASDF.dmi'
verb/Talk(infront of player) // Fake.
src << "Lawl?"

x.x
I can get everything except the the infront part...
Thank you, for you reading this...
Use get_step()

get_step() can give you the turf that's in front of the player. Then you just need to check if whatever is in that turf.
In response to Jon88
_> I mean, just on the sides, not diagonally.
I'm reading it in the refrence, and it looks it only supports on direction
What I mean by sides:
North
South
West
East
In response to Hell Ramen
What you want is to find the turf in front of you. get_step() returns the turf in the direction you specify.

var/turf/T = get_step(src,src.dir) // in front of src, in the direction of src's dir


Now you want to find the mob in front of you. There are two ways to do it.

Option one: Loop through all of the mobs in the turf and do what you want there.

for(var/mob/M in T)
...


Option two: Find one mob and specify it.

var/mob/M = locate() in T
if(M) // you always want to check if there is a mob there, otherwise M would be null
...


Hope I helped.
~~> Dragon Lord
In response to Unknown Person
Thanks, DL.
_>
Sorry for being a nub.
In response to Unknown Person
Ok here's a question:

What if you want something excatly like oview, but not include NW, SW, NE, SE directions, so only N,S,E,W, what command would i use to achieve this?

for(var/mob/M in oview(-NW,NE,SW,SE))
In response to DeathAwaitsU
DeathAwaitsU wrote:
Ok here's a question:

What if you want something excatly like oview, but not include NW, SW, NE, SE directions, so only N,S,E,W, what command would i use to achieve this?

You can use the get_dir() proc. It returns the direction of two objects.

To find turfs that are in every direction except north, we could do this:

for(var/turf/T in oview(src, 1))
if(get_dir(src,T)!=NORTH)
...


~~> Dragon Lord
In response to Unknown Person
I see, thanks.
In response to Jon88
get_step() still detects diagonally.
Well, it depends, there is no way to my knowledge to make a verb appear on a non-diagonal basis, a feature I've been requesting for some time, but you can make the diagonals not work with one simple equation:

if((abs(usr.x-src.x)+abs(usr.y-src.y))<2)
//success code down here.
else
//failure code down here.
usr << "You should be adjacent to them!"
In response to Ter13
if(D&(D-1)) is better.