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:
- Touch Toggle CONTROLLER TEMPLATE.lsl – A controller script!
- Fountain PARTICLE TEMPLATE.lsl – Simple fountain script.
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.
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:
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!
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.
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!