Advertisement
Madi_Perth

Untitled

Nov 14th, 2023
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Linden Scripting 2.34 KB | Source Code | 0 0
  1. /*
  2. This file contains a series of defines and functions that will
  3. allow you to use linkSetData memory for lists.  These lists will
  4. not have all the versitlity of normal LSL lists.
  5.  
  6. The format in LinksetData memory are as follows.
  7.  
  8. The first entry in a list is the master header file.  It is
  9. defined as the following.
  10.  
  11. linkset listName is the list listName and the data is the number of
  12. entries the list.
  13.  
  14. <listName> -> <list entries number>
  15.  
  16. the format of each list entry is as follows
  17.  
  18. <listName>:<entrynumber>:<data>
  19.  
  20. */
  21.  
  22. // The first step is the define the linkSetList entry
  23. integer linkSetDefine(string listName)
  24. {
  25.     // test to see if entry already exists,
  26.     // if so return error of -1
  27.     if(llLinksetDataRead(listName) != "")
  28.         return -1;
  29.     else
  30.         llLinksetDataWrite(listName, "0");
  31.     return 1; // linkSetList Created.
  32. }
  33.  
  34. // add a entry to the linkset entry and increment the
  35. // the count by one when adding.   create the linkSet
  36. // if it does not exist. any data other than a string
  37. // must be typecast to a string.
  38. integer addLinkData(string listName, string data)
  39. {
  40.     integer tcList;
  41.     // if listName exists, add link
  42.     // and increment count.
  43.     if(linkSetDefine(listName) == 1)
  44.         tcList = incrmLinkCount(listName, 0);
  45.     else
  46.         tcList = incrmLinkCount(listName, 1);
  47.     llLinksetDataWrite(listName +":"+ (string) tcList +":"+data, "0");    
  48.  
  49.     return tcList;
  50. }
  51.  
  52. // get count total from base and increase it by 'count'
  53. integer incrmLinkCount(string listName, integer count)
  54. {
  55.     integer currentNum = (integer) llLinksetDataRead(listName);
  56.    
  57.     currentNum += count;
  58.     llLinksetDataWrite(listName, (string) currentNum);
  59.  
  60.     return currentNum;
  61. }
  62.  
  63. // Return the number of entries in a linkSetList
  64. integer GetLinkSetListLength(string listName)
  65. {
  66.     // return error if linkSetList does not exits of -1
  67.     integer listLength = (integer) llLinksetDataRead(listName);
  68.     if(listLength == 0)
  69.         return -1;
  70.     else
  71.         return (listLength + 1);
  72. }
  73.  
  74. // returns a string that is at index in src
  75. string linkList2String(string src, integer index)
  76. {
  77.     string found;
  78.     string searchFor = src+":"+(string) index +":";
  79.  
  80.     found = (string) llLinksetDataFindKeys(searchFor, 0, 1);
  81.     return llList2String(llParseString2List(found, [":"], [""]), 2);
  82. }
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement