URL Catcher

From NMC-Campus

Jump to: navigation, search

// URL catcher: Generator script ver. 1.1 // // This script is free. Copy this to any object you can or modify the object comes // with this script. // All you need to have inside URL catcher are "This script", "URL ball", and a sound // file for generating URL ball event. // For URL ball modification, please read the script inside the ball object.


float fwdoffset = 0.5; float leftoffset = 0.0; float upoffset = 1.5;

integer ballcolor = 0; string generateSound = "bubble";

default {

   state_entry()
   {
       llWhisper(0, "Reset");
       llListen( 0, "", "", "");
   }
   
   listen(integer channel, string name, key id, string message)
   {   
       list messageList = llParseString2List(message, [" "], []);
       integer wwwinList = -1;
       integer httpinList = -1;
       integer urlinList = -1;
       integer i = 0;
       for(i = 0 ; i <= llGetListLength(messageList) ; i++)
       {
           string j = llList2String(messageList, i);
           wwwinList = llSubStringIndex(j, "http:");
           httpinList = llSubStringIndex(j, "www.");
           if(wwwinList != -1 || httpinList != -1) urlinList = i;
       }
       
       if(urlinList != -1)
       {
           string urlString = llList2String(messageList, urlinList);
           integer wwwinString = -1;
           integer httpinString = -1;
           string url = "";
           wwwinString = llSubStringIndex(urlString, "www");
           httpinString = llSubStringIndex(urlString, "http");
           if(wwwinString != -1)
           {
               url = "http:\/\/" +llGetSubString(urlString, wwwinString, -1);
           }
           if(httpinString != -1)
           {
               url = llGetSubString(urlString, httpinString, -1);
           }
           
           vector pos = llGetPos() + <fwdoffset, leftoffset, upoffset>;
           llRezObject("URL ball", pos, ZERO_VECTOR, ZERO_ROTATION, 1);
           llTriggerSound(generateSound, 0.5);
           llSay(404, (string)ballcolor + " " + url);
           ballcolor += 1;
           if(ballcolor == 3) ballcolor = 0;
       }
   }

}

Personal tools
using the wiki