Jump to content

Combining a toggle particle script and toggle loop sound script..?


MistressNocturne
 Share

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

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

Recommended Posts

Hey, was wondering if anyone had a tip on how to combine two scripts together? Trying to make it so when click my bomb or dynamite, a fuse hiss plays and a spark appears. Currently I have two seperate scripts inside the object, but I know its going to desync itself at some point. Was wondering if anyone had any ideas..? Here are the two scripts for refrence:

PARTICLE SCRIPT-

Quote

// touch to toggle particle on/off
integer isOn = 1;
startParticle()
{
         llParticleSystem([
         PSYS_PART_FLAGS, 0 | PSYS_PART_EMISSIVE_MASK |
         PSYS_PART_INTERP_COLOR_MASK | PSYS_PART_INTERP_SCALE_MASK |
         PSYS_PART_FOLLOW_SRC_MASK | PSYS_PART_FOLLOW_VELOCITY_MASK,
         PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_EXPLODE,
         PSYS_PART_MAX_AGE,.3,
         PSYS_PART_START_COLOR,<1.00000, 1.00000, 0.00000>,
         PSYS_PART_END_COLOR,<1.00000, 0.00000, 0.00000>,
         PSYS_PART_START_SCALE,<.07,.07,0>,
         PSYS_PART_END_SCALE,<.04,.04,0>,
         PSYS_SRC_BURST_RATE,0.0,
         PSYS_SRC_ACCEL, <0,0,1>,
         PSYS_SRC_BURST_PART_COUNT,15,
         PSYS_SRC_BURST_RADIUS,0.008,
         PSYS_SRC_BURST_SPEED_MIN,0.1,
         PSYS_SRC_BURST_SPEED_MAX,0.1,
         PSYS_SRC_TARGET_KEY,(key)"",
         PSYS_SRC_INNERANGLE,1.55,
         PSYS_SRC_OUTERANGLE,0,
         PSYS_SRC_OMEGA,<0.00000, 0.00000, 5.00000>,
         PSYS_SRC_MAX_AGE,0.000000,
         PSYS_PART_START_ALPHA,3.6,
         PSYS_PART_END_ALPHA,0.05
         ]);
}
default
{
     state_entry()
     {
         startParticle();
         isOn = 1;

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

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

SOUND LOOP SCRIPT-

Quote

integer toggle;
string sound;
default
{
    state_entry()
    {
        sound = llGetInventoryName(INVENTORY_SOUND,0);
    }
    touch_start(integer total_number)
    {
 if( llDetectedKey(0) == llGetOwner())
 {
        toggle=!toggle;
        if(toggle){
            llLoopSound(sound,1.0);
        }
        else{
            llStopSound();
        }
}
    }
}

I'm not good at scripting (I can replace stuff at times and do VERY VERY basic copy pasta stuff but thats it), so any advice is welcome!

Link to comment
Share on other sites

  1. Move the "string sound;" statement from the sound script to the top of the particle script.
  2. Take the one line inside state_entry() in your sound script and move it inside state_entry() in your particle script.
  3. Take the llStopSound() call from the sound script and place it right after the empty llParticleSystem([]) call in your particle script.
  4. Take the llLoopSound() call from the sound script and place it right after the startParticle() call in your particle script.

By using only one toggle (isOn), you eliminate the possibility of sound and particles decoupling.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

19 minutes ago, Madelaine McMasters said:
  1. Move the "string sound;" statement from the sound script to the top of the particle script.
  2. Take the one line inside state_entry() in your sound script and move it inside state_entry() in your particle script.
  3. Take the llStopSound() call from the sound script and place it right after the empty llParticleSystem([]) call in your particle script.
  4. Take the llLoopSound() call from the sound script and place it right after the startParticle() call in your particle script.

By using only one toggle (isOn), you eliminate the possibility of sound and particles decoupling.

THANK YOU SO MUCH. It took a bit, but once I got it, it finally started working!, one quick question, does it matter where I place the LoopSound call at? Is it ok to place it in the second startParticle call or is it better to put it in the first..? Just making sure.

Link to comment
Share on other sites

46 minutes ago, MistressNocturne said:

THANK YOU SO MUCH. It took a bit, but once I got it, it finally started working!, one quick question, does it matter where I place the LoopSound call at? Is it ok to place it in the second startParticle call or is it better to put it in the first..? Just making sure.

Everything happens in sequence, so if you put LoopSound before StartParticle, the sound will start playing before the particle shows up (or after, if you place it after).

In this case it might not really matter either way.

Edited by Wulfie Reanimator
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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