Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Am I bugged? Really basic attach() problem

Kirilisa Tigerpaw
Registered User
Join date: 6 Nov 2007
Posts: 15
11-18-2007 02:25
Ok, I posted earlier with a music script I was having issues... I've been mucking around and I discovered something which I think is the key to my music script issues and which makes me wonder if I am insane.

How is the attach() event supposed to work? I made a cube prim and stuck the below script into it. All it does it when you attach or detach the prim is tells you if you have attached or detached. I got the code straight off wiki.secondlife.com.

What happens? I attach the prim. Nothing happens. I detach the prim. It says "I have been attached." "I have been detached."

Whhhat? By this reasoning, when you attach something attach() event doesn't happen, but when you detach something, it happens twice?

Is there something wrong with me?!?!!? Is my avatar in some weird hidden demented state that I do not know about?

CODE

default
{
attach(key id)
{
if(id)//tests if it is a valid key and not NULL_KEY
{
llSay(0,"I have been attached!");
}
else
{
llSay(0,"I have been detached!");
}
}
}
Core Taurog
Registered User
Join date: 2 May 2007
Posts: 17
11-18-2007 04:20
Hi Kirilisa,

I've just tried this in game now and it works fine for me; attaching from the ground, detaching, attaching from inventory, dropping, etc.; all seems to work.

regards,

Core
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
11-18-2007 04:30
The script you posted also works fine for me.

What you're observing feels to me like a symptom of a no-script area - when many events seem to get delayed and then trigger on top of each other.
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-18-2007 04:32
sl sometimes has a glitch when saving, if you save and activate the script by attaching right after save it will couse it to lock up and not work, try copy/pasting it into a new script
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
11-18-2007 08:35
What you describe sounds pretty familiar. It sounds like what happens if you have a script with an attach() event in a child prim of an attachment. It's a bug that's been around for a long time :(
Kirilisa Tigerpaw
Registered User
Join date: 6 Nov 2007
Posts: 15
11-18-2007 14:09
Thanks for the answers all of you. I am in a sandbox so I presumed that scripts would work fine, but maybe I'm wrong?

I tried it with both my avatar and my husband's avatar on 2 different machines just for kicks and the blasted script failed in the same way every single time.

And, regarding what Lex said "It sounds like what happens if you have a script with an attach() event in a child prim of an attachment." -- what does that mean exactly? What is a 'child prim of an attachment'? I have just the one basic prim with that lone script in it.

Sorry if dumb question - I'm awfully new to Second Life & LSL.

Thanks!
Kirilisa Tigerpaw
Registered User
Join date: 6 Nov 2007
Posts: 15
11-18-2007 18:50
It was the sandbox I was in. (bangs head against wall). As soon as I went elsewhere the basic attach/detach script worked perfectly.

I didn't realize there were places where scripts wouldn't wholly work... I will never forget this lesson ;-)
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
01-18-2008 09:00
I'm not sure it was the sandbox issue. The last week, I noticed a fairly high failure rate for the attach event. I was making a device that was supposed to ask for animation permission on attach, and it wasn't working consistently. When put an llOwnerSay in the event to debug, "I am a well behaved script" only returned half the time. For me, I was able to solve the problem by putting the permissions request in the on_rez event, but it's a bit of a cludgy fix.

Is anyone else having this problem? I searched JIRA and found no mention of it.
_____________________


Horses, Carriages, Modern and Historical Riding apparel. Ride a demo horse, play whist, or just loiter. I'm fair used to loiterers.

http://slurl.com/secondlife/Caledon%20Eyre/48%20/183/23/
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
01-18-2008 13:15
The attach() event running on detach is not a guaranteed event. There are some very old threads on this, if you search. the sim will try to run the event until the actual detach occurs. At that point the script's state is saved, and the script ceases to run. If you are in a sim which is very laggy or has a lot of scripts running (like a sandbox...), the script won't be running fast enough to do much before it's saved. So the rest of that event will run next time the object is rezzed. That's why you would see both messages upon the next attach, first the previous detach finished, then it responded to the attach.

So, two considerations, don't ever expect the detach to run guaranteed, and alway keep whatever you *do* have going on in the detach code as quick and short as possible. :)
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
01-18-2008 14:53
Are you on "no script" land?
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Virrginia Tombola
Equestrienne
Join date: 10 Nov 2006
Posts: 938
01-18-2008 16:00
No, scripts were enabled in the area and I checked several different sims over the course of three days.

The failure occurred on both attach and detach.

Mind you, I just checked again, and now it's working :rolleyes:....
_____________________


Horses, Carriages, Modern and Historical Riding apparel. Ride a demo horse, play whist, or just loiter. I'm fair used to loiterers.

http://slurl.com/secondlife/Caledon%20Eyre/48%20/183/23/