User:Fred Gandt/Scripts
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
My Contributions
If unsure about how to use these scripts
I have implemented a version number system to make it more obvious if a script is updated. The V# is a comment at the top of each script.
If you have any comments about the content of this page please post them HERE
All my scripts are written for compilation as MONO
More Scripts
- Direct Links To All Individual Scripts
- Free Scripts
- Free Scripts 2
- Free Scripts 3
- Free Scripts 4
- Free Scripts 5
- Free Scripts 6
- Free Scripts 7
- Car Type Land Vehicle Scripts (working on it...)
- Functions For Specific Tasks
Legal Stuff
The legal stuff about contributing to this wiki. (worth reading)
PJIRA Issue Tracker
The issues I have filed on the PJIRA
Tuition
Tuition scripts, notes, videos and screenshots etc. (hardly any content yet)
Free Scripts
Basic Light Switch
Placed in the root of a linked object this script will make the whole object active to touch. The light will always be emitted by the prim the script is in. So, if you have a 5 prim lamp, put this in the "bulb" prim and make that prim the root. If placed in a child prim of an object, only that prim will be clickable (unless there are other touch scripts in other prims of the object).
<syntaxhighlight lang="lsl2">// V1 //
vector color = <1.0, 1.0, 1.0>; // R,G,B ( red, green, blue ) values.
float intensity = 1.0; // 0.0 to 1.0 ( 1.0 = full brightness )
float radius = 20.0; // 0.1 to 20.0 ( 20.0 = full sphere )
float falloff = 0.01; // 0.01 to 2.0 ( 2.0 = least spread )
/////////////////////////////////////////////////////////////////////////
integer on; // Global variable used to measure the condition "on" or "off".
Switch() {
// The switching function. on = !on; // Flip the boolean value of the integer "on". // Set the prim's light emitter on or off, dependant on the value of "on". llSetPrimitiveParams( [ PRIM_POINT_LIGHT, on, color, intensity, radius, falloff ] );
}
default {
touch_end( integer nd ) { // If clicked, Switch(); // unconditionally call the switch to operate. }
}</syntaxhighlight>
Basic Alpha (transparency) SHOW/HIDE
<syntaxhighlight lang="lsl2">// V1 //
string command = "switch"; // Place the command to chat here. The same command will switch on and off.
integer channel = 1; // Place channel to use here ( must be positive if an avatar is chatting on it ).
//////////////////////////////////////////////////////////////////////////////////////////////////////
integer on; // Store the state of transparency.
Switch() {
llSetLinkAlpha( LINK_SET, ( float )on, ALL_SIDES ); // This setting will turn a whole link_set transparent or visible. on = !on; // Flip the boolean value of the integer "on".
}
default {
state_entry() { llListen( channel, "", "", command ); // This script is listening to everyone all the time. // llListen( channel, "", llGetOwner(), command ); // Delete the "//" at the beginning of this line... // ...and add "//" at the beginning of the line above... // ...to make This script listen to only the owner. } // Switching the listen off at times would be better to reduce lag. But when?? touch_end( integer nd ) { // if ( llDetectedKey( 0 ) == llGetOwner() ) // Delete the "//" at the beginning of this line to make touches only respond to owner. Switch(); // Call the switching function. } listen( integer chan, string name, key id, string msg ) { Switch(); // Call the switching function. }
}</syntaxhighlight>
Basic Particle Candle Flame ON/OFF
This script will make the prim it is in a small glowing sphere that sits at the center of the flame.
<syntaxhighlight lang="lsl2">// V1 //
integer on; // Establish "on" as a global variable so that we can remember whether or not the flame is on.
Flame( integer num ) {
// Do we or don't we make a flame? "num" is either TRUE or FALSE ( 1 or 0 ). if ( num ) { // Make the flame since the condition above was met. llParticleSystem( [ PSYS_PART_FLAGS, 275, PSYS_SRC_PATTERN, 4, PSYS_PART_START_ALPHA, 0.6, PSYS_PART_END_ALPHA, 0.0, PSYS_PART_START_COLOR, <1.0, 1.0, 0.3>, PSYS_PART_END_COLOR, <0.8, 0.6, 0.6>, PSYS_PART_START_SCALE, <0.04, 0.07, 0.0>, PSYS_PART_END_SCALE, <0.04, 0.04, 0.0>, PSYS_PART_MAX_AGE, 0.3, PSYS_SRC_MAX_AGE, 0.0, PSYS_SRC_ACCEL, <0.0, 0.0, 0.02>, // These are the parameters of the particle effect. PSYS_SRC_ANGLE_BEGIN, 0.0, PSYS_SRC_ANGLE_END, 0.0, PSYS_SRC_BURST_PART_COUNT, 50, PSYS_SRC_BURST_RATE, 0.07, PSYS_SRC_BURST_RADIUS, 0.0, PSYS_SRC_BURST_SPEED_MIN, 0.001, PSYS_SRC_BURST_SPEED_MAX, 0.4, PSYS_SRC_OMEGA, <0.0, 0.0, 0.0>, PSYS_SRC_TARGET_KEY, ( key )"", PSYS_SRC_TEXTURE, "" ] ); llSetPrimitiveParams( [ PRIM_POINT_LIGHT, TRUE, <1.0, 0.8, 0.3>, 0.5, 2.0, 1.9, // For extra effect we switch the light on too. PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.1, // And set the transparency to slightly visible, PRIM_GLOW, ALL_SIDES, 0.1 ] // and the glow to slight. ); } else { // "num" was not 1 ( TRUE ) so we need to stop the effect or not start it. llParticleSystem( [] ); // Make no particles ( no flame ). llSetPrimitiveParams( [ PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR, 0.0, 0.0, 0.0, // Switch the light off. PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0, // And set the transparency to invisible, PRIM_GLOW, ALL_SIDES, 0.0 ] // and the glow to zero. ); } on = num; // Establish the value of the global variable "on" as being equal to the task we just performed. This acts as our memory.
}
default { // Create a state for the code to run in.
state_entry() { // These instructions will change the size, shape and texturing of the prim the script is in. llSetPrimitiveParams( [ PRIM_TYPE, PRIM_TYPE_SPHERE, 0, <0.0, 1.0, 0.0>, 0.0, ZERO_VECTOR, <0.0, 1.0, 0.0>, // Make the prim a sphere. PRIM_SIZE, <0.01, 0.01, 0.03>, // Make the prim the right size to act as the glowing center of the flame. PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, ZERO_VECTOR, ZERO_VECTOR, 0.0 ] // Set the blank texture. ); // Make the candle flame ignite. Flame( TRUE ); // Flame( TRUE ); Is an order to run the code "Flame" with the integer value "TRUE" ( numerical value = 1 ). } touch_end( integer detected ) { // Detect if we have touched the candle. Flame( !on ); // We now order that the Flame() code is run with the integer value that is the opposite of what it already is. // "!on" = FALSE if on = TRUE and TRUE if on = FALSE. The "!" means "not". }
}</syntaxhighlight>
Simple Timer Alarm
Good for reminding you about sandbox returns etc. Ideally worn as a single prim HUD attachment.
<syntaxhighlight lang="lsl2">// V3 //
string alarm = "5e1d5f52-e7ae-0194-a412-93a96f39ff6f"; // Name of the sound in the object inventory.
// Or the UUID of any sound.
float volume = 0.5; // Values between "0.0" and "1.0".
vector passive = <0.0, 0.0, 1.0>; // Color for prim when timer is off.
vector active = <0.0, 1.0, 0.0>; // Color for prim when timer is running.
vector alarmed = <1.0, 0.0, 0.0>; // Color for prim when alarm is sounding.
integer on; // Used to store if the timer is running.
default {
on_rez( integer param ) { llResetScript(); } state_entry() { llStopSound(); llSetColor( passive, ALL_SIDES ); llSetObjectName( "Alarm" ); } touch_end( integer nd ) { if ( on ) { llResetScript(); } else { float time = ( float )llGetObjectDesc() * 60; // Time established from the prim description. if ( time < 1.0 ) { llOwnerSay( "The time is not set.\nPlease write the time into the object description and try again" ); return; } llSetColor( active, ALL_SIDES ); llOwnerSay( "/me is set to sound in " + ( string )llRound( time / 60 ) + " minutes." ); llSetTimerEvent( time ); on = TRUE; llPreloadSound( alarm ); } } timer() { llSetTimerEvent( 0.0 ); llLoopSound( alarm, volume ); llSetColor( alarmed, ALL_SIDES ); }
}</syntaxhighlight>
Floating on Water (very beta)
This creates a movement sort of like a floating lantern. But it needs a lot of work before I will consider it even close to done.
<syntaxhighlight lang="lsl2">// V2 //
float limit = 10.0; // This is the radius that the object is allowed to drift up to.
// 20.0 would be a 40 meter circle.
float offset = 0.0; // Use this float to offset the height of the object in relation to the water surface. // The object will (when the offset is zero) float with its geometric center at the level of the water surface.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
float float_height;
vector home;
FloatAbout( vector pos ) {
llSetTimerEvent( limit ); @a; float num_x = llFrand( limit / 2 ) - ( limit / 4 ); float num_y = llFrand( limit / 2 ) - ( limit / 4 ); vector target = <( pos.x + num_x ), ( pos.y + num_y ), float_height>; if ( llVecDist( target, home ) <= limit ) { llMoveToTarget( target, limit * 1.5 ); } else { jump a; }
}
default {
on_rez( integer param ) { llResetScript(); } state_entry() { float_height = llWater( ZERO_VECTOR ) + offset; llSetStatus( STATUS_ROTATE_X
More Scripts...
- Direct Links To All Individual Scripts
- Free Scripts
- Free Scripts 2
- Free Scripts 3
- Free Scripts 4
- Free Scripts 5
- Free Scripts 6
- Free Scripts 7
- Car Type Land Vehicle Scripts (Working on it...)
If you have any comments about the content of this page please post them HERE