Jump to content

Need help with adding on/off on touch to this script please


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

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

Recommended Posts

I'm not a scripter at all, but I'm working on a project and I've used a particle generator to create particles the way I want them. However it has no on/off on touch. I would love, and really appreciate help in turning this script into a touch on/off particle script. Thank you in advance.  The script is inside the root prim (which is fully transparent) but it is inside another prim, I don't know if this imprtant to know (as you can't touch the actual prim housing the script) so I'm mentioning it in case it is important. Anyway here's the script.

Thank you :)

~Jewel

 

default{
state_entry(){
llLinkParticleSystem(LINK_THIS,[
PSYS_PART_FLAGS,
PSYS_PART_BOUNCE_MASK,
PSYS_PART_START_COLOR,<.47451,.70588,.78431>,
PSYS_PART_START_ALPHA,.0,
PSYS_PART_END_COLOR,<.47451,.70588,.78431>,
PSYS_PART_END_ALPHA,.0,
PSYS_PART_START_SCALE,<.03125,.03125,.03125>,
PSYS_PART_END_SCALE,<.03125,.03125,.03125>,
PSYS_PART_MAX_AGE,4.5,
PSYS_SRC_PATTERN,
PSYS_SRC_PATTERN_EXPLODE,
PSYS_SRC_TEXTURE,(key)"9e0385e4-934e-6bc1-6adf-ed5354849d7a",
PSYS_SRC_BURST_RATE,.15,
PSYS_SRC_BURST_PART_COUNT,2,
PSYS_SRC_BURST_RADIUS,.055,
PSYS_SRC_BURST_SPEED_MIN,.007,
PSYS_SRC_BURST_SPEED_MAX,.009,
PSYS_PART_BLEND_FUNC_SOURCE,
PSYS_PART_BF_ONE,
PSYS_PART_BLEND_FUNC_DEST,
PSYS_PART_BF_ONE,
PSYS_PART_END_GLOW,.02
]);
}
}

Link to comment
Share on other sites

// touch to toggle particle on/off

 

integer isOn = 1;

 

startParticle()

{

llParticleSystem

(

[

// PUT YOUR PARTICLE PARAMETERS HERE

]

);

}

 

default {

 

state_entry()

{ startParticle(); isOn = 1;

}

 

touch_start(integer num_detected)

{

if (isOn == 1) {

llParticleSystem([]); isOn = 0;

}

else

{

startParticle(); isOn = 1;

}

}

}

  • Like 2
Link to comment
Share on other sites

  • 2 years later...

Hello, scripters ! Like Jewel, i have a particle script and i'd like to add a touch on/off , i've been trying what sndbad Ghost said , but i've a syntax error (44.0).

Im not a scripter at all ... if someone could help me by correcting the error it would help me alot !

This is the script :

 

// touch to toggle particle on/off

 

integer isOn = 1;

 

startParticle()

{

llParticleSystem

(

[

PSYS_PART_FLAGS,( 0
|PSYS_PART_WIND_MASK

|PSYS_PART_FOLLOW_VELOCITY_MASK ),
PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE ,
PSYS_PART_START_ALPHA,1,
PSYS_PART_END_ALPHA,1,
PSYS_PART_START_COLOR,<1,1,1> ,
PSYS_PART_END_COLOR,<1,1,1> ,
PSYS_PART_START_SCALE,<4,4,0>,
PSYS_PART_END_SCALE,<4,4,0>,
PSYS_PART_MAX_AGE,5,
PSYS_SRC_MAX_AGE,0,
PSYS_SRC_ACCEL,<0,0,-5>,
PSYS_SRC_BURST_PART_COUNT,2,
PSYS_SRC_BURST_RADIUS,15,
PSYS_SRC_BURST_RATE,0.01,
PSYS_SRC_BURST_SPEED_MIN,0,
PSYS_SRC_BURST_SPEED_MAX,0,
PSYS_SRC_ANGLE_BEGIN,1,
PSYS_SRC_ANGLE_END,1,
PSYS_SRC_OMEGA,<0,0,0>,
PSYS_SRC_TEXTURE, (key)"6918812d-8e7f-b347-4732-456e7918624b",
PSYS_SRC_TARGET_KEY, (key)"00000000-0000-0000-0000-000000000000"
 ]);
}
}

]

);

}

 

default {

 

state_entry()

{ startParticle(); isOn = 1;

}

 

touch_start(integer num_detected)

{

if (isOn == 1) {

llParticleSystem([]); isOn = 0;

}

else

{

startParticle(); isOn = 1;

}

}

}

Link to comment
Share on other sites

Try formatting your code mebbe?.. it helps you see errors more clearly.

an online site that may work is ... http://jsbeautifier.org/

 // touch to toggle particle on/off
integer isOn = 1;
startParticle()
{
    llParticleSystem
    ([
      PSYS_PART_FLAGS, (0 |
      PSYS_PART_WIND_MASK |
      PSYS_PART_FOLLOW_VELOCITY_MASK),
      PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
      PSYS_PART_START_ALPHA, 1,
      PSYS_PART_END_ALPHA, 1,
      PSYS_PART_START_COLOR, < 1, 1, 1 > ,
      PSYS_PART_END_COLOR, < 1, 1, 1 > ,
      PSYS_PART_START_SCALE, < 4, 4, 0 > ,
      PSYS_PART_END_SCALE, < 4, 4, 0 > ,
      PSYS_PART_MAX_AGE, 5,
      PSYS_SRC_MAX_AGE, 0,
      PSYS_SRC_ACCEL, < 0, 0, -5 > ,
      PSYS_SRC_BURST_PART_COUNT, 2,
      PSYS_SRC_BURST_RADIUS, 15,
      PSYS_SRC_BURST_RATE, 0.01,
      PSYS_SRC_BURST_SPEED_MIN, 0,
      PSYS_SRC_BURST_SPEED_MAX, 0,
      PSYS_SRC_ANGLE_BEGIN, 1,
      PSYS_SRC_ANGLE_END, 1,
      PSYS_SRC_OMEGA, < 0, 0, 0 > ,
      PSYS_SRC_TEXTURE, (key)
      "6918812d-8e7f-b347-4732-456e7918624b",
      PSYS_SRC_TARGET_KEY, (key)
      "00000000-0000-0000-0000-000000000000"
    ]);
}
default
{
     state_entry()
     {
         startParticle();
         isOn = 1;

     }
     touch_start(integer num_detected)
     {
         if (isOn == 1)
         {   llParticleSystem([]);
             isOn = 0;

         } else
         {   startParticle();
             isOn = 1;
         }
     }
 }

 

  • Thanks 1
Link to comment
Share on other sites

Ohh Xiija beated me... anyway, always be sure the curly braces are pairwise. Further no need for state changes, just handle the simple rain on/off in the touch event.

integer bRain= TRUE;

Particles( integer bState )
{
    if (bState)
    {
        llParticleSystem(
        [
            PSYS_PART_FLAGS,( PSYS_PART_WIND_MASK| PSYS_PART_FOLLOW_VELOCITY_MASK ),
            PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_EXPLODE,
            PSYS_PART_START_ALPHA, 1,
            PSYS_PART_END_ALPHA, 1,
            PSYS_PART_START_COLOR, <1,1,1> ,
            PSYS_PART_END_COLOR, <1,1,1> ,
            PSYS_PART_START_SCALE, <4,4,0>,
            PSYS_PART_END_SCALE, <4,4,0>,
            PSYS_PART_MAX_AGE, 5,
            PSYS_SRC_MAX_AGE, 0,
            PSYS_SRC_ACCEL, <0,0,-5>,
            PSYS_SRC_BURST_PART_COUNT, 2,
            PSYS_SRC_BURST_RADIUS, 15,
            PSYS_SRC_BURST_RATE, 0.01,
            PSYS_SRC_BURST_SPEED_MIN, 0,
            PSYS_SRC_BURST_SPEED_MAX, 0,
            PSYS_SRC_ANGLE_BEGIN, 1,
            PSYS_SRC_ANGLE_END, 1,
            PSYS_SRC_OMEGA, <0,0,0>,
            PSYS_SRC_TEXTURE, "6918812d-8e7f-b347-4732-456e7918624b"
        ]
        );
    }
    else
        llParticleSystem([]);
}

default
{
    state_entry()
    {
        bRain= TRUE;
        Particles( bRain);
    }

    touch_start(integer num_detected)
    {
       // toggle the boolean FALSE/TRUE
        bRain= !bRain;
        Particles( bRain );
    }
}

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2050 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...