a script for figuring out your current Hypergrid X,Y coordinates

146 views
Skip to first unread message

John "Pathfinder" Lester

unread,
Apr 15, 2012, 2:04:09 PM4/15/12
to the-hypergrid-a...@googlegroups.com
Howdy folks,

I spend a lot of time jumping between different grids and recording different hypergrid landmarks.  So I'm always hitting the 4096 barrier (http://metaverseink.com/blog/?p=222) while trying to calculate my *next* jump point based on the X,Y coordinates of where I currently *am.*

And many times I find myself standing on a region somewhere scratching my head wondering the heck the X,Y HG coordinates are for where I'm standing.

So here's a little script I hacked together that you can drop in an object you're wearing (I have it in my hat).  When you touch the object, it will tell you your current Hypergrid X,Y coordinates.  Problem solved!

----------------------------------------
// Hacked together on 4/15/2012 by Pathfinder Lester (http://about.me/pathfinder)
// from some code I found in Jeff Kelley's excellent HGBoard.
// When object is touched, it will say current Hypergrid coordinates.

    default
{
    state_entry()
    {
        llSay(0, "Script running");
    }
         touch_start(integer total_number)
    {
    vector regionCoor = llGetRegionCorner();
    regionCoor = regionCoor / 256;
    string gridX = (string)llFloor(regionCoor.x);
    string gridY = (string)llFloor(regionCoor.y);
  llSay(0, "Current Hypergrid Coordinates: " + gridX + "," + gridY);  
}
}
----------------------------------------


David Cranmer

unread,
Apr 15, 2012, 2:18:47 PM4/15/12
to the-hypergrid-a...@googlegroups.com
Thanks John,

That's always been an annoyance for me.  Great solution.  Thanks




--
You received this message because you are subscribed to the Google Groups "The Hypergrid Adventurers Club" group.
To view this discussion on the web visit https://groups.google.com/d/msg/the-hypergrid-adventurers-club/-/h7voTuCaS2MJ.
To post to this group, send email to the-hypergrid-a...@googlegroups.com.
To unsubscribe from this group, send email to the-hypergrid-adventu...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/the-hypergrid-adventurers-club?hl=en.

Liz Dorland

unread,
Apr 15, 2012, 2:23:41 PM4/15/12
to the-hypergrid-a...@googlegroups.com
Excellent! Can't wait to try it out.

No more being "Lost in Hyperspace". heheh

Chimera / Liz D.

Joel Foner

unread,
Apr 15, 2012, 2:58:44 PM4/15/12
to the-hypergrid-a...@googlegroups.com

Cool... Leads to thinking about Google Maps for hypergrid... Enter start and end, get list of least hops route to get there, maybe sent to user as chat or im as clickable links? Ok, that's clearly dreaming, but still :)

Joel

Jeff Kelley

unread,
Apr 15, 2012, 3:48:31 PM4/15/12
to the-hypergrid-a...@googlegroups.com
At 1:23 PM -0500 4/15/12, Liz Dorland wrote:

> // from some code I found in Jeff Kelley's excellent HGBoard.

This is trivial, you may delete credit :)))


Current version of HGBoard:

// This script is licensed under Creative Commons BY-NC-SA
// See <http://creativecommons.org/licenses/by-nc-sa/3.0/>
//
// You may not use this work for commercial purposes.
// You must attribute the work to the author, Jeff Kelley.
// You may distribute, alter, transform, or build upon this work
// as long as you do not delete the name of the original author.


integer DEBUG_ON = FALSE;
DEBUG(string message) {if (DEBUG_ON) llOwnerSay(message);}


///////////////////////////////////////////////////////////////////
// Part 1 : Datasource
///////////////////////////////////////////////////////////////////

// The goal of the datasource is to read a file in script's memory
// At the moment, we support three datasources:
//
// http:// A web file
// card://cardname A notecard in the objects's inventory
// card://uuid/cardname A notecard from the LSL server 'uuid'
// (requires a server script, not included)
//
// Edit the 'datasource' string to fit your need
//
//string datasource = "card://Destinations";
//string datasource =
"card://e511d6c0-7588-4157-a684-8ca5f685a077/Destinations";
//string datasource = "http://my_web_server/path_to_file/Destinations";

string datasource = "card://Destinations";

string datasorceData; // The content of the datasource

readFile(string source) {
list parse = llParseString2List (source, ["/"],[]);
string s0 = llList2String (parse, 0);
string s1 = llList2String (parse, 1);
string s2 = llList2String (parse, 2);

// Web server: fall through http_response event

if (s0 == "http:") sendHTTPRequest (source);

// LSL server : fall through dataserver event
// If no UUID : fall through dataserver event

if (s0 == "card:")
if (isUUID(s1)) osMessageObject ((key)s1, "READ "+s2);
else readNotecard (s1);
}

integer isUUID (string s) {
list parse = llParseString2List (s, ["-"],[]);
return ((llStringLength (llList2String (parse, 0)) == 8)
&& (llStringLength (llList2String (parse, 1)) == 4)
&& (llStringLength (llList2String (parse, 2)) == 4)
&& (llStringLength (llList2String (parse, 3)) == 4)
&& (llStringLength (llList2String (parse, 4)) == 12));
}

///////////////////
// Notecard reader
///////////////////

// Since osGetNotecard has Threat Level = VeryHigh
// we stick to the old, slow, clumsy notecard reader

string ncName; // Name of the notecard to be read
key ncQueryID; // id of dataserver queries
integer ncLine; // Current line being read

readNotecard (string name) {
ncName = name;
ncLine = 0;
ncQueryID = llGetNotecardLine(ncName, ncLine++); // request first line
}

addtoNotecard (string data) {
datasorceData += data+"\n";
ncQueryID = llGetNotecardLine(ncName, ncLine++); // Request next line
}

///////////////////
// Http stuff
///////////////////

key httpQueryId;

sendHTTPRequest (string url) {
httpQueryId = llHTTPRequest(url,
[ HTTP_METHOD, "GET", HTTP_MIMETYPE,"text/plain;charset=utf-8" ], "");
}

string URI2hostport (string uri) {
list parse = llParseString2List (uri, [":"], []);
return llList2String (parse, 0)
+":" + llList2String (parse, 1);
}


///////////////////////////////////////////////////////////////////
// Part 2 : Parsing & accessors
///////////////////////////////////////////////////////////////////

list destinations; // Strided list for destinations

integer NAME_IDX = 0; // Index of region name in list
integer COOR_IDX = 1; // Index of grid coordinates in list
integer HURL_IDX = 2; // Index of hypergrid url in list
integer HGOK_IDX = 3; // Index of validity flag in list
integer LAND_IDX = 4; // Index of landing point in list
integer N_FIELDS = 5; // Total number of fields

parseFile (string data) {
list lines = llParseString2List (data,["\n"],[]);
integer nl = llGetListLength (lines);
integer i; for (i=0;i<nl;i++)
parseLine (llList2String(lines,i));
}

parseLine (string line) {
if (line == "") return; // Ignore empty lines

if (llGetSubString (line,0,1) == "//") { // Is this a comment?
llOwnerSay ("(Comment) "+line);
return;
}

list parse = llParseStringKeepNulls (line, ["|"],[]);
string grid = llList2String (parse, 0); // Grid name
string name = llList2String (parse, 1); // Region name
string gloc = llList2String (parse, 2); // Coordinates
string hurl = llList2String (parse, 3); // HG url
string coor = llList2String (parse, 4); // Landing

// Parse and check grid location

parse = llParseString2List (gloc, [","],[]);
integer xloc = llList2Integer (parse, 0); // X grid location
integer yloc = llList2Integer (parse, 1); // Y grid location

vector hisLoc = <xloc, yloc, 0>;
vector ourLoc = llGetRegionCorner()/256;
integer ok =( llAbs(llFloor(hisLoc.x - ourLoc.x)) < 4096 )
&& ( llAbs(llFloor(hisLoc.y - ourLoc.y)) < 4096 )
&& ( hisLoc != ourLoc);

// Parse and check landing point

parse = llParseString2List (coor, [","],[]);
integer xland = llList2Integer (parse, 0); // X landing point
integer yland = llList2Integer (parse, 1); // Y landing point
integer zland = llList2Integer (parse, 2); // Z landing point

vector land = <xland, yland, zland>;
if (land == ZERO_VECTOR) land = <128,128,20>;

// Note: grid and region names merged into one field
destinations += [grid+" "+name, gloc, hurl, ok, land];
}

///////////////////
// List accessors
///////////////////

string dst_name (integer n) { // Get name for destination n
return llList2String (destinations, N_FIELDS*n +NAME_IDX);
}

string dst_coord (integer n) { // Get coords for destination n
return llList2String (destinations, N_FIELDS*n +COOR_IDX);
}

vector dst_landp (integer n) { // Get landing point for destination n
return llList2Vector (destinations, N_FIELDS*n +LAND_IDX);
}

string dst_hgurl (integer n) { // Get hypergrid url for destination n
return llList2String (destinations, N_FIELDS*n +HURL_IDX);
}

integer dst_valid (integer n) { // Get validity flag for destination n
return llList2Integer (destinations, N_FIELDS*n +HGOK_IDX);
}


////////////////////////////////////////////////////////////
// Part 3 : Drawing
////////////////////////////////////////////////////////////

integer TEXTURE_SIZE = 512;
integer DISPLAY_SIDE = 4;
integer FONT_SIZE = 10; // Depends on TEXTURE_SIZE
integer COLUMNS = 3;
integer ROWS = 16;

string validCellColor = "CadetBlue";
string invalCellColor = "IndianRed";
string emptyCellColor = "DarkGray";
string cellBorderColor = "White";
string backgroundColor = "Gray";

string drawList;

displayBegin() {
drawList = "";
}

displayEnd() {
osSetDynamicTextureData ( "", "vector", drawList,
"width:"+(string)TEXTURE_SIZE+",height:"+(string)TEXTURE_SIZE, 0);
}

drawCell (integer x, integer y) {
integer CELL_HEIGHT = TEXTURE_SIZE / ROWS;
integer CELL_WIDHT = TEXTURE_SIZE / COLUMNS;
integer xTopLeft = x*CELL_WIDHT;
integer yTopLeft = y*CELL_HEIGHT;

// Draw grid

drawList = osSetPenColor (drawList, cellBorderColor);
drawList = osMovePen (drawList, xTopLeft, yTopLeft);
drawList = osDrawRectangle (drawList, CELL_WIDHT, CELL_HEIGHT);

integer index = (y+x*ROWS);
string cellName = dst_name(index);
integer cellValid = dst_valid(index);

string cellBbackground;
if (cellName == "") cellBbackground = emptyCellColor; else
if (cellValid) cellBbackground = validCellColor; else
cellBbackground = invalCellColor;

// Fill background

drawList = osSetPenColor (drawList, cellBbackground);
drawList = osMovePen (drawList, xTopLeft+2, yTopLeft+2);
drawList = osDrawFilledRectangle (drawList, CELL_WIDHT-3, CELL_HEIGHT-3);

xTopLeft += 2; // Center text in cell
yTopLeft += 6; // Center text in cell
drawList = osSetPenColor (drawList, "Black");
drawList = osMovePen (drawList, xTopLeft, yTopLeft);
drawList = osDrawText (drawList, cellName);
}

drawTable() {
displayBegin();

drawList = osSetPenSize (drawList, 1);
drawList = osSetFontSize (drawList, FONT_SIZE);

drawList = osMovePen (drawList, 0, 0);
drawList = osSetPenColor (drawList, backgroundColor);
drawList = osDrawFilledRectangle (drawList, TEXTURE_SIZE, TEXTURE_SIZE);

integer x; integer y;
for (x=0; x<COLUMNS; x++)
for (y=0; y<ROWS; y++)
drawCell (x, y);

displayEnd();
}

integer getCellClicked(vector point) {
integer y = (ROWS-1) - llFloor(point.y*ROWS); // Top to bottom
integer x = llFloor(point.x*COLUMNS); // Left to right
integer index = (y+x*ROWS);
return index;
}


///////////////////////////////////////////////////////////////////
// Part 4 : Action routnes: when clicked, when http test succeed
///////////////////////////////////////////////////////////////////

string CLICK_SOUND = "clickSound"; // Sound to play when board clicked
string TELPT_SOUND = "teleportSound"; // Sound to play when teleported
integer JUMP_DELAY = 2; // Time to wait before teleport

string hippo_url; // URL for http check
string telep_url; // For osTeleportAgent
key telep_key; // For osTeleportAgent
vector telep_land; // For osTeleportAgent


integer action (integer index, key who) {
string name = dst_name (index);
string gloc = dst_coord (index);
vector land = dst_landp (index);
string hurl = dst_hgurl (index);
integer ok = dst_valid (index);

if (name == "") return FALSE; // Empty cell
if (!ok) llWhisper (0, "This region is too far ("+gloc+")");
if (!ok) return FALSE; // Incompatible region

llWhisper (0, "You have selected "+name+", location "+gloc);

// Pr�parer les globales avant de sauter

telep_key = who; // Pass to postaction
telep_url = hurl; // Pass to postaction
telep_land = land; // Pass to postaction

hippo_url = "http://"+URI2hostport(hurl); // Pass to http check

DEBUG ("Region name: " +name +" "+gloc+" (Check="+(string)ok+")");
DEBUG ("Landing point: " +(string)land);
DEBUG ("Hypergrid Url: " +hurl);
DEBUG ("Hippochek url: " +hippo_url);

llTriggerSound (CLICK_SOUND, 1.0);
return TRUE;
}

postaction (integer success) {
if (success) {
llWhisper (0, "Fasten your seat belt, we move!!!");
llPlaySound (TELPT_SOUND, 1.0); llSleep (JUMP_DELAY);
osTeleportAgent(telep_key, telep_url, telep_land, ZERO_VECTOR);
} else {
llWhisper (0, "Sorry, host is not available");
}
}


///////////////////////////////////////////////////////////////////
// State 1 : read the data and draw the board
///////////////////////////////////////////////////////////////////

default {

state_entry() {
llOwnerSay ("Reading data from "+datasource);
readFile (datasource);
}

// Handler for card:// datasource
dataserver(key id, string data) {
// Internal card reader
if (id == ncQueryID) {
if (data != EOF) addtoNotecard (data);
else state ready; // File in datasorceData
// External card server
} else {
datasorceData = data;
state ready; // File in datasorceData
}
}

// Handler fot http:// datasource
http_response(key id,integer status, list meta, string body) {
if (id != httpQueryId) return;
datasorceData = body;
state ready; // File in datasorceData
}

state_exit() {
llOwnerSay ("Done. Initializing board");
parseFile(datasorceData);
drawTable();
}

}

///////////////////////////////////////////////////////////////////
// State 2 : running, we pass most of our time here
///////////////////////////////////////////////////////////////////

state ready {

state_entry() {
llWhisper (0, "Ready");
}

touch_start (integer n) {
key whoClick = llDetectedKey(0);
vector point = llDetectedTouchST(0);
integer face = llDetectedTouchFace(0);
integer link = llDetectedLinkNumber(0);

if (link != LINK_ROOT)
if (whoClick == llGetOwner()) llResetScript();
else return;

if (point == TOUCH_INVALID_TEXCOORD) return;
if (face != DISPLAY_SIDE) return;

integer ok = action (getCellClicked(point), whoClick);
if (!ok) return; // Incompatible grid coordinates

integer USE_MAP = (llGetObjectDesc() == "usemap");

// llMapDestination works only in touch events
// We must invoke it here, bypassing http check
// Return so osTeleportAgent will not be called

if (USE_MAP) {
llMapDestination (telep_url, telep_land, ZERO_VECTOR);
return;
}

// Proceed to http check which
// will chain to osTeleportAgent

llWhisper (0, "Checking host. This may take up to 30s, please
wait...");
state hippos; // Perform HTTP check
}

changed(integer what) {
if (what & CHANGED_REGION) llResetScript();
if (what & CHANGED_INVENTORY) llResetScript();
if (what & CHANGED_REGION_RESTART) llResetScript();
}

}

///////////////////////////////////////////////////////////////////
// State 3 : HTTP host check
///////////////////////////////////////////////////////////////////

state hippos {

state_entry() {
sendHTTPRequest (hippo_url);
llSetTimerEvent (60);
}

http_response(key id,integer status, list meta, string body) {
if (id == httpQueryId)
postaction (status == 200);
state ready;
}

timer() {
llSetTimerEvent (0);
postaction (FALSE);
state ready;
}

}


Data source example:

// Enter each destination in the form :
// grid | region | x,y (global location) | url | x,y,z (optional landing
point)

// The optional landing point is useful in the case of sims that not been
designed
// for direct teleport, when your avatar lands underwater or in a closed
room.

OSGrid|Lbsa Plaza|10402,10050|hg.osgrid.org:80:Lbsa Plaza|128,128,30
OSGrid|Wright Plaza|10000,10000|hg.osgrid.org:80:Wright Plaza|128,128,30
OSGrid|jump4000|4090,4090|hg.osgrid.org:80:jump4000
OSGrid|jump8000|8180,8180|hg.osgrid.org:80:jump8000

Hyperica|Lower|4025,4025|hg.hyperica.com:8022:Hyperica Lower
Hyperica|Central|7025,7025|hg.hyperica.com:8022:Hyperica Central
Hyperica|Upper|11025,11025|hg.hyperica.com:8022:Hyperica Upper

NewWorld|Welcome|7000,7000|grid.newworldgrid.com:8002:Welcome
NewWorld|Physics|6998,7001|grid.newworldgrid.com:8002:Physics
NewWorld|CERN|6998,7002|grid.newworldgrid.com:8002:CERN
NewWorld|Pic du Midi|6998,7001|grid.newworldgrid.com:8002:Pic

Example|Unreachable|100000,100000|exemple.grid.net:8000

CraftWorld|Hydra|10000,9992|craft-world.org:8002:Hydra

Larry Havenstein

unread,
Apr 16, 2012, 10:25:48 AM4/16/12
to the-hypergrid-a...@googlegroups.com
Actually if you have an easy way for people to register in the map that is not a bad idea.   Would take the pain out of it.





On 15 Apr 2012 at 14:58, Joel Foner wrote:

Cool... Leads to thinking about Google Maps for hypergrid... Enter start and end, get list of least hops route to get there, maybe sent to user as chat or im as clickable links? Ok, that's clearly dreaming, but still :)

Joel

On Apr 15, 2012 2:04 PM, "John "Pathfinder" Lester" < john.e...@gmail.com> wrote:
Howdy folks,

I spend a lot of time jumping between different grids and recording different hypergrid landmarks. So I'm always hitting the 4096 barrier (
http://metaverseink.com/blog/?p=222 ) while trying to calculate my *next* jump point based on the X,Y coordinates of where I currently *am.*
 ~~~~~~~~~~~~~~~~~~
 Larry Havenstein
  System Engineer and KSRE/COA Computer Security Officer
  Information and Educational Technology
  Department of Communications
  K-State Research and Extension
  Kansas State University     
      
  Lhav...@ksu.edu                        
 

  

Barbara Ann Janson

unread,
Apr 16, 2012, 11:42:01 AM4/16/12
to the-hypergrid-a...@googlegroups.com
my hat is off to you!  thanks!
b

--
You received this message because you are subscribed to the Google Groups "The Hypergrid Adventurers Club" group.
To view this discussion on the web visit https://groups.google.com/d/msg/the-hypergrid-adventurers-club/-/h7voTuCaS2MJ.

Bronte Alcott

unread,
Apr 15, 2012, 2:42:39 PM4/15/12
to the-hypergrid-a...@googlegroups.com
Thanks, John.  What a fantastic gift!

John "Pathfinder" Lester

unread,
Apr 17, 2012, 2:20:04 PM4/17/12
to the-hypergrid-a...@googlegroups.com
You're welcome, folks.  The more we all share what we learn, the more we can help each other move forward!

-John

----------------------------
John Lester
Chief Learning Officer
ReactionGrid, Inc.
http://reactiongrid.com
+1 (617) 910 0386
My Jibe Office: http://jibemicro.reactiongrid.com/pathfinderlester
What is Jibe?: http://www.youtube.com/watch?v=KxYfmfhZ1W8
Additional Contact Info: http://about.me/pathfinder

“If you want to build a ship, don’t drum up the men to gather wood, divide the work and give orders. Instead, teach them to yearn for the vast and endless sea.”  -Antoine de Saint-Exupéry

Thirza Ember

unread,
Jun 20, 2012, 7:01:33 PM6/20/12
to the-hypergrid-a...@googlegroups.com
I finally got around to trying this script today. It worked great in osgrid, where I started out, but when I jumped, the script stopped working -  just showed a 'Loading" message. In a few places, where I was able to rez a new prim/create a script, I got perfect results - but wearing the script (including using it in a Hud) didn't work at all for me - what am I doing wrong?
Thirza
To post to this group, send email to the-hypergrid-adventurers-cl...@googlegroups.com.
To unsubscribe from this group, send email to the-hypergrid-adventurers-club+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "The Hypergrid Adventurers Club" group.
To post to this group, send email to the-hypergrid-adventurers-cl...@googlegroups.com.
To unsubscribe from this group, send email to the-hypergrid-adventurers-club+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "The Hypergrid Adventurers Club" group.
To post to this group, send email to the-hypergrid-adventurers-cl...@googlegroups.com.
To unsubscribe from this group, send email to the-hypergrid-adventurers-club+unsubscribe@googlegroups.com.

Vanish

unread,
Jun 20, 2012, 7:14:03 PM6/20/12
to the-hypergrid-a...@googlegroups.com, Thirza Ember
You're not doing anything wrong, this is the way scripts in OpenSim
behave. Basically, they stop running when you enter a new region (either
through hypergrid, teleport or just by crossing over) and need to be reset
in the new region. (In a related note, this is also the reason why
vehicles in OpenSim aren't good for exploration: They just stop running at
a region crossing, because the scripts stop working.)

> I finally got around to trying this script today. It worked great in
> osgrid, where I started out, but when I jumped, the script stopped
> working
> - just showed a 'Loading" message. In a few places, where I was able to
> rez a new prim/create a script, I got perfect results - but wearing the
> script (including using it in a Hud) didn't work at all for me - what am
> I
> doing wrong?
> Thirza
>
> On Tuesday, April 17, 2012 8:20:04 PM UTC+2, John Pathfinder Lester
> wrote:
>>
>> You're welcome, folks. The more we all share what we learn, the more we
>> can help each other move forward!
>>
>> -John
>>
>> ----------------------------
>> John Lester
>> Chief Learning Officer
>> ReactionGrid, Inc.
>> http://reactiongrid.com <http://jibemix.com>
>>>> the-hypergrid-a...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> the-hypergrid-adventu...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/the-hypergrid-adventurers-club?hl=en.
>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "The Hypergrid Adventurers Club" group.
>>>> To post to this group, send email to
>>>> the-hypergrid-a...@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> the-hypergrid-adventu...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/the-hypergrid-adventurers-club?hl=en.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups
>>> "The Hypergrid Adventurers Club" group.
>>> To post to this group, send email to
>>> the-hypergrid-a...@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> the-hypergrid-adventu...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/the-hypergrid-adventurers-club?hl=en.
>>>
>>
>>
>


--
The Twilight’s Green Illuminate Beam,
This Great ImBalance, that I’ve seen,
That Trees Got Icy Branches and,
The Good In Bad, That God I’ve Been.

http://tgib.co.uk/
Reply all
Reply to author
Forward
0 new messages