Difference between revisions of "Computer:jaycoonlanguage"

From Second Life Wiki
Jump to navigation Jump to search
(Brush up and add to category index)
m (a few readability improvements)
Line 2: Line 2:
This is a language that is written in LSL. It reads a notecard specified by the user (meant for use with my computer that you can buy here: http://slurl.com/secondlife/Coda/249/46/73)
This is a language that is written in LSL. It reads a notecard specified by the user (meant for use with my computer that you can buy here: http://slurl.com/secondlife/Coda/249/46/73)
<lsl>
<lsl>
integer open  = FALSE; //initialised: Starts un initialised
// initialised: Starts un initialised
integer open  = FALSE;
 
string notecard;
string notecard;
key datanotecardlin;
 
key datanotecardtext;
key notecardLineQueryID;
key notecardTextQueryID;
 
integer lines;
integer lines;
string process;
string process;
Line 12: Line 16:
list ints;
list ints;
list strings;
list strings;
default
default
{
{
     state_entry()
     state_entry()
     {
     {
         llListen(0,"","","");
    //  PUBLIC_CHANNEL has the integer value 0
         llListen(4,"","","");      
         llListen(PUBLIC_CHANNEL, "", NULL_KEY, "");
         llListen(4, "", NULL_KEY, "");
     }
     }
     listen(integer chan, string name, key id, string message)
 
     listen(integer channel, string name, key id, string message)
     {
     {
         if(message == "os:load progs") //Init start here
    //  init start
        {
         if(message == "os:load progs")
             llSay(4,"prog:jaycoonlanguage");
             llSay(4, "prog:jaycoonlanguage");
        }
 
         if(message == "bios:startjaycoonlanguage")
         else if(message == "bios:startjaycoonlanguage")
        {
             open = TRUE;
             open = TRUE;
        }
 
         if(message == "close" && open)
         else if(message == "close" && open)
        {
             open = FALSE;
             open = FALSE;
        } //init done
    // init done
         if(~llSubStringIndex(message, "notecard:") && open == TRUE)
 
        {
    //  set notecard
             notecard = llDeleteSubString(message,0,9); //set notecard
         if(~llSubStringIndex(message, "notecard:") && open)
           
             notecard = llDeleteSubString(message, 0, 9);
        }
 
         if(message == "compile" && notecard != "" && open)
         if(message == "compile" && notecard != "" && open)
         {
         {
            //start compiling
        // start compiling
          datanotecardlin = llGetNumberOfNotecardLines(notecard);
            notecardLineQueryID = llGetNumberOfnotecardLineQueryIDs(notecard);
             process = "lines";
             process = "lines";
             integer contvar = 0;
             integer contvar = 0;
             while (contvar <= lines)
             while (contvar <= lines)
             {
             {
              datanotecardtext = llGetNotecardLine(notecard,contvar);
                notecardTextQueryID = llGetnotecardLineQueryID(notecard,contvar);
              if(~llSubStringIndex(line,"print:"))
 
                if(~llSubStringIndex(line, "print:"))
                 {
                 {
                    line = llDeleteSubString(line,0,6);      
                    line = llDeleteSubString(line,0,6);
                     if(~llListFindList(ints,[line]))
 
                    {
                     if(~llListFindList(ints, [line]))
                         llSay(0,llList2String( ints,llListFindList(ints,[line])));
                         llSay(PUBLIC_CHANNEL,
                    }
                            llList2String(ints,llListFindList(ints, [line])));
                     if(~llListFindList(strings,[line]))
 
                    {
                     if(~llListFindList(strings, [line]))
                         llSay(0,llList2String( ints,llListFindList(strings,[line])));
                         llSay(PUBLIC_CHANNEL,
                    }
                            llList2String(ints,llListFindList(strings, [line])));
                     llSay(0,line);
 
                     llSay(PUBLIC_CHANNEL, line);
                 }
                 }
                 if(~llSubStringIndex(line,"int:"))
                 if(~llSubStringIndex(line, "int:"))
                 {
                 {
                     line = llDeleteSubString(line,0,4);
                     line = llDeleteSubString(line, 0, 4);
                     ints += (integer)line;
                     ints += (integer)line;
                   
                   
                 }
                 }
                 if(~llSubStringIndex(line,"string:"))
                 if(~llSubStringIndex(line, "string:"))
                 {
                 {
                     line = llDeleteSubString(line,0,4);
                     line = llDeleteSubString(line, 0, 4);
                     strings += (string)line;
                     strings += (string)line;
                   
                 }
                 }
               
 
                 contvar++;
                 ++contvar;
             }
             }
         }
         }
     }
     }
     dataserver(key data, string function)
 
     dataserver(key query_id, string data)
     {
     {
         if(data == datanotecardlin)
         if(query_id == notecardLineQueryID)
        {
             lines = (integer)data;
             lines = (integer)function;
 
        }   
         if(query_id == notecardTextQueryID)
         if(data == datanotecardtext)
             line = data;
        {
             line = function;
           
           
        }
       
     }
     }
}
}

Revision as of 09:34, 9 October 2012

This is a language that is written in LSL. It reads a notecard specified by the user (meant for use with my computer that you can buy here: http://slurl.com/secondlife/Coda/249/46/73) <lsl> // initialised: Starts un initialised integer open = FALSE;

string notecard;

key notecardLineQueryID; key notecardTextQueryID;

integer lines; string process; string line; string notcard; list ints; list strings;

default {

   state_entry()
   {
   //  PUBLIC_CHANNEL has the integer value 0
       llListen(PUBLIC_CHANNEL, "", NULL_KEY, "");
       llListen(4, "", NULL_KEY, "");
   }
   listen(integer channel, string name, key id, string message)
   {
   //  init start
       if(message == "os:load progs")
           llSay(4, "prog:jaycoonlanguage");
       else if(message == "bios:startjaycoonlanguage")
           open = TRUE;
       else if(message == "close" && open)
           open = FALSE;
   //  init done
   //  set notecard
       if(~llSubStringIndex(message, "notecard:") && open)
           notecard = llDeleteSubString(message, 0, 9);
       if(message == "compile" && notecard != "" && open)
       {
       //  start compiling
           notecardLineQueryID = llGetNumberOfnotecardLineQueryIDs(notecard);
           process = "lines";
           integer contvar = 0;
           while (contvar <= lines)
           {
               notecardTextQueryID = llGetnotecardLineQueryID(notecard,contvar);
               if(~llSubStringIndex(line, "print:"))
               {
                   line = llDeleteSubString(line,0,6);
                   if(~llListFindList(ints, [line]))
                       llSay(PUBLIC_CHANNEL,
                           llList2String(ints,llListFindList(ints, [line])));
                   if(~llListFindList(strings, [line]))
                       llSay(PUBLIC_CHANNEL,
                           llList2String(ints,llListFindList(strings, [line])));
                   llSay(PUBLIC_CHANNEL, line);
               }
               if(~llSubStringIndex(line, "int:"))
               {
                   line = llDeleteSubString(line, 0, 4);
                   ints += (integer)line;
               }
               if(~llSubStringIndex(line, "string:"))
               {
                   line = llDeleteSubString(line, 0, 4);
                   strings += (string)line;
               }
               ++contvar;
           }
       }
   }
   dataserver(key query_id, string data)
   {
       if(query_id == notecardLineQueryID)
           lines = (integer)data;
       if(query_id == notecardTextQueryID)
           line = data;
   }

} </lsl>