Change font size
It is currently Sat Dec 15, 2018 12:57 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: Automatic Light.
PostPosted: Sun Mar 22, 2009 3:57 pm 
User avatar

Joined: Sat Nov 22, 2008 6:21 pm
Posts: 31
Here are 3 scripts ported from SL.
One controler script (It 'sees' the position of the sun.) and one light script (gives light...amazing isn't it;-) ) and a glow script (makes a lightbulb glow)

The controller script:
{L_CODE}:
//// "Night Sensor" CONTROLLER TEMPLATE v1 - by Jopsy Pendragon - 4/8/2008
//// You are free to use this script as you please, so long as you include this line:
//** The original 'free' version of this script came from THE PARTICLE LABORATORY. **//

// EFFECT: Checks sun's position once a minute to see if it is NIGHTTIME.

// SETUP: Drop this CONTROLLER TEMPLATE script into the same object with
// your PARTICLE TEMPLATE. It will detect day or night in 60 seconds.

integer ON_AT_NIGHT = TRUE; // Set to FALSE for on during the day & off at night.

vector sunpos;
integer mode;
integer last_check=-1;

string CONTROLLER_ID = "A"; // see more about CONTROL TEMPLATES at end.

default {
state_entry() {
// Don't be a lagtard! Checking more than every 60 seconds is greedy:
llSetTimerEvent(60.0);
}

timer() {
sunpos = llGetSunDirection();

if ( sunpos.z < 0.0 )
mode = ON_AT_NIGHT;
else
mode = ! ON_AT_NIGHT;

if ( mode != last_check ) {
llMessageLinked( LINK_SET, mode, CONTROLLER_ID, NULL_KEY ); // send command
last_check = mode;
}
}
}

//========================================================================
//======================== USING CONTROL TEMPLATES =======================
//
// To use: Drop this CONTROLLER TEMPLATE script into the same object with
// your PARTICLE TEMPLATE. It should be operational immediately.
//
// By default, control templates will turn EVERY particle template in the
// same object ON or OFF. If you want particle templates to only listen
// to specific controller templates, then give both matching CONTROLLER_ID's,
// (something other than "A", like: "B" for example).

//======================================== END ===============================


The light script:
{L_CODE}:
//// "Light" EFFECT TEMPLATE v1 - by Jopsy Pendragon - 4/8/2008
//// You are free to use this script as you please, so long as you include this line:
//** The original 'free' version of this script came from THE PARTICLE LABORATORY. **//

// SETUP: Use with particle lab Controller Templates to activate/deactivate.

// Causes the prim to emit light, illuminating nearby avatars, prims and ground.

// Customize the particle_parameter values below to create your unique
// effect and click SAVE.

// PURPOSE: This script will enable/disable and adjust the LIGHT emitted by a prim.

// NOTE: This is not a particle effect.

vector color = <1.00,0.50,0.50>; // red, green and blue values 0.00(dark) to 1.00(bright)
float intensity = 0.75; // % brightness: 0.0 to 1.0
float radius = 10.00; // range/distance of light: 0.0 to 20.0 meters
float falloff = 0.5; // % brightness at max distance 0.00 to 1.00

string CONTROLLER_ID = "A"; // See comments at end regarding CONTROLLERS.
integer AUTO_START = FALSE; // Optionally FALSE only if using CONTROLLERS.

rotation adjustment = ZERO_ROTATION;

default {
state_entry() {

if ( AUTO_START )
llSetPrimitiveParams( [PRIM_POINT_LIGHT, TRUE, color , intensity, radius, falloff]);

}

link_message( integer sibling, integer num, string mesg, key target_key ) {
if ( mesg != CONTROLLER_ID ) { // this message isn't for me. Bail out.
return;
} else if ( num == 0 ) { // Message says to turn particles OFF:
llSetPrimitiveParams( [PRIM_POINT_LIGHT, FALSE, ZERO_VECTOR , 0.0, 0.0, 0.0 ]);
} else if ( num == 1 ) { // Message says to turn particles ON:
llSetPrimitiveParams( [PRIM_POINT_LIGHT, TRUE, color , intensity, radius, falloff]);
} else { // bad instruction number
// do nothing.
}
}

}

// for more visit:

// http://rpgstats.com/wiki/index.php?title=LlSetPrimitiveParams
// http://wiki.secondlife.com/wiki/LlSetPrimitiveParams
// http://lslwiki.net/lslwiki/wakka.php?wakka=llSetPrimitiveParams


And the glow script:
{L_CODE}:
//// "Glow" EFFECT TEMPLATE v1 - by Jopsy Pendragon - 4/8/2008
//// You are free to use this script as you please, so long as you include this line:
//** The original 'free' version of this script came from THE PARTICLE LABORATORY. **//

// SETUP:  Drop one optional particle texture and this script into a prim.
// Particles should start automatically. (Reset) the script if you insert a
// particle texture later on.  Add one or more CONTROLLER TEMPLATES to any
// prims in the linked object to control when particles turn ON and OFF.

// Rotate the prim to direction of spray.

// Customize the particle_parameter values below to create your unique
// particle effect and click SAVE.  Values are explained along with their
// min/max and default values further down in this script.

// PURPOSE:  This script will start a client side "spin" effect on any prim it's
// added to.  (the whole object will spin if added to root prim).
// This is an 'illusionary' effect, not a physical one.

// !!! NOTE !!! -->  This is not a PARTICLE effect!  This sets GLOW on the faces of a prim! =)
// Setting GLOW on a prim is a very new LSL feature.  This script may become obsolete
// if there are changes in LSL to how GLOW is set.


integer side = ALL_SIDES; // replace with a digit to affect one side of the prim.
float intensity = 0.50; // 0.00(no-glow) to 1.00(max)

string  CONTROLLER_ID = "A"; // See comments at end regarding CONTROLLERS.
integer AUTO_START = FALSE;   // Optionally FALSE only if using CONTROLLERS.


default {
    state_entry() {
       
        if ( AUTO_START ) llSetPrimitiveParams( [25, ALL_SIDES, 0.0 ]); 
       
    }
   
    link_message( integer sibling, integer num, string mesg, key target_key ) {
        if ( mesg != CONTROLLER_ID ) { // this message isn't for me.  Bail out.
            return;
        } else if ( num == 0 ) { // Message says to turn particles OFF:
           
            llSetPrimitiveParams( [PRIM_GLOW, side, 0.0 ]); 
           
        } else if ( num == 1 ) { // Message says to turn particles ON:
           
            llSetPrimitiveParams( [PRIM_GLOW, side, intensity ]); 
       
        } else { // bad instruction number
            // do nothing.
        }           
    }
       
}

// for more on setting prim attributes, visit:

// http://rpgstats.com/wiki/index.php?title=LlSetPrimitiveParams
// http://wiki.secondlife.com/wiki/LlSetPrimitiveParams
// http://lslwiki.net/lslwiki/wakka.php?wakka=llSetPrimitiveParams


I hope this is usefull for somebody...Have fun with it;-)

_________________
El presidente of the Republic of Hannaghbha.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net