Jump to content

Monahan McMillan

Resident
  • Posts

    3
  • Joined

  • Last visited

Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks to you all for your suggestions and corrections. I might indeed aim a bit high for my poor scripting skills, but it is thanks to your help that I can improve them. I am still looking to make it work with a do... while loop, but still can't make it work yet.
  2. Thanks for the tip. Sorry for the delay. Did that but doesn't work as expected, sounds are playing even if nobody is sitting... vector sit_position = <0.0, 0.0, -0.1>; // here an euler rot vector sit_rotation = <0.0, 0.0, 0.0>; 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() { llSitTarget(sit_position, llEuler2Rot(sit_rotation * DEG_TO_RAD)); 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) { key sittingAvatar = llAvatarOnSitTarget(); if (sittingAvatar == NULL_KEY) { llStopSound(); return; } string sound = llList2String( soundnames, llFloor(llFrand( sounds )) ); llPlaySound(sound, volume); }}
  3. 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);}}}
×
×
  • Create New...