| 灯光的开关效果脚本 作者:Tony 时间:2007-1-17 17:39:03 |
第 1 楼 |
// Sample touch lighting LSL script with color change capability - 07/07/2006 - 2fast4u Nabob // // * Permission granted to modify and create derivative works. // * If you sell this script, include attribution to 2fast4u Nabob, the author of // this script in your product's documentation and primary script. // // Provided "as is" // // Features: // // *Touch On/Off // *Listens to owner and allows the color of the light to be changed // *Low lag - listens to owner on touch only and cancels the listen after 30 seconds // // Instructions: // // 1.Place this script into a prim that you want to light-up when touched // 2. Thank 2fast4u Nabob for helping you //
// channel_num is the channel that the light listens on. Type /5555 ... to talk to the light integer channel_num=5555; // colorWords lists the colors that the light supports - add here and in colorVectors list colorWords=["white" , "red" , "green" , "blue"]; // colorVectors represent the color values that the light supports list colorVectors = [1 , 1 , 0 , 0];
// Don't edit anything below this line
integer isOn = FALSE; vector light_color;
integer listenHandle = 0;
// This makes it easier to change the light's parameters in one place setLightParameters() { llSetPrimitiveParams ([PRIM_POINT_LIGHT , isOn , light_color , 1.0 , 10.0 , 0.75]); }
default { on_rez(integer start_param) { llResetscript(); //Reset in case owner changed } state_entry() { light_color = llList2Vector(colorVectors , 0); //Set the initial color to white } touch_start(integer num_detected) { // If not already listening , start listening to the owner if(listenHandle == 0) { listenHandle = llListen(channel_num , "" , llGetOwner() , ""); llSetTimerEvent(30.0); } // Toggle the light on/off isOn = !isOn; // Set the light's parameters setLightParameters(); } timer() { // If the script is listening , stop listening and stop the timer to reduce lag if(listenHandle != 0) { llListenRemove(listenHandle); llSetTimerEvent(0.0); } } listen(integer channel , string name , key id , string message) { // The following IF statement is for the paranoid Not really necessary to check the // id against the owner , but no harm in doing it anyway if(channel != channel_num || id != llGetOwner()) return; // Look for what the user says in the list.... integer listLocation; listLocation = llListFindList(colorWords , [message]); // Did not find what the user said in the list? Stop here if(listLocation == -1) return; // found what the user said in the list , set the corresponding vector light_color = llList2Vector(colorVectors , listLocation); // set the light's parameters - does not change On/Off setting setLightParameters(); } }
|
|
|