Difference between revisions of "XMREngine.scriptdb"
Line 1: | Line 1: | ||
− | These methods are available as an alternative to using the OpenSim notecard | + | These API methods are available as an alternative to using the OpenSim notecard API methods. They provide access to persistent storage that scripts can use to save information. The information is stored and retrieved as name/value pairs. The name is a string up to 233 characters and the value can be up to 65535 characters. Name/value pairs written by one script in an object can be accessed by any script in the same object (including other linked prims). They cannot be accessed by other objects. |
− | These methods access persistent storage as lists of lines, similar to the OpenSim notecard methods. | + | These methods access persistent storage as lists of lines, similar to the OpenSim notecard API methods. |
Write the list as a series of lines to the named persistent data element. | Write the list as a series of lines to the named persistent data element. | ||
Line 8: | Line 8: | ||
name = name of persistent element | name = name of persistent element | ||
contents = list of lines to write to element | contents = list of lines to write to element | ||
+ | Note: | ||
+ | If persistent element with same name already exists, it is overwritten | ||
Read a single line from an element written by xmrScriptDBWriteLines() | Read a single line from an element written by xmrScriptDBWriteLines() | ||
Line 42: | Line 44: | ||
value = string to write to persistent element | value = string to write to persistent element | ||
Note: | Note: | ||
− | If persistent element with | + | If persistent element with same name already exists, it is overwritten |
Read a single persistent element as one whole string: | Read a single persistent element as one whole string: | ||
Line 83: | Line 85: | ||
Output: | Output: | ||
returns number of elements deleted (might be zero) | returns number of elements deleted (might be zero) | ||
+ | |||
+ | In the above, keylike is a MySql style LIKE parameter. Use % to indicate matching any number of characters in the element name, use _ to indicate matching exactly one character of the element name. For example, "%" matches all names, "1.%" matches all names beginning with "1.". | ||
+ | |||
+ | Examples of how to use them to replace OpenSim notecard API methods: | ||
+ | |||
+ | osMakeNotecard (name, contents) => xmrScriptDBWriteLines (llGetLinkNumber() + "." + name, contents) | ||
+ | |||
+ | osGetNotecardLine (name, line) => xmrScriptDBReadLine (llGetLinkNumber() + "." + name, line, "ERROR!", "\n\n\n") | ||
+ | |||
+ | osGetNotecard (name) => xmrScriptDBReadOne (llGetLinkNumber() + "." + name, "ERROR!") | ||
+ | |||
+ | osGetNumberOfNotecardLines (name) => xmrScriptDBNumLines (llGetLinkNumber() + "." + name) |
Revision as of 07:41, 7 April 2018
These API methods are available as an alternative to using the OpenSim notecard API methods. They provide access to persistent storage that scripts can use to save information. The information is stored and retrieved as name/value pairs. The name is a string up to 233 characters and the value can be up to 65535 characters. Name/value pairs written by one script in an object can be accessed by any script in the same object (including other linked prims). They cannot be accessed by other objects.
These methods access persistent storage as lists of lines, similar to the OpenSim notecard API methods.
Write the list as a series of lines to the named persistent data element. xmrScriptDBWriteLines (string name, list contents) Input: name = name of persistent element contents = list of lines to write to element Note: If persistent element with same name already exists, it is overwritten
Read a single line from an element written by xmrScriptDBWriteLines() string xmrScriptDBReadLine (string name, integer line, string notfound, string endoffile) Input: name = name as passed to xmrScriptDBWriteLines() line = line number (starting with 0) notfound = what string to return if there is no persistent element name found endoffile = what string to return if line is beyond end of list written Output: returns notfound, endoffile, or list element line from persistent element name
Get the number of lines in an element written by xmrScriptDBWriteLines() integer xmrScriptDBNumLines (string name) Input: name = name as passed to xmrScriptDBWriteLines() Output: returns -1 if not found or number of lines if found
Get list of all lines in an element written by xmrScriptDBWriteLines() list xmrScriptDBReadLines (string name, list notfound) Input: name = name as passwd to xmrScriptDBWriteLines() notfound = list to return if not found Output: returns notfound or list of lines in element
These methods access persistent storage as a single (possibly long and/or multi-lined) string
Write a string to a persistent element: xmrScriptDBWrite (string name, string value) Input: name = name of persistent element to write value = string to write to persistent element Note: If persistent element with same name already exists, it is overwritten
Read a single persistent element as one whole string: string xmrScriptDBReadOne (string name, string notfound) Input: name = as passed to xmrScriptDBWrite() notfound = what to return if element not found Output: returns notfound or value as passed to xmrScriptDBWrite()
Number of element that match the given key integer xmrScriptDBCount (string keylike) Input: keylike = search key to match persistent element names Output: returns number of matching elements
List of elements that match the given key list xmrScriptDBList (string keylike, integer limit, integer offset) Input: keylike = search key to match persistent element names limit = maximum number of element names to return offset = number of element names to skip before returning any Output: returns list of matching names (might be empty list)
Read multiple elements that match the given key array xmrScriptDBReadMany (string keylike, integer limit, integer offset) Input: keylike = search key to match persistent element names limit = maximum number of elements to return offset = number of elements to skip before returning any Output: returns array of elements found as name/value pairs (might be empty array)
Delete elements that match the given key integer xmrScriptDBDelete (string keylike) Input: keylike = search key to match persistent element names Output: returns number of elements deleted (might be zero)
In the above, keylike is a MySql style LIKE parameter. Use % to indicate matching any number of characters in the element name, use _ to indicate matching exactly one character of the element name. For example, "%" matches all names, "1.%" matches all names beginning with "1.".
Examples of how to use them to replace OpenSim notecard API methods:
osMakeNotecard (name, contents) => xmrScriptDBWriteLines (llGetLinkNumber() + "." + name, contents)
osGetNotecardLine (name, line) => xmrScriptDBReadLine (llGetLinkNumber() + "." + name, line, "ERROR!", "\n\n\n")
osGetNotecard (name) => xmrScriptDBReadOne (llGetLinkNumber() + "." + name, "ERROR!")
osGetNumberOfNotecardLines (name) => xmrScriptDBNumLines (llGetLinkNumber() + "." + name)