Projects » Rain with on off switch

// Two scripts in same prim:

// Script 1 the switch on off

// Script name: Rain on off

integer PLAY_SOUND = TRUE; // TRUE for a click-sound, FALSE for silent.
string SOUND = "64319812-dab1-4e89-b1ca-5fc937b8d94a"; // a click sound
string CONTROLLER_ID = "A"; // see more about CONTROL TEMPLATES at end.
integer mode = 0; // keep track of whether particles are ON(1) or OFF(0).

default {
touch_start(integer total_number) {

if ( PLAY_SOUND ) llPlaySound( SOUND, 1.0 );

mode = ! mode; // flip on to off, (or off to on).

llMessageLinked( LINK_SET, mode, CONTROLLER_ID, NULL_KEY ); // send command

}

// Listen for other controllers sending ON/OFF commands and remember changes:

link_message( integer sibling, integer num, string controller_id, key ignore ) {

if ( controller_id != CONTROLLER_ID ) return; // this message is not for us.

mode = num;

}

}

// ####################### EOF ##########################


// Script 2 the rain
// Script name: Rain


integer PLAY_SOUND = TRUE; // TRUE for a click-sound, FALSE for silent.
string SOUND = "64319812-dab1-4e89-b1ca-5fc937b8d94a"; // a click sound
string CONTROLLER_ID = "A"; // see more about CONTROL TEMPLATES at end.
integer mode = 0; // keep track of whether particles are ON(1) or OFF(0).

default {

touch_start(integer total_number) {

if ( PLAY_SOUND ) llPlaySound( SOUND, 1.0 );

mode = ! mode; // flip on to off, (or off to on).

llMessageLinked( LINK_SET, mode, CONTROLLER_ID, NULL_KEY ); // send command

}

// Listen for other controllers sending ON/OFF commands and remember changes:

link_message( integer sibling, integer num, string controller_id, key ignore ) {

if ( controller_id != CONTROLLER_ID ) return; // this message is not for us.

mode = num;
}
}

// ####################### EOF ##########################
Added by: Rakis Heron
Last Update: 5 years ago
Project Category: Other
👍 4 like

Code

File name Added By Last Updated Actions


Comments

No comments yet