Lee Ludd
Scripted doors & windows
Join date: 16 May 2005
Posts: 243
|
09-17-2009 08:54
Is there a way to determine a region name if you know its global coordinates? You can find a map of a region if you know the coordinates, e.g. http://map.secondlife.com/map-1-1000-1000-objects.jpg and I would like a similar way to find the region name.
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
09-17-2009 09:04
There are LSL commands that will get you the name and global position of the region you're on.. Not sure if that helps you. If not, I think you'd have to poke the MapAPI, http://wiki.secondlife.com/wiki/Map_API, but I suspect that you've been there already..
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
09-17-2009 21:48
IIRC if you look around at the JavaScript on the http://slurl.com/ site, you can find the form of service URLs to map back and forth between names and coordinates.
|
Lee Ludd
Scripted doors & windows
Join date: 16 May 2005
Posts: 243
|
09-17-2009 23:12
Looking at code to figure out how to do things is a little like going to a sausage factory to figure out what to have for lunch. Nevertheless, I followed the advice of both respondents and found how slurl.com crosswalks from region coordinates to region names (and vice versa). Whether I can use this information in an lsl script remains to be tested. Thank you to both respondents.
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
09-17-2009 23:56
This:
http://slurl.com/get-region-name-by-coords?var=region&grid_x=1000&grid_y=1000
will return:
var region='Da Boom';
This uses the region offset, i.e. you have to do the division by 256 first.
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
09-18-2009 01:15
Here's "it works", maybe someone can turn it into "it works and isn't hideous". // Read a landmark in an object's inventory and print its SLurl
key gLandmark; key gWebQuery; vector gGlobalCoordinates; vector gRegionCoordinates;
default { touch_start(integer num_detected) { if (llGetInventoryNumber(INVENTORY_LANDMARK)) { // got a landmark? gLandmark = llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, 0)); } }
dataserver(key queryid, string data) { if (queryid == gLandmark) { vector coordinates = (vector)data + llGetRegionCorner();
gGlobalCoordinates = coordinates / 256; gGlobalCoordinates.x = llFloor(gGlobalCoordinates.x); gGlobalCoordinates.y = llFloor(gGlobalCoordinates.y);
gRegionCoordinates.x = coordinates.x - (gGlobalCoordinates.x * 256); gRegionCoordinates.y = coordinates.y - (gGlobalCoordinates.y * 256); gRegionCoordinates.z = coordinates.z;
gWebQuery = llHTTPRequest( "http://www.google.com/gwt/n?u=http%3A%2F%2Fslurl.com%2Fget-region-name-by-coords%3Fvar%3Dregion%26grid_x%3D" + (string)gGlobalCoordinates.x + "%26grid_y%3D" + (string)gGlobalCoordinates.y, [], "" ); } }
http_response(key request_id, integer status, list metadata, string body) { if (request_id == gWebQuery) { integer regIndex = llSubStringIndex(body, "var region='"); if (regIndex == -1) { llOwnerSay("Unknown Region"); } else { body = llGetSubString(body, regIndex + 12, -1); body = llEscapeURL(llGetSubString(body, 0, llSubStringIndex(body, "'") - 1)); llOwnerSay( "http://slurl.com/secondlife/" + body + "/" + (string)((integer)gRegionCoordinates.x) + "/" + (string)((integer)gRegionCoordinates.y) + "/" + (string)((integer)gRegionCoordinates.z) ); } } } }
|
Lee Ludd
Scripted doors & windows
Join date: 16 May 2005
Posts: 243
|
09-18-2009 08:47
Interesting code, Viktoria. Thanks for posting it.
I'm curious why you access slurl.com through google.
|
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
|
09-18-2009 09:19
From: Lee Ludd Interesting code, Viktoria. Thanks for posting it.
I'm curious why you access slurl.com through google. I might be wrong but Linden Lab put a block on scripts accessing their web servers. So Google would be the back way in.
|
Viktoria Dovgal
…
Join date: 29 Jul 2007
Posts: 3,593
|
09-18-2009 12:29
Right, it's the same deal as with the search API, slurl.com returns a nice happy "access denied". It helps LL to protect itself against any inadvertent back doors that might sneak into queries from inside LL's networks.
|