Gayngel

Basic Notecard Reader

May 28th, 2022 (edited)
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string ncName = "config";
  2. key ncKey;
  3.  
  4.  
  5. integer nLine;
  6.  
  7. key queryNC;
  8.  
  9. nextLine()
  10. {
  11.  
  12.    ++nLine;
  13.    queryNC = llGetNotecardLine(ncName, nLine);    
  14.    
  15. }
  16.  
  17. default
  18. {
  19.    
  20.    
  21.    
  22.     state_entry()
  23.     {
  24.        
  25.        
  26.        
  27.        ncKey = llGetInventoryKey(ncName);
  28.        
  29.        nLine = 0;
  30.        
  31.        queryNC = llGetNotecardLine(ncName, nLine);
  32.        
  33.     }
  34.    
  35.    
  36.     link_message(integer sender, integer num, string msg, key id)
  37.     {
  38.        
  39.        
  40.        if(msg == "Reset_Notecard")
  41.        {
  42.            
  43.          llResetScript();  
  44.            
  45.         }
  46.        
  47.        
  48.    
  49.        
  50.     }
  51.    
  52.    
  53.     dataserver(key query, string data)
  54.     {
  55.      
  56.      if(query == queryNC)
  57.      {
  58.          
  59.       if(nLine == 0)
  60.       {
  61.        
  62.        llOwnerSay("Reading config notecard for settings. Please wait.");    
  63.          
  64.       }  
  65.      
  66.      if(data != EOF)
  67.      {
  68.      
  69.        
  70.            if(llSubStringIndex(data, "\\") != 0 && data !="")
  71.           {
  72.            list tmp = llParseString2List(data, ["="],[]);  
  73.            string cmd = llStringTrim(llToLower(llList2String(tmp,0)), STRING_TRIM);
  74.            string ref = llStringTrim(llList2String(tmp,1), STRING_TRIM);
  75.            
  76.          
  77.            
  78.           if(cmd == "admin_id")
  79.           {
  80.                
  81.               llMessageLinked(LINK_SET,0,"Add_To_Admins",(key)ref);  
  82.               nextLine();
  83.                  
  84.           }
  85.          
  86.          
  87.          
  88.          
  89.        
  90.          
  91.            else if(cmd == "access_id")
  92.           {
  93.               llMessageLinked(LINK_SET,0,"Add_To_Access",(key)ref);  
  94.                nextLine();
  95.                
  96.            }
  97.                  
  98.        
  99.              else
  100.            {
  101.                
  102.              nextLine();  // unrecognized command
  103.                
  104.             }
  105.            
  106.              
  107.          
  108.        
  109.          
  110.            }
  111.            
  112.            else
  113.            {
  114.                
  115.              nextLine(); // line is a comment or blank
  116.                
  117.             }
  118.          
  119.          
  120.      }
  121.      
  122.      else // (data == EOF)
  123.      {
  124.        
  125.      
  126.        
  127.        llMessageLinked(LINK_SET,0,"End_of_Notecard","");  
  128.          
  129.      }  
  130.      
  131.     }
  132.        
  133.        
  134.     }
  135.    
  136.     changed(integer change)
  137.     {
  138.      
  139.      if(change & CHANGED_INVENTORY)
  140.      {
  141.          
  142.        
  143.          
  144.        if(llGetInventoryKey(ncName) != ncKey)
  145.        {
  146.          
  147.            llResetScript();
  148.            
  149.         }  
  150.          
  151.      }  
  152.        
  153.        
  154.     }
  155.    
  156.    
  157. }
Add Comment
Please, Sign In to add comment