Controller scripts....

Mini tutorial: About Controller Scripts.

Controller scripts....
Controller scripts….

Here is a quick tutorial about controller scripts.
With these ‘controller’ scripts you can control other scripts: Touch a light switch to turn on lights, Fly and your jet-boots start to puff smoke, turn a shower on or off, etc, etc.

And using these scripts are actually very easy!

First you need a couple of scripts.

This zip-file contains 2 scripts:

  1. Touch Toggle CONTROLLER TEMPLATE.lsl – A controller script! :-)
  2. Fountain PARTICLE TEMPLATE.lsl – Simple fountain script.

I have more scripts in-world in my learning center on Metropolis. Login and grab them for free.
The scripts are made by Jopsy Pendragon, not by me:-)

How to use these scripts.
Build a prim and drop both scripts in the content tab of the prim. Done!

Touch the prim and voilà; a fountain!

Touch the prim again and the fountain stops.

~OR~

Build a fountain. Put the Fountain PARTICLE TEMPLATE.lsl script in the part that you want to spray water. Select all the parts of the fountain and link it.
Now build a prim with an on/off switch and put the Touch Toggle CONTROLLER TEMPLATE.lsl script in it.

Select the fountain, hold down the ‘SHIFT key’ and select the on/off switch.
Link this together.

Things that can be changed in the script.
There are some parameters that can be changed in the scripts:

Controller ID.
You will find the following line at the top of controller and the TEMPLATE scripts. This line of code tells which controller what thing to control. Let’s say you have a house with rooms, and you want to have separate lamps in those rooms.
By changing the controller ID, you can create separate light switches.

string  CONTROLLER_ID = “A”;

Notice the A in that line of code? The A is the ID of this controller, and controls all scripts that are in the linked object that have the same ID.
You can change this in to something else, make sure you change them in both scripts! And it’s case-sensitive too!

Auto Start.
In the TEMPLATE script, there is a line you can change:

integer AUTO_START = TRUE;

This makes the particle start when you save the script. This is OK if you don’t use a controller.
Set it to FALSE if you use a controller.

Sound.
You can use a sound file, or not.

integer PLAY_SOUND = TRUE; // TRUE for a click-sound, FALSE for silent.
string SOUND = “bac3e333-9624-4b1a-ade2-d2b01d5960aa”; // a click sound

Set PLAY_SOUND to FALSE to turn sound off.
Replace the UUID (That bunch of letters and numbers) with another UUID.

That’s it! You can create lots of cool stuff with these script!
Have fun.

Oddy

One thought on “Mini tutorial: About Controller Scripts.”

  1. Hey Odd, if you want to use both scripts in one prim, you really only need one script too. I always try to minimize the number of scripts I use to optimize resources.
    Usually the control scripts are used if you want to be able to touch one prim, but affect change in another. Like lighting a fire and up on the roof smoke comes out of the chimney when the fire burns. Just saying…

Leave a Reply to Eryn Cancel reply