Turning six Particles scripts On with one button?
|
Lord Wishbringer
Registered User
Join date: 3 Dec 2004
Posts: 209
|
12-12-2005 09:57
Hi again lol
Im after some help. I am making a row of christmas lights with particles of different colours in each bulb. Thats no problem, i have got all the RGBs i need and the 'bulbs' work perfectly.
What i'm having trouble with is a switch to turn them all on with one touch and same to turn them off. I am hopeless at scripting, i have been to the particle lab,read the LSL wiki,attempted to dissect other scripts with llMessageLinked events in them, but i cannot for the life of me make it work.
I'm not sure if its possible to add one script to the 'switch' button and another seperate script in each of the child 'bulb' prims to tell the main particle script it has been touched,in turn,switching them all on,or if it means the whole particle scripts inside of the bulbs needs reworking to accomidate the switching event.
Anyone know where i can buy the scripts i need,or even if it's possible to do what i'm asking about? lol
|
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
|
12-12-2005 10:28
From: Lord Wishbringer Hi again lol
Im after some help. I am making a row of christmas lights with particles of different colours in each bulb. Thats no problem, i have got all the RGBs i need and the 'bulbs' work perfectly.
What i'm having trouble with is a switch to turn them all on with one touch and same to turn them off. I am hopeless at scripting, i have been to the particle lab,read the LSL wiki,attempted to dissect other scripts with llMessageLinked events in them, but i cannot for the life of me make it work.
I'm not sure if its possible to add one script to the 'switch' button and another seperate script in each of the child 'bulb' prims to tell the main particle script it has been touched,in turn,switching them all on,or if it means the whole particle scripts inside of the bulbs needs reworking to accomidate the switching event.
Anyone know where i can buy the scripts i need,or even if it's possible to do what i'm asking about? lol In the main switch script (assuming all these prims are linked) you could define a global integer, say: integer switchedOn = FALSE; then in: touch_start(integer foo) { if(!switchedOn) { llSetText("Lights: On, more or less",<1,1,1>,1); llMessageLinked(LINK_ALL_OTHERS,0,"turn on, my pretties!",""); switchedOn = TRUE; } else { llSetText("Lights: Not so much on as off",<1,1,1>,1); llMessage Linked(LINK_ALL_OTHERS,0,"Sleep. Sleeeeeeeep, my pretties, else you get the hose!",""); switchedOn = FALSE; } }
then, in the particle script: link_message(integer sender_num, integer number, string message, key id) { if( message == "turn on, my pretties!" ) { updateParticles();//or whatever function call you use to instantiate the particles } else if( message == "Sleep. Sleeeeeeeep, my pretties, else you get the hose!") { llParticleSystem([]);//passing the particle generator an empty list kills the particles } }
Or something. I'm at work and doing this from memory, so it may not have great syntax. Good luck!
|
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
|
12-12-2005 10:30
In the button, put the following script: integer Active;
default { state_entry() { llMessageLinked(LINK_SET, 0, "Off", NULL_KEY); } on_rez(integer param) { llResetScript(); } touch_start(integer total_number) { if(Active) { Active = 0; llMessageLinked(LINK_SET, 0, "Off", NULL_KEY); }else{ Active = 1; llMessageLinked(LINK_SET, 0, "On", NULL_KEY); } } } And in the bulb, use this: Parts_On() { //Your particle system here }
Parts_Off() { llParticleSystem([]); }
default { link_message(integer sender, integer num, string message, key id) { if(message == "On") Parts_On(); if(message == "Off") Parts_Off(); } } Note: if the button is the primary prim (last one selected when linking) the touch event will pass from the bulbs to the button, triggering the system on/off. If you don't want this to happen, just use anyother prim as the primary.
|
Lord Wishbringer
Registered User
Join date: 3 Dec 2004
Posts: 209
|
12-12-2005 10:56
Thanks for the replies! Alas, i can't bloody work it out rofl. Kayla, i try to put the code you gave me for the bulb into this particle script, i have tried diffrent places/configurations, but it never compiles. How am i supposed to use it? Sorry for all the questions, i've only just started messing with scripting and i'm finding it tough going. Ok,heres the particle code:
// Jopsy's No-Frills Particle Script v2 // All settings below are 'defaults integer mode; default { state_entry() { llParticleSystem( [ // Appearance Settings PSYS_PART_START_SCALE,(vector) <.5,.5,0>, // Start Size, (minimum .04, max 10.0?) PSYS_PART_END_SCALE, (vector) <.5,.5,0>, // End Size, requires *_INTERP_SCALE_MASK PSYS_PART_START_COLOR,(vector) <109,140,.139>, // Start Color, (RGB, 0 to 1) PSYS_PART_END_COLOR, (vector) <109,140,.139>, // EndC olor, requires *_INTERP_COLOR_MASK PSYS_PART_START_ALPHA,(float) 1.0, // startAlpha (0 to 1), PSYS_PART_END_ALPHA, (float) 1.0, // endAlpha (0 to 1) PSYS_SRC_TEXTURE, (string) "", // name of a 'texture' in emitters inventory // Flow Settings, keep (age/rate)*count well below 4096 !!! PSYS_SRC_BURST_PART_COUNT,(integer) 1, // # of particles per burst PSYS_SRC_BURST_RATE, (float) 0.1, // delay between bursts PSYS_PART_MAX_AGE, (float) 10, // how long particles live PSYS_SRC_MAX_AGE, (float) 0.0, // turns emitter off after 15 minutes. (0.0 = never) // Placement Settings PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_DROP, // _PATTERN can be: *_EXPLODE, *_DROP, *_ANGLE,or *_ANGLE_CONE PSYS_SRC_BURST_RADIUS,(float) 0.0, // How far from emitter new particles start, PSYS_SRC_INNERANGLE, (float) 0.0, // aka 'spread' (0 to 2*PI), PSYS_SRC_OUTERANGLE, (float) 0.0, // aka 'tilt' (0(up), PI(down) to 2*PI), PSYS_SRC_OMEGA, (vector) <0,0,0>, // how much to rotate around x,y,z per burst, // Movement Settings PSYS_SRC_ACCEL,(vector) <0,0,0>, // aka gravity or push, ie <0,0,-1.0> = down PSYS_SRC_BURST_SPEED_MIN,(float) 1.0, // Minimum velocity for new particles PSYS_SRC_BURST_SPEED_MAX,(float) 1.0, // Maximum velocity for new particles //PSYS_SRC_TARGET_KEY,(key) llGetOwner(), // key of a target, requires *_TARGET_POS_MASK // for *_TARGET try llGetKey(), or llGetOwner(), or llDetectedKey(0) even. :) PSYS_PART_FLAGS, // Remove the leading // from the options you want enabled: //PSYS_PART_EMISSIVE_MASK | // particles glow //PSYS_PART_BOUNCE_MASK | // particles bounce up from emitter's 'Z' altitude //PSYS_PART_WIND_MASK | // particles get blown around by wind //PSYS_PART_FOLLOW_VELOCITY_MASK | // particles rotate towards where they're going //PSYS_PART_FOLLOW_SRC_MASK | // particles move as the emitter moves //PSYS_PART_INTERP_COLOR_MASK | // particles change color depending on *_END_COLOR //PSYS_PART_INTERP_SCALE_MASK | // particles change size using *_END_SCALE //PSYS_PART_TARGET_POS_MASK | // particles home on *_TARGET key 0 // Unless you understand binary arithmetic, leave this 0 here. :) ] ); } touch_start(integer num) { if (mode++) llResetScript(); // 2nd time touched? start over else llParticleSystem([ ]); // 1st time touched? Turn particles off. } }
Thanks once again for attempting to help  -LW
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
12-12-2005 11:19
Combined bulb code: // Jopsy's No-Frills Particle Script v2 // All settings below are 'defaults Parts_On() { llParticleSystem( [ // Appearance Settings PSYS_PART_START_SCALE,(vector) <.5,.5,0>, // Start Size, (minimum .04, max 10.0?) PSYS_PART_END_SCALE, (vector) <.5,.5,0>, // End Size, requires *_INTERP_SCALE_MASK PSYS_PART_START_COLOR,(vector) <109,140,.139>, // Start Color, (RGB, 0 to 1) PSYS_PART_END_COLOR, (vector) <109,140,.139>, // EndC olor, requires *_INTERP_COLOR_MASK PSYS_PART_START_ALPHA,(float) 1.0, // startAlpha (0 to 1), PSYS_PART_END_ALPHA, (float) 1.0, // endAlpha (0 to 1) PSYS_SRC_TEXTURE, (string) "", // name of a 'texture' in emitters inventory // Flow Settings, keep (age/rate)*count well below 4096 !!! PSYS_SRC_BURST_PART_COUNT,(integer) 1, // # of particles per burst PSYS_SRC_BURST_RATE, (float) 0.1, // delay between bursts PSYS_PART_MAX_AGE, (float) 10, // how long particles live PSYS_SRC_MAX_AGE, (float) 0.0, // turns emitter off after 15 minutes. (0.0 = never) // Placement Settings PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_DROP, // _PATTERN can be: *_EXPLODE, *_DROP, *_ANGLE,or *_ANGLE_CONE PSYS_SRC_BURST_RADIUS,(float) 0.0, // How far from emitter new particles start, PSYS_SRC_INNERANGLE, (float) 0.0, // aka 'spread' (0 to 2*PI), PSYS_SRC_OUTERANGLE, (float) 0.0, // aka 'tilt' (0(up), PI(down) to 2*PI), PSYS_SRC_OMEGA, (vector) <0,0,0>, // how much to rotate around x,y,z per burst, // Movement Settings PSYS_SRC_ACCEL,(vector) <0,0,0>, // aka gravity or push, ie <0,0,-1.0> = down PSYS_SRC_BURST_SPEED_MIN,(float) 1.0, // Minimum velocity for new particles PSYS_SRC_BURST_SPEED_MAX,(float) 1.0, // Maximum velocity for new particles //PSYS_SRC_TARGET_KEY,(key) llGetOwner(), // key of a target, requires *_TARGET_POS_MASK // for *_TARGET try llGetKey(), or llGetOwner(), or llDetectedKey(0) even. :) PSYS_PART_FLAGS, // Remove the leading // from the options you want enabled: //PSYS_PART_EMISSIVE_MASK | // particles glow //PSYS_PART_BOUNCE_MASK | // particles bounce up from emitter's 'Z' altitude //PSYS_PART_WIND_MASK | // particles get blown around by wind //PSYS_PART_FOLLOW_VELOCITY_MASK | // particles rotate towards where they're going //PSYS_PART_FOLLOW_SRC_MASK | // particles move as the emitter moves //PSYS_PART_INTERP_COLOR_MASK | // particles change color depending on *_END_COLOR //PSYS_PART_INTERP_SCALE_MASK | // particles change size using *_END_SCALE //PSYS_PART_TARGET_POS_MASK | // particles home on *_TARGET key 0 // Unless you understand binary arithmetic, leave this 0 here. :) ] ); }
Parts_Off() { llParticleSystem([]); }
default { state_entry() { Parts_On(); }
link_message(integer sender, integer num, string message, key id) { if(message == "On") Parts_On(); if(message == "Off") Parts_Off(); } }
That's using Kayla's version. So use her button script, and put this in the bulbs, and hopefully it will work.
|
Lord Wishbringer
Registered User
Join date: 3 Dec 2004
Posts: 209
|
12-12-2005 11:51
That worked perfectly, thankyou much guys!! 
|