User:Free Portal/Sandbox: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
Created page with 'Free's SandBox'
 
mNo edit summary
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
Free's SandBox
{{multi-lang}}
{{User:Free_Portal/Template:Wiki_Header}} {{RightToc}}
= SandBox =
<div id="box">
<div style="padding: 0.5em 0.5em 1.5em">
Usefull user function package for LSL
</div>
</div>
 
<div id="box">
== searchReplace ==
<div style="padding: 0.5em 0.5em 1.5em">
search replace string
<lsl>string searchReplace(string input, string old, string new) {
    return llDumpList2String(llParseString2List(input, [old], []), new);
}</lsl>
</div>
</div>
 
<div id="box">
== DEBUG ==
<div style="padding: 0.5em 0.5em 1.5em">
print debug message
<lsl>integer debug = TRUE;
 
string DEBUG(string msg) {
    if (DEBUG)
        llOwnerSay("__" + llGetObjectName() + " :: " + llGetScriptName() + " :: " + msg
}</lsl>
</div>
</div>
 
<div id="box">
== Get between String ==
<div style="padding: 0.5em 0.5em 1.5em">
get string of between 2 word
<lsl>string getBetweenString(string str, string pre, string suf) {
    if ((llSubStringIndex(str, pre) == -1) ||
        (llSubStringIndex(str, suf) == -1))
        return NULL_KEY;
    return llGetSubString(
            str,
            llSubStringIndex(str, pre) + llStringLength(pre),
            llSubStringIndex(str, suf)-1);
}</lsl>
</div>
</div>

Latest revision as of 05:58, 20 June 2010

SandBox

Usefull user function package for LSL

searchReplace

search replace string <lsl>string searchReplace(string input, string old, string new) {

   return llDumpList2String(llParseString2List(input, [old], []), new);

}</lsl>

DEBUG

print debug message <lsl>integer debug = TRUE;

string DEBUG(string msg) {

   if (DEBUG)
       llOwnerSay("__" + llGetObjectName() + " :: " + llGetScriptName() + " :: " + msg

}</lsl>

Get between String

get string of between 2 word <lsl>string getBetweenString(string str, string pre, string suf) {

   if ((llSubStringIndex(str, pre) == -1) ||
       (llSubStringIndex(str, suf) == -1))
       return NULL_KEY;

   return llGetSubString(
           str,
           llSubStringIndex(str, pre) + llStringLength(pre),
           llSubStringIndex(str, suf)-1);

}</lsl>