Advertisement
itoibo

multi card reader

Jul 2nd, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer playPause = TRUE;
  2. float sleepTime = 5.0;
  3. key gRequestID;
  4. integer numBookPages;
  5. integer gChannel;
  6. string gMenuText = "Select a card to read.";
  7. list gMenu;
  8. list gMenuShort;
  9.  
  10. list gMenuControls = ["SLOWER", "FASTER", "RESET", "SHOUT TEXT"];
  11.  
  12. integer gListener;
  13.  
  14. string gName;
  15.  
  16. integer gLine = 0;        // current line number
  17. key gQueryID; // id used to identify dataserver queries
  18.  
  19. key user;
  20.  
  21.  
  22. integer itemsContained;
  23. integer currentItem;
  24. string itemName;
  25. string itemShortName;
  26. CountItems()//makes a list of names of notecards in inventory and a list of shortened names for the dialog buttons.
  27. {
  28.   itemsContained = llGetInventoryNumber( INVENTORY_NOTECARD);
  29.   //--items_contained; //minus 1, the script itself isn't counted, since its used with the INVENTORY_ALL flag
  30.     for(currentItem; currentItem < itemsContained; currentItem++)
  31.     {
  32.         itemName = llGetInventoryName(INVENTORY_NOTECARD, currentItem);
  33.         itemShortName = llGetSubString(itemName, 0,10);
  34.         gMenu += itemName;
  35.         gMenuShort += itemShortName;
  36.         llSay(0, (string)itemName);
  37.         //llList2String(gMenu, itemName)):
  38.         //currentItem++;
  39.     }
  40.     //llSay(0, llDumpList2String(gMenu, ","));
  41. }
  42.  
  43.  
  44. default
  45. {
  46.     state_entry() {
  47.        
  48.         CountItems();//makes a list of names of notecards in inventory and a list of shortened names for the dialog buttons.
  49.        
  50.     }
  51.    
  52.     touch_start(integer touches)
  53.     {        
  54.         llListenRemove(gListener);
  55.        
  56.         user = llDetectedKey(0);
  57.        
  58.         gChannel = llGetUnixTime();
  59.         gListener = llListen(gChannel, "", user, "");
  60.  
  61.         llDialog(user, gName+ gMenuText, gMenuShort+gMenuControls, gChannel);
  62.     }
  63.    
  64.    
  65.     listen(integer chan, string name, key id, string msg)
  66.     {
  67.         playPause=TRUE;
  68.        
  69.         integer shortName = llListFindList(gMenuShort, [msg]);
  70.         gName = llList2String(gMenu, shortName);
  71.         llSay(0, (string)gName);
  72.         //llListenRemove(gListener);
  73.         // If the user clicked x button,
  74.         if (msg == "RESET"){llOwnerSay("resetting"); llResetScript();}
  75.        
  76.         else if(msg == "STOP"){llSay(0, "Stop Reading line "+(string)gLine+" of "+(string)numBookPages); playPause = FALSE;}
  77.        
  78.         else if(msg == "FF"){gLine += 5; llSay(0, "Fast Fwd - Line "+(string)gLine+" of "+(string)numBookPages);}
  79.        
  80.          else if(msg == "FFF"){gLine += 25; llSay(0, "Fast Fast Fwd - Line "+(string)gLine+" of "+(string)numBookPages);}
  81.                
  82.         else if(msg == "PLAY"){llSay(0, "Now reading "+gName+" "+ " line "+(string)gLine+" of "+(string)numBookPages); playPause = TRUE;}
  83.        
  84.         else if(msg == "RW"){gLine -= 5; llSay(0, "Rewinding - Line "+(string)gLine+" of "+(string)numBookPages);}
  85.        
  86.          else if(msg == "RRW"){gLine -= 25; llSay(0, "Fast Rewind - Line "+(string)gLine+" of "+(string)numBookPages);}
  87.        
  88.         else if(msg == "SLOWER"){ sleepTime += 1; llOwnerSay("Slower: Delay is " + (string)sleepTime); playPause=FALSE;}
  89.        
  90.         else if(msg == "FASTER" && sleepTime>=1){ sleepTime -= 1; llOwnerSay("Faster: Delay is " + (string)sleepTime);playPause=FALSE;}
  91.          //else if(msg == ""){ gName =; llSay(0, "Faster: Delay is " + (string)sleepTime);
  92.         //}
  93.         else
  94.         {
  95.             //if(playPause == TRUE)
  96.             //{
  97.                 gQueryID = llGetNotecardLine(gName, gLine);    // request first line
  98.             }
  99.          llDialog(user, gName+ gMenuText, gMenuShort+gMenuControls, gChannel);
  100.         //}
  101.     }
  102.    
  103.  
  104.     dataserver(key query_id, string data)
  105.      {
  106.          
  107.          if (query_id == gQueryID)
  108.          {
  109.              if (data != EOF)
  110.              {    // not at the end of the notecard
  111.                  //llSay(0, (string)gLine+": "+data);    // output the line
  112.                 if(playPause == TRUE)
  113.                 {
  114.  
  115.                 //send to chat
  116.                  llShout(0, (string)data);    // output the line                
  117.                  llSleep(sleepTime);
  118.                  ++gLine;                // increase line count
  119.                  gQueryID = llGetNotecardLine(gName, gLine);    // request next line
  120.                 }
  121.             }
  122.         }    
  123.             //if (query_id==gRequestID) {
  124.                 numBookPages = (integer)data;
  125.         //}
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement