Created
June 15, 2011 09:13
Simple Second Life region map grab/update script. Uses the gridsurvey.com API
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 ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I just noticed I have a typo on line 48 ("=" when I should have "=="). I've tried to edit this but gist doesn't seem to want to retain the edit. O_o