Over the six years that I have been building and programming in Second Life I’ve built up a reasonable arsenal of tools and techniques for making life as a builder just that little bit easier. No one thing that is the magic bullet but added up they can make a difference to the time and ease that a build comes together. Tips, Tricks & Gadgets is where I intend to share these.
One of the things I often need to define in a script is colour, more often than not for floating text though other functions can require colour as well, e.g a particle system or a texture tint. LSL uses a vector to store colour values but in its wisdom doesn’t use 0 to 255 to define the RGB colour channels. Instead each value is defined from 0.0 to 1.0, so where white in traditional RGB would be <255, 255, 255>, in LSL it is <1.0, 1.0, 1.0>. To make it simple to translate the values I have created a small gadget called Isa’s Colour Vector.
To display the colour vector one changes the prim colour through the build window. This automatically changes the floating text to the selected colour, displays the vector values and sends the owner a message in chat with the vector values so they may be copied and pasted.
The second small gadget is one that may not often be used in educational builds but it definitely has a place in the “for fun” builds I become involved with. It had often seemed incongruous to me that torches meant to light paths at night were burning in broad daylight, so I was delighted when I discovered there’s a function for getting the time of day in Second Life. I now commonly use this function for lights, torches, or other effects that I only want to come on at night.
The code block used to work this effect runs a timed event that checks the sun’s postion above or below the horizon using the llGetSunDirection() function. If the Z value is positive the sun is above the horizon, if negative it is below and night has fallen.
vector wheresSun = llGetSunDirection();
if(wheresSun.z > 0.0)
// Turn off effect
// Turn on effect
Now more often than not I don’t want the effect to start only after the sun has gone below the horizon. In fact some effects I want to turn off and on at different times of the day, e.g. a mist over a lake or river that starts pre-dawn and fades off in the late morning. For these effects I need easy access to the Z value of the llGetSunDirection() vector when deciding what value I test in the if(wheresSun.z > sun’s Z position) statement. That’s why I built Isa’s Sun/Moon Vector. With this gadget rezzed I have access to the vector at the touch of a prim, both as floating text and sent to the owner via chat and can visually decide inworld exactly what time I want the effect to activate.
Both these gadgets are available from my Second Life Workshop (see Virtually Related links). They have been set to allow anyone to copy so right click and select Take Copy to receive them in your Inventory.