ContinentDetector

From Second Life Wiki
Revision as of 23:53, 14 January 2011 by Dale Innis (talk | contribs) (some general links)
Jump to navigation Jump to search

Introduction

The Second Life grid, especially the mainland parts, is organized into interesting and aesthetically-pleasing continents, with a variety of landforms and connectivities and geographies. The continents have their own histories, their own interesting places. But because so many people just teleport everywhere (kids these days, I tell ya), all too many people aren't aware of which continent they're on, or where they are relative to the continents, much of the time. This script is a simple example of how one might determine this, and thereby become more Geographically Aware, and therefore more fun at parties.

Usage

To use this script, stick it into the root prim of pretty much any object, and wear that object somewhere on your person. Whenever you teleport, or touch the object, it will tell you your global coordinates, and also what continent or other area of the grid you are on.

Limitations and Notes

In fact this script is mostly just a demonstration of llGetRegionCorner(). The division of the world into continents and other sections is strictly unofficial and approximate, the result of using the map to zip around the grid and see roughly where things seemed to start and stop. It's relatively easy to change what's there, or to add your own areas and divisions. (Is the old Teen Grid still around somewhere? If anyone knows the coordinates, it'd be fun to add them also.)

The reason the script should be put into the root prim of an object is that only root prims get the CHANGED_TELEPORT event.

The Code

You may do anything you like with this code, without limitation. Well, without limitation in the sense of me suing you, that is. If you do illegal things with it, you might get in trouble, for instance. And you can't do impossible things with it.

<lsl> // Each set of five list elements represents a grid-aligned rectangle, in the form xmin,xmax,ymin,ymax,name. // The code returns the FIRST one that it finds, so its okay if the rectangles overlap, as long as you put // the right one first.

list map = [

257024.0,265984.0,229888.0,240384.0,"Jeogeot",
252928.0,254464.0,256000.0,257280.0,"Bay City",
254720.0,265728.0,250368.0,259072.0,"Sansara",
253696.0,259584.0,259328.0,265216.0,"Heterocera",
281600.0,290304.0,257280.0,268032.0,"Satori",
283136.0,291072.0,270848.0,276736.0,"Nautilus",
281600.0,296448.0,276992.0,281600.0,"Corsica",
290048.0,290816.0,268288.0,269824.0,"Western Blake Sea",
291072.0,294400.0,266496.0,272128.0,"Blake Sea",
291840.0,294144.0,284672.0,289280.0,"Gaeta I",
296960.0,304384.0,276736.0,281344.0,"Gaeta V",
460032.0,466176.0,301824.0,307200.0,"Zindra",

// and then for places outside the bounds of mainland continents, some random names...

     0.0,250000.0,     0.0,999999.0,"the Western Ocean",  
250000.0,265000.0,     0.0,999999.0,"the West",        
265000.0,280000.0,     0.0,999999.0,"the Center Longitudes",         
280000.0,310000.0,     0.0,999999.0,"the East",          
310000.0,450000.0,     0.0,999999.0,"the Gap Longitudes",           
450000.0,500000.0,     0.0,999999.0,"the Zindra Longitudes",            
500000.0,999999.0,     0.0,999999.0,"the Far East"

];

string get_continent_name(vector gc) {

   integer count = llGetListLength(map);
   integer i;
   for (i=0;i<count;i+=5) {
       if ((gc.x>=llList2Float( map,i )) &&
           (gc.x<=llList2Float( map,i+1 )) &&        
           (gc.y>=llList2Float( map,i+2 )) &&                                
           (gc.y<=llList2Float( map,i+3 )) ) return llList2String( map,i+4 );
   }
   return "";

}

say_location() {

   vector gc = llGetRegionCorner();
   llOwnerSay("Coordinates: "+(string)gc.x+","+(string)gc.y);
   string s = get_continent_name(gc);
   if (s!="") {
       llOwnerSay("You are in "+s);
   } else {
       llOwnerSay("You are not in any known area.");
   }  

}

default {

   changed(integer change) {
       if (change & CHANGED_TELEPORT) say_location();
   }
   touch_start(integer total_number) {
        say_location();
   }

} </lsl>

See Also

Functions

llGetRegionCorner - to find out the global coordinates of the southwest corner of this sim

llOwnerSay - to tell you about it

Constants

CHANGED_TELEPORT - to see if we've teleported

General

Linden Department of Public Works Roads - shows the major continents and their Linden roads

Physical - a page that should talk about physics stuff in general