|
Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
|
06-27-2006 15:46
I hate asking for this type of help. I'm looking for a script, I don't know how to do this. When an avatar gets near a a timed event will happen. Lets say, an avatar comes within 10 meters of a particle poofer, it will go off for 5 seconds. I know that this is easy, but i've never made anything with a sensor before. I think that its easy.
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
06-27-2006 18:53
sensors are pretty ez llSensor(string name, key id, integer type, float range, float arc) string name is a filter if you know the name of the item your scanning for if not use "" key id, same thing but as a key for open scan use NULL_KEY integer type is on the wiki, your probally gonna use AGENT (or 1) float range, in meters, this defines the scan range, but its a radius, so a value of 10 would cover a 20m sphere , 5 would cover a 10m sphere ect float arc this is kinda funky If arc is x radians, the sensor will look for x radians around the object's forward vector (which is the object's local X axis, positive direction), so the actual sweep of the search is 2 * x radians, and thus PI radians will search all around the object. with normal use of radians PI is = half a circle, since sensors dubble it, PI now is good for a full circle (which makes a 3d sphere), i think this is the only situation 2*radian comes up sensors and timers are 2 of the top 5 things attribuited to lag, they are not bad, but really fast events constantly going off can cause noticible sim lag. to keep it "low impact" i would probally do something like this
sweep() { llSensor("",NULL_KEY,1,5,PI); }
start_particles() { llSay(0,"obo"); }
kill_particles() { llParticleSystem([ ]); }
default { state_entry() { sweep(); }
sensor(integer tn) { if (tn == 0) { llSleep(1); } else { start_particles(); llSleep(5); kill_particles(); } sweep();
} }
this way has a cupple bonses... 1 your using a single sensor sweep per loop, which is much more controlable, ie it will not do another sweep untill its done processing that 1 event, using something like llSensorRepeate, most ppl tend to switch it on and leave it blasting no matter what, which doesnt help the sim much, nor your script becuase it tends to cause overflows 2 there is NO TIMER, llSleep and loops will do the trick as long as ... you dont need the script to actually do anything during this timeout (like accept payment or touches ect) becuase it actually pauses the script during the specified time anyways good luck to you !
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
06-28-2006 01:07
sensor() only fires when there's at least one detected target - you need to use no_sensor() there e.g. sensor(integer tn) { start_particles(); llSleep(5); kill_particles(); sweep(); }
no_sensor() { llSleep(1); }
|
|
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
|
06-28-2006 01:17
I've tried this, but will re-create the sensor()/no_sensor() handling; as well as with normal llSensorRepeat...
With no_sensor() I've found the item to become less reacting compared to llSensorRepeat; it also spawns a lot of no_sensor () events, which I think will cause more lag then using llSensorRepeat.
IMHO, it would be a bit strange to use a 'fabricated' sensor repeat function to *prevent* lag, if there is one built-in.
I will post findings...
|
|
Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
|
06-28-2006 05:58
I've tried to make this work. But it doesn't work for me. Can one of you please see where I goofed it at? // Mask Flags - set to TRUE to enable integer glow = TRUE; // Make the particles glow integer bounce = FALSE; // Make particles bounce on Z plan of object integer interpColor = TRUE; // Go from start to end color integer interpSize = TRUE; // Go from start to end size integer wind = FALSE; // Particles effected by wind integer followSource = FALSE; // Particles follow the source integer followVel = FALSE; // Particles turn to velocity direction
// Choose a pattern from the following: // PSYS_SRC_PATTERN_EXPLODE // PSYS_SRC_PATTERN_DROP // PSYS_SRC_PATTERN_ANGLE_CONE_EMPTY // PSYS_SRC_PATTERN_ANGLE_CONE // PSYS_SRC_PATTERN_ANGLE integer pattern = PSYS_SRC_PATTERN_EXPLODE;
// Select a target for particles to go towards // "" for no target, "owner" will follow object owner // and "self" will target this object // or put the key of an object for particles to go to key target = "";
// Particle paramaters float age = 30; // Life of each particle float maxSpeed = 1; // Max speed each particle is spit out at float minSpeed = 1; // Min speed each particle is spit out at string texture = "Heart"; // Texture used for particles, default used if blank float startAlpha = 1; // Start alpha (transparency) value float endAlpha = 1; // End alpha (transparency) value vector startColor = <1,1,1>; // Start color of particles <R,G,B> vector endColor = <1,1,1>; // End color of particles <R,G,B> (if interpColor == TRUE) vector startSize = <.5,.5,.5>; // Start size of particles vector endSize = <.5,.5,.5>; // End size of particles (if interpSize == TRUE) vector push = <0,0,0>; // Force pushed on particles
// System paramaters float rate = 0.01; // How fast (rate) to emit particles float radius = 0.1; // Radius to emit particles for BURST pattern integer count = 5; // How many particles to emit per BURST float outerAngle = 1.55; // Outer angle for all ANGLE patterns float innerAngle = 1.55; // Inner angle for all ANGLE patterns vector omega = <0,0,0>; // Rotation of ANGLE patterns around the source float life = 30; // Life in seconds for the system to make particles
// Script variables integer flags;
updateParticles() { if (target == "owner") target = llGetOwner(); if (target == "self") target = llGetKey(); if (glow) flags = flags | PSYS_PART_EMISSIVE_MASK; if (bounce) flags = flags | PSYS_PART_BOUNCE_MASK; if (interpColor) flags = flags | PSYS_PART_INTERP_COLOR_MASK; if (interpSize) flags = flags | PSYS_PART_INTERP_SCALE_MASK; if (wind) flags = flags | PSYS_PART_WIND_MASK; if (followSource) flags = flags | PSYS_PART_FOLLOW_SRC_MASK; if (followVel) flags = flags | PSYS_PART_FOLLOW_VELOCITY_MASK; if (target != "") flags = flags | PSYS_PART_TARGET_POS_MASK;
llParticleSystem([ PSYS_PART_MAX_AGE,age, PSYS_PART_FLAGS,flags, PSYS_PART_START_COLOR, startColor, PSYS_PART_END_COLOR, endColor, PSYS_PART_START_SCALE,startSize, PSYS_PART_END_SCALE,endSize, PSYS_SRC_PATTERN, pattern, PSYS_SRC_BURST_RATE,rate, PSYS_SRC_ACCEL, push, PSYS_SRC_BURST_PART_COUNT,count, PSYS_SRC_BURST_RADIUS,radius, PSYS_SRC_BURST_SPEED_MIN,minSpeed, PSYS_SRC_BURST_SPEED_MAX,maxSpeed, PSYS_SRC_TARGET_KEY,target, PSYS_SRC_INNERANGLE,innerAngle, PSYS_SRC_OUTERANGLE,outerAngle, PSYS_SRC_OMEGA, omega, PSYS_SRC_MAX_AGE, life, PSYS_SRC_TEXTURE, texture, PSYS_PART_START_ALPHA, startAlpha, PSYS_PART_END_ALPHA, endAlpha ]); } sweep() { llSensor("",NULL_KEY,1,5,PI); }
start_particles() { llOwnerSay("Starting Particles"); updateParticles(); }
kill_particles() { llParticleSystem([ ]); }
default { state_entry() { sweep(); }
sensor(integer tn) { start_particles(); llSleep(5); kill_particles(); sweep(); }
no_sensor() { llSleep(1); }
}
|
|
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
|
06-28-2006 11:11
From: Robin Peel I've tried to make this work. But it doesn't work for me. Can one of you please see where I goofed it at? no_sensor() { llSleep(1); }
llSensor only does 1 sweep... If that is done, without people nearby, you will end up in the no_sensor event, where llSleep waits for 1 second. After that, nothing happens anymore.... It should read:
no_sensor() { llSleep(1); sweep(); // Restart sensor }
However my experience is that it would be wiser to use llSensorRepeat and forget about the no_sensor... Because the chances are, no_sensor will called so often it will cause more lag then llSensorRepeat. Just set repeat interval to 5 or 10 seconds (or more)...
|
|
Robin Peel
Registered User
Join date: 8 Feb 2005
Posts: 163
|
06-28-2006 11:36
Thank you. As soon as I'm able to get back in I will make the change.
|
|
MarkA Runo
Registered User
Join date: 28 Jan 2009
Posts: 5
|
02-27-2009 11:04
From: Marcuw Schnook llSensor only does 1 sweep... If that is done, without people nearby, you will end up in the no_sensor event, where llSleep waits for 1 second. After that, nothing happens anymore.... It should read:
no_sensor() { llSleep(1); sweep(); // Restart sensor }
However my experience is that it would be wiser to use llSensorRepeat and forget about the no_sensor... Because the chances are, no_sensor will called so often it will cause more lag then llSensorRepeat. Just set repeat interval to 5 or 10 seconds (or more)... I’m getting to understand this now, so it repeats the sweep in 5 to 10 seconds. Is there a way to incorporate a “config” note card that the owner could easy to change what it is sensing or sweeping for? I want to call a few moving Prims “Object A’ “Object B” etc and let the owner change what to be searched on in the card. This way it prevents the script from being messed with. Thanks for any suggestions and have a great day
|