It's written such that all you need do is drop the script in a prim (ideally a cube, I guess) and it'll "just work". Note that it places the map on face 0 of the prim -- this is handy for creating a one-prim framed map of your home.
You can find the code on gist, and embedded below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////// | |
// Holds the key of the last request. | |
key g_keyRequest; | |
////////////////////////////////////////////////////////////////////// | |
// Force a refresh of the region map. | |
RefreshMap() | |
{ | |
g_keyRequest = llHTTPRequest( "http://api.gridsurvey.com/simquery.php?" + | |
"region=" + llEscapeURL( llGetRegionName() ) + "&item=objects_uuid", | |
[ HTTP_METHOD, "GET" ], "" ); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Default state. | |
default | |
{ | |
////////////////////////////////////////////////////////////////// | |
// Start entry. | |
state_entry() | |
{ | |
// Do an initial refresh. | |
RefreshMap(); | |
// Set a timer so we refresh every so often. | |
llSetTimerEvent( 43200 ); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Refresh on touch. | |
touch_start( integer total_number ) | |
{ | |
RefreshMap(); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Refresh on timer. | |
timer() | |
{ | |
RefreshMap(); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Handle the HTTP response from the request for the map UUID. | |
http_response( key request_id, integer status, list metadata, string body ) | |
{ | |
// If the response is in response to our request... | |
if ( request_id = g_keyRequest ) | |
{ | |
// ...if it's not an error... | |
if ( llGetSubString( body, 0, 4 ) != "Error" ) | |
{ | |
// Set the texture of the first face to the map. | |
llSetTexture( body, 0 ); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////////////////////////////////////////// | |
// Holds the key of the last request. | |
key g_keyRequest; | |
////////////////////////////////////////////////////////////////////// | |
// Force a refresh of the region map. | |
RefreshMap() | |
{ | |
g_keyRequest = llHTTPRequest( "http://api.gridsurvey.com/simquery.php?" + | |
"region=" + llEscapeURL( llGetRegionName() ) + "&item=objects_uuid", | |
[ HTTP_METHOD, "GET" ], "" ); | |
} | |
////////////////////////////////////////////////////////////////////// | |
// Default state. | |
default | |
{ | |
////////////////////////////////////////////////////////////////// | |
// Start entry. | |
state_entry() | |
{ | |
// Do an initial refresh. | |
RefreshMap(); | |
// Set a timer so we refresh every so often. | |
llSetTimerEvent( 43200 ); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Refresh on touch. | |
touch_start( integer total_number ) | |
{ | |
RefreshMap(); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Refresh on timer. | |
timer() | |
{ | |
RefreshMap(); | |
} | |
////////////////////////////////////////////////////////////////// | |
// Handle the HTTP response from the request for the map UUID. | |
http_response( key request_id, integer status, list metadata, string body ) | |
{ | |
// If the response is in response to our request... | |
if ( request_id == g_keyRequest ) | |
{ | |
// ...if it's not an error... | |
if ( llGetSubString( body, 0, 4 ) != "Error" ) | |
{ | |
// Set the texture of the first face to the map. | |
llSetTexture( body, 0 ); | |
} | |
} | |
} | |
} |
No comments:
Post a Comment