Wednesday, February 12, 2014

Script: Simple Light Controller

:: BLACK TULIP SIMPLE LIGHT CONTROLLER ::
:: Turn on/off all your light points with one script ::


Simple Light Controller at Marketplace
By Auryn Beorn (2012)

TABLE OF CONTENTS



PURPOSE AND FEATURES


The purpose of the "[Black Tulip] Simple Light Controller" script is to allow you to:

  • Define one or many "light points" in your linked object
  • Determine which color the light point will be
  • Determine the intensity, radius and fall off for the light point
  • Turn the light points on/off by clicking the object
  • Optionally, turn on/off the full bright feature at the same time the light is activated/deactivated

Everything is controlled by a single script, so you can have as many light points as you wish in the same object at low lag cost.

But as you can see, this box contains four full permissions scripts, separated in two blocks:

  • [Black Tulip] Light on/off (AU)
  • [Black Tulip] Light on/off (OO)

Both scripts perform the same action: On touch, it turns on/off the lights in the defined light points.
The difference between them is:

  • AU -> All Users - Everybody will be able to turn on/off the lights by clicking the object.
  • OO -> Owner Only - Only the owner of the object will be able to turn on/off the lights by clicking the object.

  • [Black Tulip] Light on/off + FB (AU)
  • [Black Tulip] Light on/off + FB (OO)

Both scripts perform the same action: On touch, it turns on/off the lights AND the full bright property in the defined light points.

The difference between them is:

  • AU -> All Users - Everybody will be able to turn on/off the lights AND the full bright property by clicking the object.
  • OO -> Owner Only - Only the owner of the object will be able to turn on/off the lights AND the full bright property by clicking the object.

INSTALL AND USE YOUR LIGHT CONTROLLER


In order to have this system working in your object, you have to:
  • Decide which are the "light points" in your linked object
  • Give those primitives a *description* having the following format:
light;color;intensity;radius;falloff
where:

light  This word is written as is (case sensitive!)
color  A valid color for a LSL script (check the note below - there's an included tool to make this task *fast and easy*)
intensity  The intensity of the light point - Valid values range from 0.0 to 1.0
radius  The radius of the light point - Valid values range from 0.0 to 20.0
falloff  The falloff of the light point - Valid values range from 0.0 to 2.0

An example of valid description following the rules above:
light;<1,0.796078,0.592157>;1;5;0.75

This package includes the [Black Tulip] Color HUD tool for you easily writing a color correctly in this part. Check this link for all the "how's" (the documentation.)

YES: Each light point may have different colors, intensities, radius and falloff
Just set the description as you wish them, for each prim that will be a light point

Drop ONE of the following scripts:

  • [Black Tulip] Light on/off (AU)
  • [Black Tulip] Light on/off (OO)
  • [Black Tulip] Light on/off + FB (AU)
  • [Black Tulip] Light on/off + FB (OO)

in the "Content" tab of your object.

That's it. As soon as the script is dropped, it looks for all the defined light points and from that moment, clicking will turn/off all of them (and the full bright property, if the "FB" version of this script is used.)

IMPORTANT: Given to some scripting limits, if the descriptions are changed to modify the properties of the light, you should RESET the script. Keep this in mind when you design your own objects for sale, to instruct your customer to reset the script. If the description changes, this is a change not detected by a script - that's why we have to do it manually.

In case of doubt about its use, check the included sample object "[Black Tulip] Tiffany Lamp 1" and its setup.