Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This file contains a series of defines and functions that will
- allow you to use linkSetData memory for lists. These lists will
- not have all the versitlity of normal LSL lists.
- The format in LinksetData memory are as follows.
- The first entry in a list is the master header file. It is
- defined as the following.
- linkset listName is the list listName and the data is the number of
- entries the list.
- <listName> -> <list entries number>
- the format of each list entry is as follows
- <listName>:<entrynumber>:<data>
- */
- // The first step is the define the linkSetList entry
- integer linkSetDefine(string listName)
- {
- // test to see if entry already exists,
- // if so return error of -1
- if(llLinksetDataRead(listName) != "")
- return -1;
- else
- llLinksetDataWrite(listName, "0");
- return 1; // linkSetList Created.
- }
- // add a entry to the linkset entry and increment the
- // the count by one when adding. create the linkSet
- // if it does not exist. any data other than a string
- // must be typecast to a string.
- integer addLinkData(string listName, string data)
- {
- integer tcList;
- // if listName exists, add link
- // and increment count.
- if(linkSetDefine(listName) == 1)
- tcList = incrmLinkCount(listName, 0);
- else
- tcList = incrmLinkCount(listName, 1);
- llLinksetDataWrite(listName +":"+ (string) tcList +":"+data, "0");
- return tcList;
- }
- // get count total from base and increase it by 'count'
- integer incrmLinkCount(string listName, integer count)
- {
- integer currentNum = (integer) llLinksetDataRead(listName);
- currentNum += count;
- llLinksetDataWrite(listName, (string) currentNum);
- return currentNum;
- }
- // Return the number of entries in a linkSetList
- integer GetLinkSetListLength(string listName)
- {
- // return error if linkSetList does not exits of -1
- integer listLength = (integer) llLinksetDataRead(listName);
- if(listLength == 0)
- return -1;
- else
- return (listLength + 1);
- }
- // returns a string that is at index in src
- string linkList2String(string src, integer index)
- {
- string found;
- string searchFor = src+":"+(string) index +":";
- found = (string) llLinksetDataFindKeys(searchFor, 0, 1);
- return llList2String(llParseString2List(found, [":"], [""]), 2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement