touch issue
|
|
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
|
01-07-2007 19:04
I made a particle panel for a stage area I have. It has four buttons each with a different particle script. Works great for the most part except that all the particles fire whenever I enter the area. How do I get that to stop? I really don't want people showing up for a concert only to have colored explosions all over them when they enter the area. Also, how do I make it so no one else can touch the buttons and fire off the particles?
|
|
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
|
01-07-2007 20:36
If I understand what you want, you want to have the particles only appear when you touch the prim. If that is the case then use this with your particle setup.
integer OFF = TRUE;
default { touch_start(integer num) { if(llDetectedKey(0) == llGetOwner()) //Only the owner can turn this on and off. { if(OFF) //Check to see if the particle system is on { MakeParticles(); //or whatever your particle function you have is here. OFF = FALSE; } else { llParticleSystem([]); //Tells the prim to not do any particles. OFF = TRUE; } } } }
Hope that is what you wanted. 
|
|
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
|
01-07-2007 20:58
Thats part so thank you very much! Now, where do I put it? I assume I take out the touch code on the bottom and add that but every time I do it doesn't work. I must be taking too much out or too little. Sorry, I dont know how you all add the code in the forums like you do. // type SETTING_NAME = sample value; // default value
mySetParticles() { // Part-1 - APPEARANCE - Settings for how each particle LOOKS vector START_SCALE = < 1.9, 1.9, 1.9 >; // < 1.0, 1.0, 0.0 > vector END_SCALE = < 1, 1, 1 >; // < 1.0, 1.0, 0.0 > vector START_COLOR = < 0, 0, 1 >; // < 1.0, 1.0, 1.0 > vector END_COLOR = < 0, 0, 1 >; // < 1.0, 1.0, 1.0 > float START_ALPHA = .8; // 1.00 float END_ALPHA = .5; // 1.00 integer INTERP_COLOR = TRUE; // FALSE integer INTERP_SCALE = TRUE; // FALSE integer EMISSIVE = TRUE; // FALSE string TEXTURE = ""; // "" float AGE = 10.00; // 10.00 float RATE = .5; // 0.10 integer COUNT = 30; // 1 float LIFE = 5; // 0.0 integer PATTERN = PSYS_SRC_PATTERN_EXPLODE; // required float RADIUS = 8.00; // 0.00 float ANGLE_BEGIN = 0.5; // 0.00 float ANGLE_END = 0.10; // 0.00 vector OMEGA = < 0.00, 1.00, 0.00 >; // < 0.00, 0.00, 0.00 > integer FOLLOW_SRC = FALSE; // FALSE integer FOLLOW_VELOCITY = TRUE; // FALSE integer WIND = FALSE; // FALSE integer BOUNCE = FALSE; // FALSE float SPEED_MIN = 0.4; // 1.00 float SPEED_MAX = .9; // 1.00 vector ACCEL = < 0.00, 0.00, -0.40 >; // < 0.00, 0.00, 0.00 > integer TARGET_POS = FALSE; // FALSE key TARGET = llGetKey(); // llGetKey(); list particle_parameters = [ PSYS_PART_FLAGS,( ( EMISSIVE * PSYS_PART_EMISSIVE_MASK ) | ( BOUNCE * PSYS_PART_BOUNCE_MASK ) | ( INTERP_COLOR * PSYS_PART_INTERP_COLOR_MASK ) | ( INTERP_SCALE * PSYS_PART_INTERP_SCALE_MASK ) | ( WIND * PSYS_PART_WIND_MASK ) | ( FOLLOW_SRC * PSYS_PART_FOLLOW_SRC_MASK ) | ( FOLLOW_VELOCITY * PSYS_PART_FOLLOW_VELOCITY_MASK ) | ( TARGET_POS * PSYS_PART_TARGET_POS_MASK ) ), PSYS_PART_START_COLOR, START_COLOR, PSYS_PART_END_COLOR, END_COLOR, PSYS_PART_START_ALPHA, START_ALPHA, PSYS_PART_END_ALPHA, END_ALPHA, PSYS_PART_START_SCALE, START_SCALE, PSYS_PART_END_SCALE, END_SCALE, PSYS_SRC_PATTERN, PATTERN, PSYS_SRC_BURST_PART_COUNT, COUNT, PSYS_SRC_BURST_RATE, RATE, PSYS_PART_MAX_AGE, AGE, PSYS_SRC_ACCEL, ACCEL, PSYS_SRC_BURST_RADIUS, RADIUS, PSYS_SRC_BURST_SPEED_MIN, SPEED_MIN, PSYS_SRC_BURST_SPEED_MAX, SPEED_MAX, PSYS_SRC_TARGET_KEY, TARGET, PSYS_SRC_ANGLE_BEGIN, ANGLE_BEGIN, PSYS_SRC_ANGLE_END, ANGLE_END, PSYS_SRC_OMEGA, OMEGA, PSYS_SRC_MAX_AGE, LIFE, PSYS_SRC_TEXTURE, TEXTURE ]; llParticleSystem( particle_parameters ); // Turns on the particle hose! if ( (AGE/RATE)*COUNT > 4096) { llSay( 0, "Your emitter creates too many particles!"); llSay( 0, "Please decrease AGE and COUNT and/or increase RATE."); llSay( 0, "Give a hoot, don't pollute!"); } }
default { state_entry() { mySetParticles(); // llSetTimerEvent(60); // uncomment to set auto-off for 60 seconds } timer() { llSetTimerEvent(0); // Turn off the alarm clock llParticleSystem( [ ] ); // Turn off the particles // updateParticles(); // Or use this to update/change the particle // system } touch(integer i) { mySetParticles(); // touch to reset/turn on the particles // llSetTimerEvent(60); // reset the alarm clock } }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-08-2007 01:17
Max, PLEASE PLEASE PLEASE use PHP tags when posting code! Your problem is the default state is automatically starting the particles on state_entry. default { state_entry() { // --------------- > will cause particles to start mySetParticles(); // llSetTimerEvent(60); // uncomment to set auto-off for 60 seconds }
|
|
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
|
01-08-2007 22:51
From: Newgate Ludd Max, PLEASE PLEASE PLEASE use PHP tags when posting code! Your problem is the default state is automatically starting the particles on state_entry.
Sorry about the PHP tag, wasn't sure how. OK, got the script to work fine except two things, when I first log in at the place with the scripted prim, it's running. How do I get it so it doesn't ever run until I touch it? I don't need people coming to my place with these particles all over the their screens. Second, I have for buttons on a prim, when I right click on the mother prim they all fire off. Left clicking does nothing just as I want it. Why does it do that? MakeParticles() { vector START_SCALE = < 1.9, 1.9, 1.9 >; vector END_SCALE = < 1, 1, 1 >; vector START_COLOR = < 0, 0, 1 >; vector END_COLOR = < 0, 0, 1 >; float START_ALPHA = .8; float END_ALPHA = .5; integer INTERP_COLOR = TRUE; integer INTERP_SCALE = TRUE; integer EMISSIVE = TRUE; string TEXTURE = ""; float AGE = 10.00; float RATE = .5; integer COUNT = 30; float LIFE = 5; integer PATTERN = PSYS_SRC_PATTERN_EXPLODE; float RADIUS = 8.00; float ANGLE_BEGIN = 0.5; float ANGLE_END = 0.10; vector OMEGA = < 0.00, 1.00, 0.00 >; integer FOLLOW_SRC = FALSE; integer FOLLOW_VELOCITY = TRUE; integer WIND = FALSE; integer BOUNCE = FALSE; float SPEED_MIN = 0.4; float SPEED_MAX = .9; vector ACCEL = < 0.00, 0.00, -0.40 >; integer TARGET_POS = FALSE; key TARGET = llGetKey(); list particle_parameters = [ PSYS_PART_FLAGS,( ( EMISSIVE * PSYS_PART_EMISSIVE_MASK ) | ( BOUNCE * PSYS_PART_BOUNCE_MASK ) | ( INTERP_COLOR * PSYS_PART_INTERP_COLOR_MASK ) | ( INTERP_SCALE * PSYS_PART_INTERP_SCALE_MASK ) | ( WIND * PSYS_PART_WIND_MASK ) | ( FOLLOW_SRC * PSYS_PART_FOLLOW_SRC_MASK ) | ( FOLLOW_VELOCITY * PSYS_PART_FOLLOW_VELOCITY_MASK ) | ( TARGET_POS * PSYS_PART_TARGET_POS_MASK ) ), PSYS_PART_START_COLOR, START_COLOR, PSYS_PART_END_COLOR, END_COLOR, PSYS_PART_START_ALPHA, START_ALPHA, PSYS_PART_END_ALPHA, END_ALPHA, PSYS_PART_START_SCALE, START_SCALE, PSYS_PART_END_SCALE, END_SCALE, PSYS_SRC_PATTERN, PATTERN, PSYS_SRC_BURST_PART_COUNT, COUNT, PSYS_SRC_BURST_RATE, RATE, PSYS_PART_MAX_AGE, AGE, PSYS_SRC_ACCEL, ACCEL, PSYS_SRC_BURST_RADIUS, RADIUS, PSYS_SRC_BURST_SPEED_MIN, SPEED_MIN, PSYS_SRC_BURST_SPEED_MAX, SPEED_MAX, PSYS_SRC_TARGET_KEY, TARGET, PSYS_SRC_ANGLE_BEGIN, ANGLE_BEGIN, PSYS_SRC_ANGLE_END, ANGLE_END, PSYS_SRC_OMEGA, OMEGA, PSYS_SRC_MAX_AGE, LIFE, PSYS_SRC_TEXTURE, TEXTURE ]; llParticleSystem( particle_parameters ); if ( (AGE/RATE)*COUNT > 4096) { llSay( 0, "Your emitter creates too many particles!"); llSay( 0, "Please decrease AGE and COUNT and/or increase RATE."); llSay( 0, "Give a hoot, don't pollute!"); } }
default { state_entry() { MakeParticles(); }
touch_start( integer num ) { state off; } }
state off { state_entry() { llParticleSystem([]); } touch_start( integer num ) { state default; } }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-09-2007 00:37
The reason its running is that you start the particles in state_entry, just like I said in my previous post. default { state_entry() { // Turn of Particles llParticleSystem([]); }
touch_start( integer num ) { state on; } }
state on { state_entry() { // Turn on particles MakeParticles(); } touch_start( integer num ) { state default; } }
|
|
Learjeff Innis
musician & coder
Join date: 27 Nov 2006
Posts: 817
|
01-09-2007 06:58
I bet the problem is that you leave the particle system in place, so it reruns in certain situations. I had the same problem just now. A simple fix was, whenever I run the particle system, I also set a timer a bit longer than the particle life, and when the timer expires I reset the particle system to empty. Bingo, problem solved.
I'm not sure why the particle system re-ran when I would teleport in, but it did. And not just on my client -- other people standing there would see it (at least, that's how I interpreted some comments from a friend, but didn't delve).
Note that I only started the particle system on specific user actions (touch or wear). The particle system re-ran without a change in state, and without the text that the object ALWAYS says when it calls llParticleSystem(). So, I'm confident that this function was not being called again.
HTH Cheers Jeff
|
|
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
|
01-09-2007 14:23
From: Learjeff Innis I bet the problem is that you leave the particle system in place, so it reruns in certain situations. I had the same problem just now. A simple fix was, whenever I run the particle system, I also set a timer a bit longer than the particle life, and when the timer expires I reset the particle system to empty. Bingo, problem solved.
I'm not sure why the particle system re-ran when I would teleport in, but it did. And not just on my client -- other people standing there would see it (at least, that's how I interpreted some comments from a friend, but didn't delve).
Note that I only started the particle system on specific user actions (touch or wear). The particle system re-ran without a change in state, and without the text that the object ALWAYS says when it calls llParticleSystem(). So, I'm confident that this function was not being called again.
HTH Cheers Jeff Yes, that is still my major issue. Not sure how to set a timer in there like you suggested as I'm very new to any type of scripting. Wish I had time for a formal or in world class. Thanks for your help
|
|
Learjeff Innis
musician & coder
Join date: 27 Nov 2006
Posts: 817
|
01-09-2007 14:36
It's very easy. default { state_entry() { MakeParticles(); llSetTimerEvent(COUNT*RATE+AGE + 1); // or however long the burst lasts, plus some slop }
touch_start( integer num ) { state off; }
timer() { llParticleSystem([]); llSetTimerEvent(0); } }
The llSetTimerEvent(0) turns off the timer, which is repetetive by default. Note that you'll have to move some variables out of the MakeParticles function and into global scope (COUNT, RATE, etc., as needed to calculate the duration). Regards, Jeff
|