|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
02-01-2007 16:16
I after over a year of effort I'm still a hack at scripting but I learn alittle more each day and I have alot of fun with it. I made a collision_start "switch" to turn on a particle stream and that worked well. So, now I am trying to use it to make a "switch" that will rez an object after an avatar walks over a prim. That works fine but it rezzes multiple items, how would I go about limiting this to rez only one or two times? Any suggestions? Examples are what I really need because discussions quickly go over my head.
integer PRIMCHAN = 2346;// had to put something here to compile
default { collision_start(integer num_detected) { llSay(0, llDetectedName(0) + " collided with me!"); llRezObject("objectname", llGetPos() + <0, 0, 1>, ZERO_VECTOR, llGetRot(), PRIMCHAN); } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
02-01-2007 16:52
Collisions are sometimes difficult because they can be triggered very rapidly even if you wouldn't expect multiple trigger events. To see the effect, put a llOwnerSay() in the collision event. I can think of at least two ways to help your situation:
Timer- Use a timer to limit the effect of the collisions. For instance, use a TRUE/FALSE switch variable within your collisions_start which sets FLASE after the first collision. Then, use a collision_end event to set a timer. When the timer runs out, set your switch to allow collisions again.
Key List- Use a list to allow object rez only when a new key collides. When the collision_start event is triggered, compare the llDetectedKey() with the list, if found... don't rez a new object. You could use a slow timer to reset the list of keys over time.
|
|
Daisy Rimbaud
Registered User
Join date: 12 Oct 2006
Posts: 764
|
02-02-2007 03:07
Perhaps you don't even need a timer - You could have it so that only one object is rezzed at a time. Whatever terminates the existence of the rezzed object would reset the collision detection. Not sure what the best way to do that is, though - is there an event triggered on deletion of an object?
Otherwise, the generator might have to poll for the existence of its rezzed object every so often.
|
|
Domino Marama
Domino Designs
Join date: 22 Sep 2006
Posts: 1,126
|
02-02-2007 03:54
PRIMCHAN in your code relates to the start_param in the on_rez event. Unless you need to pass data to the rezzed object, just use 0. The simplest way to reduce the number of collisions is to maintain a list of currently colliding avs. Rather than use a timer, it makes sense to do the cleanup in the collision_end event. Something like this perhaps: list currentHits; integer i; key hit;
default { state_entry() { llVolumeDetect( TRUE ); } collision_start(integer num_detected) { while ( num_detected ) { hit = llDetectedKey( --num_detected ); if ( llListFindList( currentHits, [ hit ] ) == -1 ) { llSay(0, llDetectedName(num_detected) + " collided with me!"); llRezObject("objectname", llGetPos() + <0, 0, 1>, ZERO_VECTOR, llGetRot(), 0); } currentHits += [ hit ]; } }
collision_end( integer num_detected) { while ( num_detected ) { i = llListFindList( currentHits, [ llDetectedKey( --num_detected ) ] ); if ( i != -1 ) { currentHits = llDeleteSubList( currentHits, i, i ); } } } }
|
|
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
|
02-04-2007 07:19
Thank you all for the help. An additional search of the forum turned up this thread, suggesting using states to limit the collision to one event, it works great. Multiple Collision Events Here is the working script using States. default { state_entry() {} collision_start(integer total_number) { state RezObject; } }
state RezObject { state_entry() { llSetTimerEvent(30); //llSay(0, llDetectedName(0) + "Who dares to trespass here?!?!"); llRezObject("Object", llGetPos() + <0, 0, 1>, ZERO_VECTOR, llGetRot(), 0);
}
timer() { llSetTimerEvent(0); state default; } }
_____________________
 VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30 http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240 http://shop.onrez.com/Archtx_Edo
|