innula

Untitled

Jan 12th, 2013
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //read poem from notecard
  2. integer counter;
  3. key queryid;
  4. key notecarduuid;
  5. list poem;
  6. string notecard;
  7.  
  8. read_notecard(){
  9.     notecard = llGetInventoryName(INVENTORY_NOTECARD,0);//get the name of the first notecard in my inventory
  10.     if(notecard){//if there is one
  11.         if(llGetInventoryKey(notecard)!=notecarduuid){//and if it's been changed since last time we looked
  12.             counter = 0; // zero the counter
  13.             queryid = llGetNotecardLine(notecard,counter); // and ask for the first line of the card (lsl starts counting at 0, not 1
  14.         }
  15.     }
  16.  
  17. }
  18.  
  19. default
  20. {
  21.     state_entry()
  22.     {
  23.         read_notecard();
  24.     }
  25.  
  26.     changed(integer change)
  27.     {
  28.         if (change & CHANGED_INVENTORY){
  29.             read_notecard();
  30.             }
  31.         if(change & CHANGED_OWNER){//force it to read aloud for the new owner
  32.             llResetScript();
  33.         }
  34.     }
  35.  
  36.     dataserver(key requested, string data)
  37.     {
  38.         if(queryid == requested){//it's for us
  39.             if(data !=EOF){//not finished reading yet
  40.                 data = llStringTrim(data,STRING_TRIM);//get rid of leading and trailing spaces, tabs and so on
  41.                 if(data){// if there's anything left
  42.                     if (llGetSubString(data,0,1)!="//"){//and it's not commented out
  43.                         llOwnerSay(data);
  44.                         poem+=[data];//add it to the poem list so we don't need to read it again
  45.                     }
  46.                 }
  47.                 ++counter;//advance the counter
  48.                 queryid = llGetNotecardLine(notecard,counter); //and request the next line
  49.  
  50.             }
  51.             else{
  52.                 notecarduuid = llGetInventoryKey(notecard);
  53.                 llSleep(1.0);
  54.                 llOwnerSay("Finished reading the card.  Touch me to hear the poem read again");
  55.             }
  56.         }
  57.     }
  58.  
  59.     attach(key attached)
  60.     {
  61.         if(attached){
  62.             read_notecard();
  63.         }
  64.     }
  65.     touch_start(integer total_number)
  66.     {
  67.         counter = -llGetListLength(poem);
  68.         do {
  69.             llOwnerSay(llList2String(poem,counter));
  70.             llSleep(0.5);
  71.         }
  72.         while(++counter);
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment