Jump to content

How can I use a script to extract the region name from a landmark?


Life Camino
 Share

You are about to reply to a thread that has been inactive for 674 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm trying to convert landmark information to landmark name, region name, local coordinates and I can get the landmark name and convert from global coordinates to local coordinates.  But, I can't seem to figure out how to extract the region name from the landmark.  Any suggestions?

Link to comment
Share on other sites

This should work correctly llRequestInventoryData() gives a vector to current region corner. You add 2, divide by 256 and you have the "grid coordinates" of the landmark which can be translated into the name through a HTTP Request:

 

key req;vector Absolute;default{    state_entry()    {        req= llRequestInventoryData(llGetInventoryName(INVENTORY_LANDMARK, 0));    }    dataserver(key id, string data)    {        if (id == req)        {            Absolute = llGetRegionCorner() + (vector)data;            vector grid = Absolute / 256.0;            req= llHTTPRequest("https://cap.secondlife.com/cap/0/b713fe80-283b-4585-af4d-a3b7d9a32492?"                                    + "var=name&grid_x=" + (string)llFloor(grid.x)                                     + "&grid_y=" + (string)llFloor(grid.y), [], "");        }    }    http_response(key id, integer status, list metadata, string body)    {        if (id == req)        {            if (status != 200)            {                llOwnerSay("Failure!");                return;            }            integer i = llSubStringIndex(body, "'");            body = llGetSubString(body, i + 1, -3);            llOwnerSay(llDumpList2String(, "/"));        }    }}

 

Link to comment
Share on other sites

Just a minor typo.

The output line should say

llOwnerSay(body);

not

 llOwnerSay(llDumpList2String(, "/"));

It's a nice script. It works for me.

If you want to make it slightly fancier, you might want to add a changed event so that the script responds when you drop a new landmark in it.  Create a new global string variable, gOldLM, and then modify the script with

    state_entry()    {        gOldLM = llGetInventoryName(INVENTORY_LANDMARK,0);        req= llRequestInventoryData(gOldLM);    }    changed(integer change)    {        if (change & CHANGED_INVENTORY)        {            llRemoveInventory(gOldLM);            gOldLM = llGetInventoryName(INVENTORY_LANDMARK,0);            req= llRequestInventoryData(gOldLM);        }    }  

 

 

Link to comment
Share on other sites

  • 5 years later...
  • 1 year later...
You are about to reply to a thread that has been inactive for 674 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...