ID:159507
 
How would I get the screen location of an object that isn't actually in client.screen, but is on the map and is in the players' view?

Like, say I have an object at 55,67. I walk away from this object until it's in the top right corner of my 7x7 view. That would mean it's screen location would be 7,7, even though it's map location is 55,67. Get what I mean?
You just check the distance and look at the size of the screen.
Look up the screen_loc variable in the reference or F1 in DM
In response to Spunky_Girl
That's not what I asked for, but thanks anyway.

Anyway, it was quite simple and I've got it now.
In response to Koil
Then please explain how you solved your problem because now I'm a bit confused on what you wanted in the first place.
In response to Spunky_Girl
He was trying to find what something's screen_loc would be if it were in the client screen.
In response to AJX
And how would you go about doing that? That's peaked my interest now kinda :D
In response to Spunky_Girl
var/SX = Target.X-x
var/SY = Target.Y-y

Something along those lines would produce the screen loc.
In response to AJX
Is "X" and "Y" a built-in var? I know "x" and "y" are, but I don't know about "X" and "Y".
In response to Spunky_Girl
It was a typo.
In response to AJX
Of course not; that just gets the distance from the player's mob (which is also not necessarily the center of the screen at all) in the x and y axes, not the location of the object on the screen, it's just an attempt to get the distance from the screen's center (and the center's position depends on the player's view size). Here's an example on how to get an atom's screen position:
atom/verb/GetScreenLoc()
set src in view()
var/atom/scrn_center = usr.client.virtual_eye
var/center_xy = usr.client.view+1 //ofc will work for numerical views only
var/x_dist = scrn_center.x - src.x
var/y_dist = scrn_center.y - src.y

var/scrn_x = center_xy - x_dist
var/scrn_y = center_xy - y_dist
usr << "([scrn_x],[scrn_y])"
In response to Kaioken
Meh. Wasn't taking client perspective into consideration. So sue me. :p
In response to AJX
I'm calling my lawyer.
In response to Kaioken
Cool little snippet :D One question though. What do you mean by "ofc will work for numerical views only"? Like, view=3? Or do you mean view="3x3"?
In response to Spunky_Girl
Spunky_Girl wrote:
What do you mean by "ofc will work for numerical views only"? Like, view=3?

Yes, that's numerical.

Or do you mean view="3x3"?

No, that's a text string, so it wouldn't work when trying to add a number to it. To deal with "WIDTHxHEIGHT" views you'd need to do a bit of more work parsing it etc which I didn't include in the code.
In response to Kaioken
Could you do an example for the text string method, because that's how I do views in my game?