DCS affecting script
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
01-18-2008 22:56
I have a script that allows an avatar to touch an object and that object follows the person around until they drop it by touching the object again. It is being used on a sim where DCS is used. I found that if someone uses the DCS to heal another person (not even the one the object is attached to), then the object drops. It does not matter whether the one with the attached object has a DCS meter or not. I even tested this having the person with the attached object sit on a DCS healing ball, and when they stand, again the object is dropped. It seems that the DCS heal is cancelling the sensor or someting else that is causing the avatar to be lost so the object is dropped. There is nothing that accesses any DCS code. If more information is needed, I will try to provide that. In the meantime, any ideas? Thank you. Here is a portion of the code that relates to the pickup and drop drop(key target) { if(target==id) { llSensorRemove(); id=NULL_KEY; llShout(0,"DROPPED!"); } }
pickup(key target) { llSay(0,"Picked up!"); id=target; llSensorRepeat("",id,AGENT,200,2*PI,.5); }
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
01-18-2008 23:17
From: Dmitriy Gausman I have a script that allows an avatar to touch an object and that object follows the person around until they drop it by touching the object again. It is being used on a sim where DCS is used. I found that if someone uses the DCS to heal another person (not even the one the object is attached to), then the object drops. It does not matter whether the one with the attached object has a DCS meter or not. I even tested this having the person with the attached object sit on a DCS healing ball, and when they stand, again the object is dropped. It seems that the DCS heal is cancelling the sensor or someting else that is causing the avatar to be lost so the object is dropped. There is nothing that accesses any DCS code. If more information is needed, I will try to provide that. In the meantime, any ideas? Thank you. Here is a portion of the code that relates to the pickup and drop drop(key target) { if(target==id) { llSensorRemove(); id=NULL_KEY; llShout(0,"DROPPED!"); } }
pickup(key target) { llSay(0,"Picked up!"); id=target; llSensorRepeat("",id,AGENT,200,2*PI,.5); }
Do you have any listens in the script?
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
01-19-2008 05:02
Yes. One event that will trigger a drop is if a person's health meter gets to zero. The script listens for DCS to say on channel 0 if the avatar with this object attached has been killed.
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
01-21-2008 20:06
Well, I think I found where the program is going awry. I don't think DCS is necessarily responsible for making the object drop. First I am setting a listen to the DCS2 on channel 0. state_entry() { llOwnerSay("ready"  ; llListen(0,"DCS2 2.30","",""  ; id=NULL_KEY; } But what happens next, is I would think the drop action would only be performed if tbe message is exact: DCS2 2.30: Dmitriy Gausman Has been Defeated However, it seems that it also drops when this message is heard: DCS2 2.30: Dmitriy Gausman heals SELF I tested this by putting an llSay statement just before the drop, to see if this was the place it was occuring. So I am at a loss why it is doing the drop even when the msg differs from what is written here. listen( integer channel, string name, key Listenid, string msg) { if(channel == 0) { if(id!=NULL_KEY) { if(msg=="DCS2 2.30:"+(string)llKey2Name(id)+" Has been Defeated"  ; { drop(id); } } }
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
01-21-2008 21:53
From: Dmitriy Gausman Well, I think I found where the program is going awry. I don't think DCS is necessarily responsible for making the object drop. First I am setting a listen to the DCS2 on channel 0. state_entry() { llOwnerSay("ready"  ; llListen(0,"DCS2 2.30","",""  ; id=NULL_KEY; } But what happens next, is I would think the drop action would only be performed if tbe message is exact: DCS2 2.30: Dmitriy Gausman Has been Defeated However, it seems that it also drops when this message is heard: DCS2 2.30: Dmitriy Gausman heals SELF I tested this by putting an llSay statement just before the drop, to see if this was the place it was occuring. So I am at a loss why it is doing the drop even when the msg differs from what is written here. Side comment -- not sure these are necessary (assuming there's only one listen): if(channel == 0) if(id!=NULL_KEY) Try adding parenthesis, in case it's an oder of calculation problem: if(msg==("DCS2 2.30:"+(string)llKey2Name(id)+" Has been Defeated"  ) And take the semi-colon off the end of the script statement. 
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
01-22-2008 08:48
Something is throwing me off here. It would be expected that only when the "if" criteria is met, that the drop in that condition would occur. Yet it seems to occur no matter what DCS is saying. So that means either the listen is not listening properly (my fault of course), or the DCS is interfering with the script. If it hears the "Heal" event, it should not drop the object inside that "if" condition, yet that is where it is dropping it. If i turn off the Listen, then the object is not dropped no matter what DCS does. The only instance it drops is on touch by the avatar. Unfortunately, I want it to drop only when DCS issues the "defeated" phrase. **i made all the changes Beezle recommended. Thank you 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-22-2008 09:34
It is that semicolon. This: if (condition) ; // <-- Here is an empty statement. It does nothing.
{ // Here is a block of code. It is executed unconditionally // some statements here }
is very, very different from: if (condition) { // some statements here }
I added spaces and comments to make it very clear. Remember that they don't matter to the compiler.
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
01-22-2008 10:14
with or without the semi colon, i get the same result. 
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
01-22-2008 10:36
I took the DCS out of the script for a moment. I made an object and called it "TestObject". I put an llSay command on touch inside the object that says "Drop the Object" I then changed my llListen statement to this: llListen(0,"TestObject","","");
And I changed the conditional if section to this:
if(msg=("TestObject:Drop the Object")) { drop(id); }
Now, when the external object is touched, and says "Drop the Object", the object is dropped from my avatar. When I issue a DCS Heal, the object is not dropped.
So I think it is safe to say that something is being interfered by listening to the DCS. I dont think the conditional section would work if it did not hear DCS saying something but it seems to not matter what DCS says. Anything DCS says is causing the drop. So my code seems to be ok. Something inside it (DCS name or something) or the DCS itself is overriding something.
|
|
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
|
01-22-2008 11:25
Oops, I'm silly: You may want to put this part back. Won't fix the "ignoring the if" problem, but breaks other things. Sorry about that. if(id!=NULL_KEY) --- --- --- if(msg=("TestObject: Drop the Object"  ) Should be: if(msg==("TestObject: Drop the Object"  ) The first one will always be true, you need the double-equals '==' for conditional tests. (added a space after the ':' to avoid auto-smilies)
_____________________
Though this be madness, yet there is method in't. -- William Shakespeare Warburton's Whimsies: In SLApez.biz
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
01-22-2008 12:03
Well, you can always put an llOwnerSay as the first instruction in the listen handler, and have it tell you the exact object name and message it received. Then you can plug that into your test object - that's one way to test your script more accurately, and know exactly what your script is hearing, from DCS or something else.
|
|
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
|
01-22-2008 12:56
Try this: listen( integer channel, string name, key Listenid, string msg) { if(~llSubStringIndex(msg,"Defeated"  && ~llSubStringIndex(msg,llKey2Name(id))){drop(id);} }
|
|
Dmitriy Gausman
Registered User
Join date: 16 May 2007
Posts: 132
|
01-22-2008 20:18
Very- That did it. Thank you very much.  ) Dmitriy
|