Jump to content
Sign in to follow this  
Kasia Mistwood

Changing 'touch' switch into 'chat' switch ON/OFF

Recommended Posts

Hello,

 

I was trying to change the way my script operates. So far it switches the light beacon ON on touch and switches it OFF on touching it again. I was trying to make it switch ON/OFF after  saying something on the local chat, "lights" for example. 

 

Here is my basic 'touch' script. On touch it changes particles to be invisible.

 

integer Toggle = FALSE;      

default
{            
touch_start(integer num_detected)
{
    if (Toggle == FALSE)
    {
     Toggle= TRUE;
      llParticleSystem
        ([
            PSYS_PART_FLAGS,
            PSYS_PART_INTERP_COLOR_MASK|
            PSYS_PART_FOLLOW_SRC_MASK|
            PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN,
            PSYS_SRC_PATTERN_ANGLE_CONE,
            PSYS_SRC_INNERANGLE, 0.0,
            PSYS_SRC_OUTERANGLE, 0.1,
            PSYS_SRC_BURST_SPEED_MIN, 0.0,
            PSYS_SRC_BURST_SPEED_MAX, 0.0,
            PSYS_SRC_BURST_RADIUS, 0.0,
            PSYS_SRC_BURST_PART_COUNT, 5,
            PSYS_SRC_BURST_RATE, 1.6,
            PSYS_PART_MAX_AGE, 1.0,
            PSYS_PART_START_SCALE, <1,1,1>,
            PSYS_PART_START_COLOR, <1,1,1>,
            PSYS_PART_END_COLOR, <1,1,1>,
            PSYS_PART_START_ALPHA, 1.0,
            PSYS_PART_END_ALPHA, 0.0
        ]);
     
    }
    else if (Toggle == TRUE)
    {
     Toggle= FALSE;
      llParticleSystem
        ([
            PSYS_PART_FLAGS,
            PSYS_PART_INTERP_COLOR_MASK|
            PSYS_PART_FOLLOW_SRC_MASK|
            PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN,
            PSYS_SRC_PATTERN_ANGLE_CONE,
            PSYS_SRC_INNERANGLE, 0.0,
            PSYS_SRC_OUTERANGLE, 0.1,
            PSYS_SRC_BURST_SPEED_MIN, 0.0,
            PSYS_SRC_BURST_SPEED_MAX, 0.0,
            PSYS_SRC_BURST_RADIUS, 0.0,
            PSYS_SRC_BURST_PART_COUNT, 5,
            PSYS_SRC_BURST_RATE, 1.6,
            PSYS_PART_MAX_AGE, 1.0,
            PSYS_PART_START_SCALE, <1,1,1>,
            PSYS_PART_START_COLOR, <1,1,2>,
            PSYS_PART_END_COLOR, <1,1,2>,
            PSYS_PART_START_ALPHA, 0.0,
            PSYS_PART_END_ALPHA, 0.0
        ]);
    }
}
}

 

I was trying to make it change on saying "ON' or "OFF" but it never worked. It switches it ON once, and nothing happens ever again...

 

default
{
//  when the script has been saved (only in default) or when re-entering this state
    state_entry()
    {
        key owner = llGetOwner();
 
        llListen(0, "", owner, "");
    }
    listen(integer channel, string name, key id, string message)
    {
        if (message == "ON")
        {
             llParticleSystem
        ([
            PSYS_PART_FLAGS,
            PSYS_PART_INTERP_COLOR_MASK|
            PSYS_PART_FOLLOW_SRC_MASK|
            PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN,
            PSYS_SRC_PATTERN_ANGLE_CONE,
            PSYS_SRC_INNERANGLE, 0.0,
            PSYS_SRC_OUTERANGLE, 0.1,
            PSYS_SRC_BURST_SPEED_MIN, 0.0,
            PSYS_SRC_BURST_SPEED_MAX, 0.0,
            PSYS_SRC_BURST_RADIUS, 0.0,
            PSYS_SRC_BURST_PART_COUNT, 5,
            PSYS_SRC_BURST_RATE, 1.6,
            PSYS_PART_MAX_AGE, 1.0,
            PSYS_PART_START_SCALE, <1,1,1>,
            PSYS_PART_START_COLOR, <1,1,1>,
            PSYS_PART_END_COLOR, <1,1,1>,
            PSYS_PART_START_ALPHA, 1.0,
            PSYS_PART_END_ALPHA, 0.0
        ]);
    }        
    
            
    if (message == "OFF")
        {
             llParticleSystem
        ([
            PSYS_PART_FLAGS,
            PSYS_PART_INTERP_COLOR_MASK|
            PSYS_PART_FOLLOW_SRC_MASK|
            PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN,
            PSYS_SRC_PATTERN_ANGLE_CONE,
            PSYS_SRC_INNERANGLE, 0.0,
            PSYS_SRC_OUTERANGLE, 0.1,
            PSYS_SRC_BURST_SPEED_MIN, 0.0,
            PSYS_SRC_BURST_SPEED_MAX, 0.0,
            PSYS_SRC_BURST_RADIUS, 0.0,
            PSYS_SRC_BURST_PART_COUNT, 5,
            PSYS_SRC_BURST_RATE, 1.6,
            PSYS_PART_MAX_AGE, 1.0,
            PSYS_PART_START_SCALE, <1,1,0>,
            PSYS_PART_START_COLOR, <1,1,0>,
            PSYS_PART_END_COLOR, <1,1,1>,
            PSYS_PART_START_ALPHA, 1.0,
            PSYS_PART_END_ALPHA, 1.0
        ]);
    }
        }
    }

 

I tried a lot of combinations but none has ever worked. After running once it always stays this way :(

 

I would be very very very glad for help with that :) Thanks :)

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for reply, but its not really the problem, sorry if i didnt explain correctly.

 

The particles work perfectly already. They switch ON and OFF on click (touch). 

 

I would like to do the same but with local chat command. So make them appear on 'ON' and dissapoear on "OFF" in chat instead of touching. 

 

Thanks again

 

 

 

Share this post


Link to post
Share on other sites

If you tried Arton;s suggestion, it ought to do what you're asking for.  Yours not only doesn't have  a llParticleSystem[] to turn them OFF, it is also missing the else in else if.

Share this post


Link to post
Share on other sites

Well, the reason why your touch script works for you, is because of you call the particle system with 0.0 alpha values in your off statement. Hence, the particles are invisible.

In your listen script though, you call a particle system with alpha values of 1.0. So there is nothing to make them invisible, or to turn them off.

To correctly turn them off, call llParticleSystem([]); with an empty list, like I said already. Remember to type upper case ON and OFF.

default{//  when the script has been saved (only in default) or when re-entering this state    state_entry()    {        key owner = llGetOwner();         llListen(0, "", owner, "");    }    listen(integer channel, string name, key id, string message)    {        if (message == "ON")        {             llParticleSystem            ([                PSYS_PART_FLAGS,                PSYS_PART_INTERP_COLOR_MASK|                PSYS_PART_FOLLOW_SRC_MASK|                PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN,                PSYS_SRC_PATTERN_ANGLE_CONE,                PSYS_SRC_INNERANGLE, 0.0,                PSYS_SRC_OUTERANGLE, 0.1,                PSYS_SRC_BURST_SPEED_MIN, 0.0,                PSYS_SRC_BURST_SPEED_MAX, 0.0,                PSYS_SRC_BURST_RADIUS, 0.0,                PSYS_SRC_BURST_PART_COUNT, 5,                PSYS_SRC_BURST_RATE, 1.6,                PSYS_PART_MAX_AGE, 1.0,                PSYS_PART_START_SCALE, <1,1,1>,                PSYS_PART_START_COLOR, <1,1,1>,                PSYS_PART_END_COLOR, <1,1,1>,                PSYS_PART_START_ALPHA, 1.0,                PSYS_PART_END_ALPHA, 0.0            ]);        }                                else if (message == "OFF")        {                 llParticleSystem([]);        }    }}

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks a lot for your help :) 

 

I've set the particles as you said and itr seems to work well now. They start and stop on start/stop command in chat :D Thanks for your time again :)

 

PS: Sorry for such a long time to reply

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...