ContinentDetector

From Second Life Wiki
Revision as of 11:59, 1 October 2022 by Gwyneth Llewelyn (talk | contribs) (→‎The Code: Replaced deprecated <source> tags with <syntaxhighlight>)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.

// Script by Dale Innis, January 2011.  You may do whatever you like with this script, without limitation.
 
// Updated June 2011, June 2013, March 2014, December 2015, February 2021 and April 2021 by Braclo Eber.
// Please see changelogs below for details. It was getting too long to keep at the start of the script.
 
// NOTE: Due to how close some regions are to the private continents, some might indicate they are part of the continent due to how the script works.
// -----
 
// 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 = [
 261888.0,267776.0,240640.0,250368.0,"Bellisseria",	//West Coast
 267776.0,281600.0,243200.0,258048.0,"Bellisseria",	//Mid to East Coast
 296704.0,302080.0,252928.0,256768.0,"Sharp",
 257024.0,266240.0,229632.0,240640.0,"Jeogeot",
 251392.0,254208.0,256000.0,257792.0,"Bay City",
 254208.0,265984.0,250368.0,259328.0,"Sansara",
 253696.0,259840.0,259328.0,265472.0,"Heterocera",
 281344.0,290560.0,257280.0,268288.0,"Satori",
 290048.0,290816.0,268288.0,269824.0,"Western Blake Sea",
 290816.0,297216.0,265216.0,271872.0,"Blake Sea",
 286976.0,289792.0,268032.0,269312.0,"Nautilus City",
 283136.0,293376.0,268288.0,276992.0,"Nautilus",
 281600.0,296960.0,276992.0,281856.0,"Corsica",
 291840.0,295936.0,284672.0,289536.0,"Gaeta I",
 296960.0,304640.0,276736.0,281600.0,"Gaeta V",
 460032.0,466432.0,301824.0,307456.0,"Zindra",
 461824.0,464384.0,307456.0,310016.0,"Horizons",
// List of private continents.
 117504.0,123392.0,   435200.0,440576.0,"Eden",
 250112.0,254720.0,   245248.0,248576.0,"Estate",
 282624.0,284416.0,   268288.0,270336.0,"FairChang",
// 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()+llGetPos();
    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();
    }
}

// Changelog
// Created January 2011 by Dale Innis

// Updated June 2011 by Braclo Eber. 
// Some border sims of continents were missing from the detector.
// Changed some figures to be more accurate. (Nautilus Continent & Bay City Extension)
// Changed the order of the continents to reflect the changes.
// Included Nautilus City.

// Updated June 2013 by Braclo Eber.
// Updated coordinates for missing border regions on continents.

// Updated March 2014 by Braclo Eber.
// Small fix for Western Blake Sea,Blake Sea,Nautilus and Nautilus City. 

// Updated December 2015 by Braclo Eber.
// Added 11 private continents that currently qualify as continents as per http://slgi.wikia.com/wiki/List_Of_Continents

// Updated February 2021 by Braclo Eber
// Added Bellisseria - Split it due to the shape of the continent.
// Added Sharp - also known as the old Teen grid.
// Updated Eden and FairChang - Continents Moved
// Removed Winterfell, Mar Lesbiana, Crossing Sands and Shopping - These continents does not exist anymore.
// Removed Caledon, Wild West, Freedom and Uhre - These are not classified as continents anymore due to the requirements of at least 30 sims as per https://wiki.secondlife.com/wiki/List_Of_Continents

// Updated April 2021 by Braclo Eber
// Added the east connection of Bellisseria, connecting to Satori.
// Added Horizons, north of Zindra.
// Adjusted Satori, Sansara, Sharp, Corsica, Jeogeot, Black Sea, Western Blake Sea, Eden, Fairchang and Nautilus City due to new regions or border regions not being detected correctly.

Another code

This script is a bit more complicated. Put it into a prim (an avatar attachment or HUD attachment should be the best). I only give you some coordinates, you can add all the others. Look on the map for most remote sims of a continent or other geographical feature, then go to Gridsurvey Gridsurvey to get the sim coordinates. You can add 40 geographical features without problems. If you want to add more, please make two scripts and put both into a prim. The script will pick-up the first continent it matches. So, if you want to detect Snowlands or Color Sims in Sansara, please put them before you put Sansara. If nothing is found, the script will answer nothing (you can add an 'else' event with an answer that no continent was detected.

Coordinates are available also from this wiki. Search at page List Of Continents and the link to all continents and at page Oceans for all oceanic coordinates. For small map structures, coordinates can be found at List Of Microcontinents And Sim Clusters or at Second Life Geography.

//Created by Ana Imfinity
default
{
    state_entry()
    {
    }
    touch_start(integer Ana)
    {
        vector grc = llGetRegionCorner(); //This gives sim coordinates in meters
        float grcx = grc.x; //Longitude
        float grcy = grc.y; //Latitude
        integer xxx = (integer)(grcx/256); //Transforms longitude from meters to sim coordinates (like Gridsurvey)
        integer yyy = (integer)(grcy/256); //Transforms longitude from meters to sim coordinates (like Gridsurvey)
        string continent;
        string sim = llGetRegionName();
// Now, see that I repeat a formula, in which the xxx and yyy are 
//minimum and maximum latitude and longitude I found on Gridsurvey. 
//Add new locations after this model.
        if (xxx>1134 && xxx<1154 && yyy>1039 && yyy<1061)
        {
            continent = "Blake Sea Continent";
        }
        else if (xxx>903 && xxx<911 && yyy>1019 && yyy<1035)
        {
            continent = "Caledon-Winterfell Continent";
        }
        else if (xxx>1099 && xxx<1160 && yyy>1080 && yyy<1101)
        {
            continent = "Corsica Continent";
        }
        else if (xxx>675 && xxx<693 && yyy>1193 && yyy<1214)
        {
            continent = "Eden Continent";
        }
        else if (xxx>973 && xxx<1009 && yyy>944 && yyy<976)
        {
            continent = "Estate Continent";
        }

//Add here new continents (and oceans) following the model

        else
        {
            continent = "No continent detected";
        }
        string message = "Current grid position is: "+(string)(xxx)+"+"+(string)(yyy)+". Sim name is "+sim+" - "+continent;
        llOwnerSay(message);
    }
}

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

History of Second Life - includes some discussion of the geography

List Of Continents

Oceans

List Of Microcontinents And Sim Clusters

Lalo Telling's history page - has his very nice geohistory of the early grid