Jump to content

Touch on/off Script Needing Help


Summer Logan
 Share

You are about to reply to a thread that has been inactive for 2939 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have a showering effects particle script that I've combined with a touch fx script so you can touch to turn the water on and off. I've already contacted the maker of the script but I'm thinking they aren't playing anymore or just not offering support. 

The problem I'm having is when I drag the shower out of my inventory it's already running and I have to touch twice to turn it off. I would like it if the shower came out of the inventory off and it's touch once for on and once for off.

I'm assuming the script resets on rez or something is happened on rez. Going to post the touch portion of the script because it was free but the particle portion I'm removing because it was purchased. 

If someone could just suggest what and where to edit so the shower rezzes from inventory off and requires a touch to be turned on and another to be turned off.

Thank you.

 

EDIT: Forgot to mention it doesn't matter if the shower is off when taking it into inventory it always rezzes out running.

///////////////////////////////////////////////
/////////////ANIMATION STATION 2011////////////
////////////////DRAKE FAUDEBURGH///////////////
///////////////////////////////////////////////
///////////////////READ THIS///////////////////
//You must click 'Running' at the bottom of the script window to activate this script!
//This is a basic Touch Toggle Script Template.
//You simply drop this script inside of your object and it will toggle the effect on and off when it is touched.
//
//Visit
//http://wiki.secondlife.com/wiki/Example_Particle_Script
//http://wiki.secondlife.com/wiki/LlParticleSystem
//for more information.....
///////////////////////////////////////////////
integer particleOn = 0;
particle()
{
///////////////////////////////////////////////
////PASTE YOUR EASY FX SCRIPT OUTPUT BELOW/////
//////OR YOUR OWN PARTICLE SCRIPT ENGINE///////





///////////////////////////////////////////////
///////////////////////////////////////////////
}
stopParticle()
{
particleOn = 0;
llParticleSystem([]);
}
default
{
state_entry()
{
particle();
}
on_rez(integer start_params)
{
particle();
}
touch_start(integer num_detected)
{
if(!particleOn)
{
particleOn = 1;
particle();
}
else
stopParticle();
}
}

 

Link to comment
Share on other sites

That's a very simple toggle switch, like a light switch, and it's working fine.  You just didn't tell it to turn off when you rez it.  Instead, you did the exact opposite.  You wrote

particle();

which calls the routine to start  the particles.  So write

stopParticle();

instead.  ;)

Link to comment
Share on other sites

Try this.   The logic is identical to your sample's but I've simplified it a bit.

 

integer toggle;list lParticles;init(){ //we have to define the list inside a function, or it won't compile -- LSL doesn't like performing  certain operaions (inluding the | operation)  outside the main script;    lParticles = [ //replace with your own particle system    PSYS_PART_FLAGS,       PSYS_PART_WIND_MASK | PSYS_PART_EMISSIVE_MASK,    PSYS_SRC_PATTERN,      PSYS_SRC_PATTERN_EXPLODE,    PSYS_PART_START_COLOR, <1.0, 0.0, 0.0>        ];    }default{    state_entry()    {        init();//define the particle system        llParticleSystem([]);//since toggle defaults to FALSE, start with no particles    }    touch_start(integer total_number)    {        llParticleSystem([]);//whatever happens, turn off the particles        if(toggle =!toggle){//switch the value of toggle and, if it's now TRUE            llParticleSystem(lParticles); //turn on the particles        }    }}

 

Link to comment
Share on other sites


Summer Logan wrote:

Thank you Rolig Loon, actually I didn't write the script it was a free script off of the MP. I will change this and let you know.

 

EDIT: This didn't work, I'm not sure I'm changing it in the right spot...also I already see a stopParticle(); in here.

Then you probably aren't replacing it in the right spot.  Think through the logic here.  You want to change the way that the script behaves on rez, right?  So you want to make the particles STOP on rez instead of STARTING:

on_rez(integer start_params)

{

stopParticle();

}

The example that Innula gave you is much more compact, and it's the way that most scripters would probably handle a simple toggle switch, but your original script is a lot easier to follow.  Study it for a few minutes, you'll see.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2939 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...