Script:Wind Powered Random Sounds: Difference between revisions
Jump to navigation
Jump to search
Silent Mole (talk | contribs) Created page with "<lsl> →Sounds are played louder and faster as wind speed increases.: integer sounds = 0; // # sounds in inventory list soundnames; // names of sounds in inventory Lo…" |
Silent Mole (talk | contribs) No edit summary |
||
| Line 20: | Line 20: | ||
float GetWindStrength() | float GetWindStrength() | ||
{ | { | ||
return | return llVecMag(llWind(<ZERO_VECTOR>)) | ||
} | } | ||
Revision as of 08:58, 12 July 2012
<lsl> /*
Sounds are played louder and faster as wind speed increases.
- /
integer sounds = 0; // # sounds in inventory list soundnames; // names of sounds in inventory
LoadSounds() {
soundnames = [];
sounds = llGetInventoryNumber( INVENTORY_SOUND );
integer n;
for ( n=0; n < sounds; ++n )
{
soundnames += llGetInventoryName( INVENTORY_SOUND, n );
}
}
float GetWindStrength() {
return llVecMag(llWind(<ZERO_VECTOR>))
}
float GetVolume( float str ) {
return str * 0.1;
}
string GetASound() {
return llList2String(soundnames,(integer)llFrand( sounds ));
}
integer count = 0;
default {
state_entry()
{
LoadSounds();
if ( sounds > 0 )
llSetTimerEvent( 0.1 );
else
llOwnerSay("No sounds.");
}
timer()
{
float str = GetWindStrength();
++count;
if ( count > (integer)(10.0 - str) )
{
llTriggerSound( GetASound(), GetVolume(str) );
count = 0;
}
}
changed (integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}
} </lsl>