|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-18-2006 14:01
You may have seen my "anti grief/shield script" on the scripting library. Well, I've just realized something has gone terribly wrong. The script, work when a bullet comes near it, and also will turn off correctly... the first time. The second you get hit, the shield pops up and a million others rez constantly, even if the bullet is no longer there, and no one is shooting anymore. When I say "/2 auto shield off" the sensor is removed, and I no longer have to worry about oddly spawning shields. There is something wrong with the sensor, and it will constantly detect things that arent' there after being shot once or more. What exactly is wrong? I've referred to the wiki, and I can't see what is wrong. Here's the code. default { state_entry() { llListen(2,"",llGetOwner(),""); } listen(integer channel,string name,key id,string message) { if(message=="auto shield on") { llOwnerSay("Auto Shield Activated."); llSensorRepeat("","",ACTIVE,1.5,TWO_PI,0.001); } if(message=="auto shield off") { llOwnerSay("Auto Shield deactivated."); llSensorRemove(); } } sensor(integer num_detected) { float TEMP = 10000.00 * (llGetMass() * llPow(123456,2)); llPushObject(llDetectedKey(0), <0,0,TEMP>, ZERO_VECTOR, 0); llRezObject("Auto Shield",llGetPos(),<0,0,.3>,ZERO_ROTATION,42); } }
|
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
03-18-2006 14:49
Your sensor interval is FAR too small - since llRezObject sleeps the script for 0.1 seconds, if that sensor is being triggered that often (and in reality, it's probably not managing that speed, but is still triggering during the sleep), it stacks 100 more sensor() events in the queue.
Trim the sensor repeat to 0.15 or so.
|
|
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
|
03-18-2006 14:51
If you are sensing ACTIVE types wouldn't it detect itself since it contains an active script? I could be wrong though. Just thinking out loud.
|
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
03-18-2006 14:53
From: Kurshie Muromachi If you are sensing ACTIVE types wouldn't it detect itself since it contains an active script? I could be wrong though. Just thinking out loud. Yes, good point, assuming the "shield" prim is scripted.
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-18-2006 15:00
Well it's attached to me, and I believe sensors dont find anything that is part of "me".
|
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
03-18-2006 15:14
From: Exile Loudon Well it's attached to me, and I believe sensors dont find anything that is part of "me". Quite right - but does the prim it rezzes as a shield have a script in it? If so, and the scruipt is "active" then your sensor will pick that up as well and rez another sheild. You may want to add a conditional: sensor(integer num_detected) { if(llVecMag(llDetectedVel(0)) > 8.0) { float TEMP = 10000.00 * (llGetMass() * llPow(123456,2)); llPushObject(llDetectedKey(0), <0,0,TEMP>, ZERO_VECTOR, 0); llRezObject("Auto Shield",llGetPos(),<0,0,.3>,ZERO_ROTATION,42); } } So it does not bother to rez or push unless the object is going faster than 8 meters per second. If it's sensing the sheild prim, and it's not physical, it won't have any velocity and so won't trigger another rez. This plus an adjusted sensor interval should solve your problem. 
|
|
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
|
03-18-2006 15:17
From: Exile Loudon Well it's attached to me, and I believe sensors dont find anything that is part of "me". Would it sense the rezzed objects? EDIT: Jill beat me 
|
|
Exile Loudon
Aspiring Scripter
Join date: 10 Dec 2005
Posts: 122
|
03-18-2006 15:17
okay, thanks 
|