User:Omei Qunhua/Example Scripts
Compute a negative channel based on user id <lsl> // Global:- integer gChannel;
//state_entry etc. :-
gChannel = 0x80000000 | (integer) ( "0x" + (string) llGetOwner() );
</lsl>
Compute a random integer
<lsl> // 16777216 is the largest positive integer that can be accurately represented in a float in LSL // Using llFrand with larger number will start producing even numbers only, then eventually numbers divisible by 4, then 8 ... etc.
integer iRand = (integer) llFrand(16777215); </lsl>
Detect a long mouse click+hold for accessing special functionality
<lsl> default {
touch_start(integer num_detected) {
llResetTime();
} touch(integer num_detected) {
if (llDetectedKey(0) == llGetOwner() && llGetTime() > 1.0) { // The owner has touched this object for longer than 1 second // execute some special feature such as issuing a management dialog // ... }
} touch_end(integer num_detected) {
if (llGetTime() < 1.0) { // The user did a normal quick click on the object // execute actions for normal clicks // ... }
}
} </lsl>