ID:2072138
 
(See the best response by Lummox JR.)
Code:
console.log("ref"+item.ref+"-loc:"+item.usrlocx+","+item.usrlocy+","+item.usrlocz+"-slot:"+item.slot);


Problem description:

I want to drag an item from my inventory, to a box around the usr's mob that will place that item on the map where the usr dropped it.

How can I get the CSS Top and Left of the user in the javascript client if i can only pass the users loc.x,y,z to the byond classes's output?

I know how to use JS to CSS change the location of the boxes and add the event listeners to allow for the item drop, I'm just wondering how I can find the proper coordinates to place the box.

Thanks!!
I've been trying byond.pos() and i keep getting stuff like

byond.pos:{"x":0,"y":0}

returned... so I don't think im passing the arguments correctly... but the reference doesn't really say.. i've tried
var testpos = JSON.stringify(byond.pos(5,5));
var testpos = JSON.stringify(byond.pos("5,5"));

etc
Best response
pos() is for HTML elements, so it won't really help you here. In the past, atomInfo() returned x and y for the item on the map, but that was taken out during DSification. I think that's actually what you want, so I can look at adding those back in.
Yes pleassee!!

I've been grinding my brain on how to do screen_loc calculations based on where the mob is on my edge_perspective... rough. lol.

Rather just do that :P
id = item.usrref;
if(id && (m=id.match(/\[0x([0-9a-f]+)\]/i))) {
id = parseInt(m[1],16);
icon = '<img class=item atom='+id+'>';
var usrref = this.atomInfo(id); // gets the atom's icon and makes a url for it
}

console.log(JSON.stringify(usrref));

{"id":50331648,"name":"Guest-W1910366036","appearance":23,"icon":13,"state":"","dir":2}


I don't see the X and Y pixel coordinates in the atominfo list... am I doing something wrong?

(yes i've updated to 1339)
Sorry, I forgot to mention that the function takes two args now. Pass in true as the 2nd arg, and you'll get extended data.

The x,y coords are map-local, so if the map is scaled at all you have to take that into account. If you have any suggestions on how I can make the data more useful, I'm pretty open.
works perfect!

Thanks!!!!

Any chance you'll ever make the references into wiki articles us developers could update to help you out with the documentation of little things like this?
I'd like to move things in that direction, although I'd need to install wiki software and I'd also need some kind of common-sense management setup so that users who have no business touching such things don't.
Well .. I've had some trouble getting this to work.

I've tried 32px icon size ,i've tried stretching, but with that big black box around the map I can't accurately gauge where the usr mob is on the screen. I can set MOB_PERSPECTIVE and just have the boxes appear 50% kinda thing, but that doesn't seem like a good solution.

Any ideas on how I can make this work? I've scanned through the reference like 20 times trying different skin params and nothing seems to work well..
If you do a local winget of the map's view-size param, and grab the map's true size in pixels, that should be enough to make the adjustment. I think it'd probably be valuable to have the map info routine include some positioning data, though.