Advertisement
salahzar

CB110 edmondo aprile 2014

Apr 11th, 2014
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer startchannel=0;
  2.  
  3. integer NUMLINES= 10;
  4. integer MAXWIDTH= 40;
  5.  
  6. debug(string x){}//{ llOwnerSay(x); }
  7. list buffer; string font;
  8.  
  9. // important to draw on the 3 objects composing each line
  10.  
  11. // Used to read the notecard
  12. key query;
  13. integer line;
  14. integer wbline; // line currently displayed on the whiteboard
  15. string notecard;
  16. integer overflow=0; // in case notecard more than 10 lines touching it will scroll
  17.  
  18. show(string str, integer row)
  19. {
  20.    
  21.     integer index=(row+1)*1000; // 0 maps to 1000, 1 to 2000 and so on
  22.     if(row==-1) index=20000; // -1 maps to 20000 (title)
  23.     debug("sending msg line: "+(string)row+" Index:"+(string)index+" {"+str+"}");
  24.     llMessageLinked(LINK_SET,index,str,"");
  25. }
  26.  
  27. // be sure the whiteboard is clean now
  28. clean(){
  29.    
  30.     integer i;
  31.     for(i=0;i<NUMLINES;i++){
  32.         show(" ",i);
  33.        // llSleep(0.1);
  34.     }
  35.     //show(" ",-1);
  36.    
  37.    
  38. }
  39.  
  40. readnotecard(){
  41.        
  42.         debug("Reading notecard "+notecard+"...");
  43.         query = llGetNotecardLine(notecard, line);
  44.  
  45. }
  46.  
  47. default
  48. {
  49.     state_entry()
  50.     {
  51.        
  52.         clean();
  53.        
  54.         notecard=llGetInventoryName(INVENTORY_NOTECARD,0);
  55.                    
  56.         show(notecard,-1);
  57.                    
  58.         // activate dataserver
  59.         wbline=-1; line=0;
  60.         readnotecard();
  61.  
  62.     }
  63.     changed(integer change)
  64.     {
  65.         llResetScript();
  66.     }
  67.    
  68.  
  69.     // if touched present menu
  70.     touch_start(integer total_number)
  71.     {
  72.         key id=llDetectedKey(0);
  73.         string touched=llGetLinkName (llDetectedLinkNumber(0));
  74.         debug("touched object: "+touched);
  75.         if(touched == "NEXT")
  76.         {
  77.             debug("NEXT action");
  78.             wbline=-1; clean();
  79.             readnotecard();
  80.            
  81.             return;
  82.            
  83.         }
  84.  
  85.        
  86.         else if(touched == "PREV")
  87.         {
  88.            
  89.             wbline=-1; line-=15;
  90.             if(line<0) line=0;
  91.             query = llGetNotecardLine(notecard, line);
  92.         }
  93.        
  94.         return;
  95.        
  96.     }
  97.    
  98.    
  99.     // this is where the fun is: get each line and showing it on the whiteboard (max 10 lines)
  100.     dataserver(key id, string data)
  101.     {
  102.         debug("dataserver received data: "+data);
  103.        
  104.         if (data != EOF)
  105.         {
  106.            
  107.            
  108.             // data in: we must display it fully
  109.            
  110.             debug("displaying data on line "+(string)wbline);
  111.             integer i;
  112.             integer numrows=llStringLength(data)/30;
  113.             integer offset=0;
  114.             for(i=0;i<=numrows;i++){
  115.                string slice=llStringTrim(llGetSubString(data,offset,offset+40),STRING_TRIM);
  116.                if(slice!=""){
  117.                   wbline++;
  118.                   if(wbline<=10) {                  
  119.                      show(slice,wbline);                  
  120.                      offset+=40;
  121.                   } else {
  122.                      // must reread the previous line
  123.                      //line--;
  124.                      jump over;
  125.                 }
  126.                }
  127.             }
  128.             @over;
  129.             if(wbline>10) {
  130.                 debug("stopping reading since more than 15 lines");
  131.             // now go fetching next but check if more than lines to be written
  132.  
  133.                 // no more room for this line so we set overflow true
  134.                 overflow=1; // when in overflow, touch will display next page
  135.                 debug("Will overflow"); //show(notecard,-1);
  136.                 //llSetText("There are other pages, touch for them...",<1,0,0>,1);
  137.                 wbline=-1;
  138.                 return;
  139.             }
  140.            
  141.            
  142.             // now go fetching next dont do if line > 9
  143.             line = line + 1;
  144.             query = llGetNotecardLine(notecard, line);
  145.    
  146.         } else {
  147.             // last line of text
  148.             // clear overflow flag if set
  149.             debug("setting overflow to false");
  150.             //llSetText("Notecard complete",<1,1,1>,1);
  151.             overflow=0; line=0;
  152.             integer i;
  153.             for(i=wbline+1;i<=10;i++) show(" ",i);
  154.             wbline=0;
  155.            
  156.  
  157.         }
  158.          
  159.     }    
  160.    
  161.    
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement