Greetings all,
I'm trying to "mix" two scripts to get random sounds to play whenever someone sits on an object. Still stuck somewhere in the compilation. Could anyone help please ?
Thanks.
Both scripts were found around here, the random sounds :
float MinimumSeconds = 10.0; // Minimum time between successive sounds (seconds)
float MaximumSeconds = 30.0; // Maximum time between successive sounds (seconds)
float volume = 0.5; // How loud? Between 0 and 1.
integer sounds = 0; // # sounds in inventory
list soundnames;
LoadSounds() {
soundnames = [];
sounds = llGetInventoryNumber( INVENTORY_SOUND );
integer n; for ( n=0; n < sounds; ++n ) { soundnames += llGetInventoryName( INVENTORY_SOUND, n ); }}
default {
state_entry() {
LoadSounds();
if ( sounds > 0 )
llSetTimerEvent( 0.1 );
else
llOwnerSay("No sounds."); }
timer() {
integer random = (integer) llFrand ( sounds );
string sound = llList2String( soundnames, random );
llTriggerSound( sound, volume );
llSetTimerEvent( MinimumSeconds + (llFrand( MaximumSeconds - MinimumSeconds)) ); }
changed (integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } }}
and the sound on sit
vector sit_position = <0.0, 0.0, -0.1>;// here an euler rotvector sit_rotation = <0.0, 0.0, 0.0>;default{state_entry(){llSitTarget(sit_position, llEuler2Rot(sit_rotation * DEG_TO_RAD));}changed(integer change){if (change & CHANGED_LINK){key sittingAvatar = llAvatarOnSitTarget();// when there's no avatar sitting, stop running code hereif (sittingAvatar == NULL_KEY) return;string firstSoundInPrim = llGetInventoryName(INVENTORY_SOUND, 0);llPlaySound("UUID", 1.0);}}}