Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Trials of a Burn Tower: Particle llSleep?

Cera Dreadlow
Registered User
Join date: 9 Jul 2008
Posts: 21
07-30-2008 09:19
As you may have seen in a previous thread, I am in the process of building a simulation burn tower maze/obstacle course for the Hocking College region.

MY current obstacle is that I cannot for the life of me figure out how to make a llSleep or timer function for a particle script. Here's the scenario: there will be a series of three or four "fires" (large-prim particle emitters) in a row, the last of which will contain a switch for the door to open (or, perhaps, the switch will be in a separate prim... Not really important at this point). To "put out" the fire, I want to be able to just click on the prim containing the particle script. But, since I don't want to have to manually reset each of the fires when someone else goes into the building, I'd like to just have it on a timer - so, you'd click on the first one and it'd be, say a 15 second delay where the fire is "out" (Oh, and I've just realized, I'll also have to figure out how to turn it phantom for that time) and then have it come back on automatically.

I've been doing my best at trying to modify different particle scripts to accomodate these needs, but because of my very BASIC knowledge of scripting, I can't figure out where things are supposed to go and what variables/"integers" go where, etc.

If anyone could help me with this, I'd be incredibly grateful!
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
07-30-2008 09:29
It would be easiest to help you if you posted your script. Or at least the basic structure, you can keep the details of the particle settings private if you want, those aren't relevant to your problem.

There are many ways to solve your problem. Here's one, using 2 functions that turn particles on and off. I probably have all the function names wrong since it's been a while since I've done this, but hopefully this should give you the general idea:

CODE



startFire()
{
// Insert all the particle stuff here
llParticleSystem(whatever);
}

stopFire()
{
llParticleSystem([]); //I think an empty list shuts off particles?
}

default
{
state_entry()
{
startFire();
}

touch_start(integer num)
{
stopFire();
llSetStatus(STATUS_PHANTOM, TRUE); // Or however this function works, don't remember

// do whatever's needed to open the door etc.

llSleep(15);

llSetStatus(STATUS_PHANTOM, FALSE);
startFire();
}
}


Cera Dreadlow
Registered User
Join date: 9 Jul 2008
Posts: 21
Gaaaaaaaaaaah! No!
07-30-2008 20:50
From: Ziggy Puff

CODE



I was so excited to try this script out, but then *duh,duh, DUH!* Syntax errors. I have no idea what to do with those. And here's the weird thing about it: the particle "fire" script I'm using works just dandy on its own, but when added to the script above, it suddenly finds syntax errors in the middle of it. :( Poop! So, here's what I'm working with - if anyone can help me out with this, I'd be more than appreciative!

As of now, I'm getting the error on line 54,18 - at
"float randBetween (float min, float max)"
I don't get it... :(

CODE



startFire()
{

// Particle Script by Mike Zidane
// Do what you want with this, but keep it free and post your changes to the boards.

// Give this effect a name, and when it hears it's name called via linkmessage,
// it will wait for START_DELAY to expire, then then fire.
// Define your effect in the define_effect() function.


string EFFECT_NAME = "fire";

float START_DELAY = 0;


//Don't muck around with the declarations.
///////////////////////////////////////////////////////////////////////////////
integer flags;
integer we_want_the_particle_to_glow;
integer we_want_the_particle_to_bounce;
integer we_want_the_particle_to_change_color;
integer we_want_the_particle_to_change_size;
integer we_want_the_particle_to_follow_wind;
integer we_want_the_particle_to_follow_its_source;
integer we_want_the_particle_to_spin_as_it_turns;
key we_want_the_effect_to_move_towards;
float we_want_each_particle_to_last_for;
float the_fastest_particles_will_be_ejected_at;
float the_slowest_particles_will_be_ejected_at;
string each_particle_should_have_this_texture;
float when_a_particle_is_created_it_will_have_an_alpha_value_of;
float and_then_it_will_gradually_shift_to_an_alpha_value_of;
vector when_a_particle_is_created_it_will_have_a_color_value_of;
vector and_then_it_will_gradually_shift_to_a_color_value_of;
vector new_particles_start_at_this_size;
vector and_change_to_this_size;
vector apply_this_constant_force_to_our_particles;
float we_want_to_create_new_particles_every;
float create_new_particles_this_far_from_the_prim;
integer create_this_number_of_particles_at_a_time;
float particles_should_fan_out_this_wide;
float spin_the_fan_this_far_around_the_center_of_the_emitter;
vector the_emmitter_will_spin_at_this_rate;
float the_emmitter_will_create_particles_for_this_long;
integer burst = PSYS_SRC_PATTERN_EXPLODE;
integer none = PSYS_SRC_PATTERN_DROP;
integer empty_cone = PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY;
integer cone = PSYS_SRC_PATTERN_ANGLE_CONE;
integer fan = PSYS_SRC_PATTERN_ANGLE;
integer we_want_the_effect_to_be_shaped_like_a;

//Don't muck around with the functions either.
float randBetween (float min, float max)
{
return llFrand(max - min) + min;
}

wait_for(float delay)
{
llSleep(delay);
}


//except this one. This is where you do your thing.
define_effect()
{
we_want_the_particle_to_glow = TRUE;

we_want_the_particle_to_bounce = FALSE;

we_want_the_particle_to_change_color = TRUE;

we_want_the_particle_to_change_size = TRUE;

we_want_the_particle_to_follow_wind = FALSE;

we_want_the_particle_to_follow_its_source = FALSE;

we_want_the_particle_to_spin_as_it_turns = TRUE;

we_want_the_effect_to_be_shaped_like_a = cone
// burst
// empty_cone
// cone
// fan
// none (= DROP)
;

we_want_the_effect_to_move_towards = ""; //(use a key,self,or owner inside the quotes)

we_want_each_particle_to_last_for = 6.0; //seconds.

the_fastest_particles_will_be_ejected_at = 0.15; // meters per second.

the_slowest_particles_will_be_ejected_at = 0. 0; // meters per second.

each_particle_should_have_this_texture = "";
//(a key is preferred here. use "" for none.)

when_a_particle_is_created_it_will_have_an_alpha_value_of = 1.0;
//(0.0 is transparent, 1.0 is opaque.)

and_then_it_will_gradually_shift_to_an_alpha_value _of = 0.0;
//over the life of the particle.

when_a_particle_is_created_it_will_have_a_color_value_of = <1.0,.5,0.0>;

and_then_it_will_gradually_shift_to_a_color_value_ of = <0,0,0>;
//over the life of the particle.

new_particles_start_at_this_size = <1.5,1.5,1.5>;

and_change_to_this_size = <0.25,0.25,0.25>;
//over the life of the particle.

apply_this_constant_force_to_our_particles = <0.0,0.0,0.15>;

we_want_to_create_new_particles_every = 0.1; //seconds.

create_new_particles_this_far_from_the_prim = 0.0; //for burst patterns only.

create_this_number_of_particles_at_a_time = 4.0;

//for angle patterns,
particles_should_fan_out_this_wide = 0; //in radians

spin_the_fan_this_far_around_the_center_of_the_emitter = 0; //,also in radians.

the_emmitter_will_spin_at_this_rate = <0,0,0>;

the_emmitter_will_create_particles_for_this_long = 5.0; //in seconds

}


//definitely definitely do not mess with this.
update_particle_effect()
{
flags = 0;
if (we_want_the_effect_to_move_towards == "owner") we_want_the_effect_to_move_towards = llGetOwner();
if (we_want_the_effect_to_move_towards == "self") we_want_the_effect_to_move_towards = llGetKey();
if (we_want_the_particle_to_glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (we_want_the_particle_to_bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (we_want_the_particle_to_change_color) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (we_want_the_particle_to_change_size) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (we_want_the_particle_to_follow_wind) flags = flags | PSYS_PART_WIND_MASK;
if (we_want_the_particle_to_follow_its_source) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (we_want_the_particle_to_spin_as_it_turns) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (we_want_the_effect_to_move_towards != "") flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,we_want_each_particle_to_last_fo r,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, when_a_particle_is_created_it_will_have_a_color_va lue_of,
PSYS_PART_END_COLOR, and_then_it_will_gradually_shift_to_a_color_value_ of,
PSYS_PART_START_SCALE,new_particles_start_at_this_ size,
PSYS_PART_END_SCALE,and_change_to_this_size,
PSYS_SRC_PATTERN, we_want_the_effect_to_be_shaped_like_a,
PSYS_SRC_BURST_RATE,we_want_to_create_new_particles_every,
PSYS_SRC_ACCEL, apply_this_constant_force_to_our_particles,
PSYS_SRC_BURST_PART_COUNT,create_this_number_of_particles_at_a_time,
PSYS_SRC_BURST_RADIUS,create_new_particles_this_far_from_the_prim,
PSYS_SRC_BURST_SPEED_MIN,the_slowest_particles_will_be_ejected_at,
PSYS_SRC_BURST_SPEED_MAX,the_fastest_particles_will_be_ejected_at,
PSYS_SRC_TARGET_KEY,we_want_the_effect_to_move_towards,
PSYS_SRC_INNERANGLE,spin_the_fan_this_far_around_the_center_of_the_emitter,
PSYS_SRC_OUTERANGLE,particles_should_fan_out_this_wide,
PSYS_SRC_OMEGA, the_emmitter_will_spin_at_this_rate,
PSYS_SRC_MAX_AGE, the_emmitter_will_create_particles_for_this_long,
PSYS_SRC_TEXTURE, each_particle_should_have_this_texture,
PSYS_PART_START_ALPHA, when_a_particle_is_created_it_will_have_an_alpha_value_of,
PSYS_PART_END_ALPHA, and_then_it_will_gradually_shift_to_an_alpha_value_of
]);
}


integer RUNNING = FALSE;

start_particle_effect()
{
RUNNING = TRUE;
define_effect();
update_particle_effect();
}

clear_the_effect()
{
RUNNING = FALSE;
llParticleSystem([]);
}

default
{
state_entry()
{
clear_the_effect();
}

on_rez(integer NOT_USED)
{
clear_the_effect();
}

touch_start(integer NOT_USED)
{
start_particle_effect();
}

link_message(integer NoT_USED, integer NOt_USED, string the_passed_name, key NOT_uSED)
{
if (the_passed_name == EFFECT_NAME)
{
if (RUNNING == FALSE)
{
wait_for(START_DELAY);
start_particle_effect();
}
else
{
clear_the_effect();
}
}
}
}








stopFire()
{
llParticleSystem([]); //I think an empty list shuts off particles?
}

default
{
state_entry()
{
startFire();
}

touch_start(integer num)
{
stopFire();
llSetStatus(STATUS_PHANTOM, TRUE); // Or however this function works, don't remember

// do whatever's needed to open the door etc.

llSleep(15);

llSetStatus(STATUS_PHANTOM, FALSE);
startFire();
}
}



Cera Dreadlow
Registered User
Join date: 9 Jul 2008
Posts: 21
08-01-2008 10:25
PLEASE! I really need help with this... A way to "pause" a particle script on touch.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-01-2008 11:33
Particles are simply SET by the script; they do not require that the script continue to run for the particles to be actively emitted. In fact, you can even delete the script that set the particles. In order to "pause" particles, you must actively set them OFF using 'llParticleSystem([])' (that's an empty list as a parameter). Then, after your "pause" you can call llParticleSystem() again with your normal parameters to turn them back on.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
08-01-2008 15:12
You can't take an entire script and drop it into a function. What you've got now tries to define a function inside another function, and that's why you're getting your errors. I'm sorry, I guess I assumed a higher level of scripting knowledge on your part when I made my suggestion.

Try this. I haven't checked it in-world so it may still give you some errors, but it's a better attempt at combining my suggestion with your original script.

CODE


// Particle Script by Mike Zidane
// Do what you want with this, but keep it free and post your changes to the boards.

// Give this effect a name, and when it hears it's name called via linkmessage,
// it will wait for START_DELAY to expire, then then fire.
// Define your effect in the define_effect() function.


string EFFECT_NAME = "fire";

float START_DELAY = 0;


//Don't muck around with the declarations.
///////////////////////////////////////////////////////////////////////////////
integer flags;
integer we_want_the_particle_to_glow;
integer we_want_the_particle_to_bounce;
integer we_want_the_particle_to_change_color;
integer we_want_the_particle_to_change_size;
integer we_want_the_particle_to_follow_wind;
integer we_want_the_particle_to_follow_its_source;
integer we_want_the_particle_to_spin_as_it_turns;
key we_want_the_effect_to_move_towards;
float we_want_each_particle_to_last_for;
float the_fastest_particles_will_be_ejected_at;
float the_slowest_particles_will_be_ejected_at;
string each_particle_should_have_this_texture;
float when_a_particle_is_created_it_will_have_an_alpha_v alue_of;
float and_then_it_will_gradually_shift_to_an_alpha_value _of;
vector when_a_particle_is_created_it_will_have_a_color_va lue_of;
vector and_then_it_will_gradually_shift_to_a_color_value_ of;
vector new_particles_start_at_this_size;
vector and_change_to_this_size;
vector apply_this_constant_force_to_our_particles;
float we_want_to_create_new_particles_every;
float create_new_particles_this_far_from_the_prim;
integer create_this_number_of_particles_at_a_time;
float particles_should_fan_out_this_wide;
float spin_the_fan_this_far_around_the_center_of_the_emi tter;
vector the_emmitter_will_spin_at_this_rate;
float the_emmitter_will_create_particles_for_this_long;
integer burst = PSYS_SRC_PATTERN_EXPLODE;
integer none = PSYS_SRC_PATTERN_DROP;
integer empty_cone = PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY;
integer cone = PSYS_SRC_PATTERN_ANGLE_CONE;
integer fan = PSYS_SRC_PATTERN_ANGLE;
integer we_want_the_effect_to_be_shaped_like_a;

//Don't muck around with the functions either.
float randBetween (float min, float max)
{
return llFrand(max - min) + min;
}

wait_for(float delay)
{
llSleep(delay);
}


//except this one. This is where you do your thing.
define_effect()
{
we_want_the_particle_to_glow = TRUE;

we_want_the_particle_to_bounce = FALSE;

we_want_the_particle_to_change_color = TRUE;

we_want_the_particle_to_change_size = TRUE;

we_want_the_particle_to_follow_wind = FALSE;

we_want_the_particle_to_follow_its_source = FALSE;

we_want_the_particle_to_spin_as_it_turns = TRUE;

we_want_the_effect_to_be_shaped_like_a = cone
// burst
// empty_cone
// cone
// fan
// none (= DROP)
;

we_want_the_effect_to_move_towards = ""; //(use a key,self,or owner inside the quotes)

we_want_each_particle_to_last_for = 6.0; //seconds.

the_fastest_particles_will_be_ejected_at = 0.15; // meters per second.

the_slowest_particles_will_be_ejected_at = 0. 0; // meters per second.

each_particle_should_have_this_texture = "";
//(a key is preferred here. use "" for none.)

when_a_particle_is_created_it_will_have_an_alpha_v alue_of = 1.0;
//(0.0 is transparent, 1.0 is opaque.)

and_then_it_will_gradually_shift_to_an_alpha_value _of = 0.0;
//over the life of the particle.

when_a_particle_is_created_it_will_have_a_color_va lue_of = <1.0,.5,0.0>;

and_then_it_will_gradually_shift_to_a_color_value_ of = <0,0,0>;
//over the life of the particle.

new_particles_start_at_this_size = <1.5,1.5,1.5>;

and_change_to_this_size = <0.25,0.25,0.25>;
//over the life of the particle.

apply_this_constant_force_to_our_particles = <0.0,0.0,0.15>;

we_want_to_create_new_particles_every = 0.1; //seconds.

create_new_particles_this_far_from_the_prim = 0.0; //for burst patterns only.

create_this_number_of_particles_at_a_time = 4.0;

//for angle patterns,
particles_should_fan_out_this_wide = 0; //in radians

spin_the_fan_this_far_around_the_center_of_the_emi tter = 0; //,also in radians.

the_emmitter_will_spin_at_this_rate = <0,0,0>;

the_emmitter_will_create_particles_for_this_long = 5.0; //in seconds

}


//definitely definitely do not mess with this.
update_particle_effect()
{
flags = 0;
if (we_want_the_effect_to_move_towards == "owner") we_want_the_effect_to_move_towards = llGetOwner();
if (we_want_the_effect_to_move_towards == "self") we_want_the_effect_to_move_towards = llGetKey();
if (we_want_the_particle_to_glow) flags = flags | PSYS_PART_EMISSIVE_MASK;
if (we_want_the_particle_to_bounce) flags = flags | PSYS_PART_BOUNCE_MASK;
if (we_want_the_particle_to_change_color) flags = flags | PSYS_PART_INTERP_COLOR_MASK;
if (we_want_the_particle_to_change_size) flags = flags | PSYS_PART_INTERP_SCALE_MASK;
if (we_want_the_particle_to_follow_wind) flags = flags | PSYS_PART_WIND_MASK;
if (we_want_the_particle_to_follow_its_source) flags = flags | PSYS_PART_FOLLOW_SRC_MASK;
if (we_want_the_particle_to_spin_as_it_turns) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK;
if (we_want_the_effect_to_move_towards != "") flags = flags | PSYS_PART_TARGET_POS_MASK;

llParticleSystem([ PSYS_PART_MAX_AGE,we_want_each_particle_to_last_fo r,
PSYS_PART_FLAGS,flags,
PSYS_PART_START_COLOR, when_a_particle_is_created_it_will_have_a_color_va lue_of,
PSYS_PART_END_COLOR, and_then_it_will_gradually_shift_to_a_color_value_ of,
PSYS_PART_START_SCALE,new_particles_start_at_this_ size,
PSYS_PART_END_SCALE,and_change_to_this_size,
PSYS_SRC_PATTERN, we_want_the_effect_to_be_shaped_like_a,
PSYS_SRC_BURST_RATE,we_want_to_create_new_particle s_every,
PSYS_SRC_ACCEL, apply_this_constant_force_to_our_particles,
PSYS_SRC_BURST_PART_COUNT,create_this_number_of_pa rticles_at_a_time,
PSYS_SRC_BURST_RADIUS,create_new_particles_this_fa r_from_the_prim,
PSYS_SRC_BURST_SPEED_MIN,the_slowest_particles_wil l_be_ejected_at,
PSYS_SRC_BURST_SPEED_MAX,the_fastest_particles_wil l_be_ejected_at,
PSYS_SRC_TARGET_KEY,we_want_the_effect_to_move_tow ards,
PSYS_SRC_INNERANGLE,spin_the_fan_this_far_around_t he_center_of_the_emitter,
PSYS_SRC_OUTERANGLE,particles_should_fan_out_this_ wide,
PSYS_SRC_OMEGA, the_emmitter_will_spin_at_this_rate,
PSYS_SRC_MAX_AGE, the_emmitter_will_create_particles_for_this_long,
PSYS_SRC_TEXTURE, each_particle_should_have_this_texture,
PSYS_PART_START_ALPHA, when_a_particle_is_created_it_will_have_an_alpha_v alue_of,
PSYS_PART_END_ALPHA, and_then_it_will_gradually_shift_to_an_alpha_value _of
]);
}


integer RUNNING = FALSE;

start_particle_effect()
{
RUNNING = TRUE;
define_effect();
update_particle_effect();
}

clear_the_effect()
{
RUNNING = FALSE;
llParticleSystem([]);
}

default
{
state_entry()
{
clear_the_effect();
}

on_rez(integer NOT_USED)
{
}

touch_start(integer NOT_USED)
{
clear_the_effect();

llSetStatus(STATUS_PHANTOM, TRUE); // Or however this function works, don't remember

// do whatever's needed to open the door etc.

llSleep(15);
llSetStatus(STATUS_PHANTOM, FALSE);

start_particle_effect();
}

link_message(integer NoT_USED, integer NOt_USED, string the_passed_name, key NOT_uSED)
{
if (the_passed_name == EFFECT_NAME) {
if (RUNNING == FALSE) {
wait_for(START_DELAY);
start_particle_effect();
} else {
clear_the_effect();
}
}
}
}



The SL forum software likes to insert spaces into posts, so if you get weird compile errors, and it looks like there are 2 words that should be 1 word, try deleting the space between the 2 words.