Wednesday, February 12, 2014

Script: Sound & Light via Menu

:: BLACK TULIP SOUND & LIGHT ::
:: Play a looped sound and turn the light on/off ::


Sound & Light via Menu at Marketplace
By Auryn Beorn (2012)

TABLE OF CONTENTS


*** IMPORTANT ***

For your fountain (or other build) being the less lag possible, please use the scripts and guidelines explained in the included free box "[Black Tulip] How to create ZERO LAG animated water" In there you will learn to create ZERO LAG animated water, which is the perfect complement for this script.

PURPOSE AND FEATURES

Perfect for fountains, this script allows you to give the following interactivity via menu:
  • Let the user start/stop a loopsound for the object
  • Let the user turn on/off the light from one linked prim that you decide
  • Change the volume of the sound
  • Change the color of the light, choosing one from ten predefined colors
  • Change the rest of parameters of the light (radius, intensity, falloff)
  • Change who can access to the menu (everybody/owner only/group)
Optionally, this script can be integrated as a module called by other scripts, such as MLP, AVsitter... All these features are controlled by a single, low lag script. This box contains four copy/transfer scripts:
  • [Black Tulip] Sound & Light - Access v.Menu
  • [Black Tulip] Sound & Light + FB - Access v.Menu
Both scripts work with the same menu structure. The difference between them is: "[Black Tulip] Sound & Light + FB - Access v.Menu" will, additionally, turn the "Full Bright" property of the light point ON/OFF together with the light itself.
  • [Black Tulip] Sound & Light - Access v.Menu [MODULE]
  • [Black Tulip] Sound & Light + FB - Access v.Menu [MODULE]
Same as the two scripts mentioned above, but you choose one from these two, in oder to be integrated as a module called by other scripts, as explained in the "THE MAIN SCRIPT, AS A MODULE YOU CAN USE FROM ANOTHER SCRIPT" section of this documentation.

INSTALL AND USE YOUR SOUND & LIGHT SCRIPT

In order to have any of these scripts working in your object, you have to:
  • Decide which primitive from your linkset will be the one emitting light
  • Change the *description* of this primitive to:
light
Note that the *description* is NOT the same as the *name*! We want here the *description*.
  • Drop in the object the sound clip that you want to be played looped when the sound is ON.
  • Drop the ONE script you want to use, from the four scripts available in the box.
Use only ONE script from the four in the box! The description in the previous section should help you decide which to use depending of your application. IMPORTANT: Don't forget to change permissions of these scripts AND your sound samples! Refer to the license of use for instructions to change the permissions of the script you use.

NOTES:

  • You may use this script no matter the object is a single prim, or several linked prims.
  • The light prim may be any of them (but only one.)
  • If there it is no sound clip in the primitive, a built-in sound will be played then.
    (If you don't want sound, there it is another tool that works only with light, not this one.)

THE MAIN SCRIPT, AS A MODULE YOU CAN USE FROM ANOTHER SCRIPT

There are some scripts which are a version of the main script, but ready so you can use this menu integrated with other tools you have that feature the ability of sending messages. You should choose ONE of the following main scripts:
  • [Black Tulip] Sound & Light - Access v.Menu [MODULE]
  • [Black Tulip] Sound & Light + FB - Access v.Menu [MODULE]
and drop it together with your system. Then you should modify your existing system to add a new entry in your menus, so when you click an option to open the menus from this tool, you should add the following code in your script/system:
llMessageLinked(LINK_THIS, -18640983, "message", toucherKey);
If you work with MLP, you can easily add a "Controller" button in the main menu by adding the following line in the .MENUITEMS notecard:
LINKMSG Controller | 1,-4,-18640983,fromMLP
fromMLP would be here the message passed in a llMessageLinked call. Your box has a .MENUITEMS notecard with this included, so you can study how and where to add it. Remember to restart your MLP for the notecard to be read. If you work with AVSitter is also easy to add a button in the main menu to open the menu. All what you have to do is to include a line such as:
BUTTON Controller|-18640983

in your AVpos notecard.

Your box has a AVpos notecard with this included, so you can study how and where to add it.