User:Kerik Rau/XY2URL

From Second Life Wiki
< User:Kerik Rau
Revision as of 22:03, 26 January 2009 by Kerik Rau (talk | contribs) (New page: <lsl> //Store the target coorinates in "X1 Y1 X2 Y2", creating a bounding box with a height and width list Coords = ["0.112 0.641 0.371 0.740"]; list URLs = ["http://wiki.secondlife.com/w...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

<lsl>

//Store the target coorinates in "X1 Y1 X2 Y2", creating a bounding box with a height and width list Coords = ["0.112 0.641 0.371 0.740"]; list URLs = ["http://wiki.secondlife.com/wiki/User:Kerik_Rau/n2k.AppSpot"];

string Message = "More information is available via this WebSite.";

default {

   touch_start(integer total_number)
   {
       if(llDetectedTouchFace(0) == 3)
       {
           integer i = 0;
           integer NumCoords = llGetListLength(Coords);
           
           for(i = 0; i < NumCoords; ++i)
           {
               list CoordList = llParseString2List(llList2String(Coords, i), [" "], []);
               
               float X1 = (float) llList2String(CoordList, 0);
               float Y1 = (float) llList2String(CoordList, 1);
               float X2 = (float) llList2String(CoordList, 2);   
               float Y2 = (float) llList2String(CoordList, 3);
               
               vector tPos = llDetectedTouchST(0);
               
               if(tPos.x > X1 && tPos.x < X2 && tPos.y > Y1 && tPos.y < Y2)
               {
                   llLoadURL(llDetectedKey(0), Message, llList2String(URLs, i));
                   return;   
               }
           }
           
           //Print out the coords if were the owner, so we can add them in
           if(llDetectedKey(0) == llGetOwner())
               llOwnerSay((string) llDetectedTouchST(0));
       }
   }

} </lsl>