SungAli

2-Light Control

Dec 1st, 2025 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Adjustable Constants
  2. integer CommandChannel = 594923831; //Randomly Chosen Channel Number.  Must Match for all controllers.  Change for different sets controls and responders.
  3. float OffDelay = 3;
  4.  
  5. //variables
  6. key Owner;
  7. integer ListenHandle;
  8.  
  9. //Functions
  10. LightsOn() {
  11.     llSetLinkPrimitiveParamsFast( LINK_THIS, [
  12.         PRIM_POINT_LIGHT, TRUE, <1.0, 1.0, 0.9>, 1.0, 10, 0.75,
  13.         PRIM_GLOW, ALL_SIDES, 0.2
  14.     ] );
  15. } // end LightsOn
  16.  
  17. LightsOff() { //Make it a nightlight instead of fully off.
  18.     llSetLinkPrimitiveParamsFast( LINK_THIS, [
  19.         PRIM_POINT_LIGHT, TRUE, <1.0, 1.0, 0.9>, 0.1, 3, 0.75,
  20.         PRIM_GLOW, ALL_SIDES, 0.02
  21.     ] );
  22. } // end LightsOn
  23.  
  24. //States
  25. default {
  26.     state_entry() {
  27.         Owner = llGetOwner();
  28.         ListenHandle = llListen( CommandChannel, "", NULL_KEY, "On");
  29.         LightsOff();
  30.     }
  31.    
  32.     on_rez( integer param ) { llResetScript(); }
  33.    
  34.     listen( integer channel, string name, key id, string message) {
  35.         //Ignore messages from objects with different owners.
  36.         if( llList2Key( llGetObjectDetails(id, [OBJECT_OWNER] ), 0 ) != Owner ) return;
  37.         if( message == "On" ) {
  38.             llListenRemove( ListenHandle ); //Only listen for the currently relevant command.
  39.             ListenHandle = llListen( CommandChannel, "", NULL_KEY, "Off");
  40.             LightsOn();
  41.         } else if( message == "Off" ) {
  42.            llListenRemove( ListenHandle ); //Only listen for the currently relevant command.
  43.             ListenHandle = llListen( CommandChannel, "", NULL_KEY, "On");
  44.             llSleep( OffDelay );
  45.             LightsOff();
  46.         } //else ignore unknown messages.
  47.     }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment