Difference between revisions of "User:ANSI Soderstrom"
Jump to navigation
Jump to search
Line 95: | Line 95: | ||
string GET(list ARRAY,list KEY) { | string GET(list ARRAY,list KEY) { | ||
if(llGetListLength(KEY)>1) { | if(!llGetListLength(KEY)>1) { | ||
return "-1"; | return "-1"; | ||
} | } | ||
Line 108: | Line 108: | ||
return llList2String(ARRAY,position+1); | return llList2String(ARRAY,position+1); | ||
} else { | } else { | ||
return " | return "0"; | ||
} | } | ||
} | } | ||
Line 114: | Line 114: | ||
list PUT(list ARRAY,list KEY, list VALUE) { | list PUT(list ARRAY,list KEY, list VALUE) { | ||
if(llGetListLength(KEY)>1 || llGetListLength(VALUE)>1) { | if(llGetListLength(KEY)>1 || llGetListLength(VALUE)>1) { | ||
return [ | return []; | ||
} | } | ||
integer position = llListFindList(ARRAY,KEY); | integer position = llListFindList(ARRAY,KEY); | ||
Line 122: | Line 122: | ||
ARRAY += KEY; | ARRAY += KEY; | ||
ARRAY += VALUE; | ARRAY += VALUE; | ||
} | } | ||
return ARRAY; | return ARRAY; | ||
} | } | ||
default | default { | ||
{ | state_entry() { | ||
state_entry() | |||
SOMELIST = ["KEY","VALUE"]; | SOMELIST = ["KEY","VALUE"]; | ||
Line 162: | Line 161: | ||
// Output : 9adba1b4-a733-4a44-8275-f4a666784d8c | // Output : 9adba1b4-a733-4a44-8275-f4a666784d8c | ||
llSay(0,GET(SOMELIST,[AGENT])); | llSay(0,GET(SOMELIST,[AGENT])); | ||
// Output : ANSI Soderstrom | // Output : ANSI Soderstrom | ||
} | |||
llSay(0,GET(SOMELIST,["NotInList"])); | |||
// Output : 0 | |||
if(!(integer)GET(SOMELIST,["Not In List"])) { | |||
llSay(0,"Not in List"); | |||
} else { | |||
llSay(0,"Found"); | |||
} | |||
// Output : Not in List | |||
if(!(integer)GET(SOMELIST,["KEY"])) { | |||
llSay(0,"Not in List"); | |||
} else { | |||
llSay(0,"Found"); | |||
} | |||
// Output : Found | |||
} | |||
} | } | ||
</lsl> | </lsl> |
Revision as of 10:36, 24 February 2010
i am alive ! ...and have for you :
A #Simple Copy Protection for your Scripts.
A #LSL Array for your Scripts.
Simple LSL Copy Protection for your Scripts (best give away as no mod) :
<lsl> // Simple Copy Protection for your Items // (C) 10/2009 ANSI Soderstrom
default {
state_entry() { if(llGetCreator() != "9adba1b4-a733-4a44-8275-f4a666784d8c") { // ANSI Soderstrom llOwnerSay("Script: " + llGetScriptName() + ":"); llOwnerSay("Sorry, my Scripts are only running in MY Items"); llOwnerSay("Greetings, ANSI Soderstrom"); // llDie(); } else { state online; } }
on_rez(integer i) { llResetScript(); }
}
state online {
state_entry() { // your Code } on_rez(integer i) { llResetScript(); }
} </lsl>
LSL Array for your Scripts :
<lsl> list SOMELIST;
string GET(list ARRAY,list KEY) {
if(!llGetListLength(KEY)>1) { return "-1"; } integer position; do { position = llListFindList(ARRAY, KEY); if(position%2 && ~position && position) { ARRAY = llDeleteSubList(ARRAY,0,position); } } while (~position && position%2); if(~position) { return llList2String(ARRAY,position+1); } else { return "0"; }
}
list PUT(list ARRAY,list KEY, list VALUE) {
if(llGetListLength(KEY)>1 || llGetListLength(VALUE)>1) { return []; } integer position = llListFindList(ARRAY,KEY); if(~position) { ARRAY = llListReplaceList(ARRAY, VALUE, position + 1, position + 1); } else { ARRAY += KEY; ARRAY += VALUE; } return ARRAY;
}
default {
state_entry() { SOMELIST = ["KEY","VALUE"];
SOMELIST = PUT(SOMELIST,[AGENT],[<1,1,1>]); llSay(0,GET(SOMELIST,["KEY"])); // Output : VALUE llSay(0,GET(SOMELIST,[AGENT])); // Output : <1.000000, 1.000000, 1.000000> SOMELIST = PUT(SOMELIST,[AGENT],["test"]); llSay(0,GET(SOMELIST,["KEY"])); // Output : VALUE llSay(0,GET(SOMELIST,[AGENT])); // Output : test SOMELIST = PUT(SOMELIST,["KEY"],["9adba1b4-a733-4a44-8275-f4a666784d8c"]);
llSay(0,GET(SOMELIST,["KEY"])); // Output : 9adba1b4-a733-4a44-8275-f4a666784d8c llSay(0,GET(SOMELIST,[AGENT])); // Output : test SOMELIST = PUT(SOMELIST,[AGENT],[llKey2Name(GET(SOMELIST,["KEY"]))]);
llSay(0,GET(SOMELIST,["KEY"])); // Output : 9adba1b4-a733-4a44-8275-f4a666784d8c llSay(0,GET(SOMELIST,[AGENT])); // Output : ANSI Soderstrom llSay(0,GET(SOMELIST,["NotInList"])); // Output : 0 if(!(integer)GET(SOMELIST,["Not In List"])) { llSay(0,"Not in List"); } else { llSay(0,"Found"); } // Output : Not in List if(!(integer)GET(SOMELIST,["KEY"])) { llSay(0,"Not in List"); } else { llSay(0,"Found"); } // Output : Found }
} </lsl>