Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Looking for content that relies on attach() event when derezzing to inventory

Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
10-12-2005 20:42
Currently there is a bug in 1.6 where the attach() event is called _before_ the object is detached from the avatar when the object is "detached to inventory", as opposed to _after_ it is detached in the case of "drop into world".

In 1.7, due to some fixes in how the rotation/position of the attachment is more correctly saved on detach this bug is more problematic than ever. It occured to some of us that maybe no one actually relies on the attach() event triggering before the object is taken to inventory in which case we would like to not bother supporting it _before_ derez. It turns out that there is no gaurantee that the attach() event will happen anyway since if the script is in the middle of a deep loop, or a very complicated function, it may not escape that scope in the amount of CPU cycles granted to the script before it is derezzed.

So, I'm curious is anyone knows of content they have seen or made that relies on the attach() event being processed before "detach to inventory". What scenarios could you imagine where the fact that the event is called before derez is important?

Also, if anyone has such content already, I'd be interested in getting a copy of it so I can test it in 1.7. Thanks.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
10-12-2005 22:59
Hello Andrew,

Although I couldn't really understand what kind of bug you menstioned, I have a problem related to attach() event.

It is a horse. You have to rez it on ground and attach it to ride. Whenever I attach it, the horse comes back into my inventory but the riding pose animation keeps being played. Some of my attachments disappers and my avatar becomes female. :D Though I can see my avatar in the screen, my friends say they can't see my avatar but a part of head. They can't see even my account name above my avatar.

I sent a bug report a couple of days ago in world but I have got no response except the first replying since then.

I'd like you to check it, but the horse is no transferable. :(
OK, I will also check it in 1.7 and report it here.
_____________________
:) Seagel Neville :)
Tateru Nino
Girl Genius
Join date: 13 Sep 2005
Posts: 312
10-12-2005 23:21
I used it, early on - mostly in a misguided fashion, actually - apparently my code still fruitlessly uses it. I can see uses for it though (in a vague, cloudy, undefined sort of way), I'm just not sure that they justify retention of the hook.

On the other hand, I'd hate to lose (a possibly potentially useful) hook, just because we might not have a use for it today. With HUD attachments looming, particularly, someone might just find a use for that hook tomorrow.

You know how it is...an event hook gets removed, and ten days after the next set of features lands in your lap you are suddenly wishing you had it back.

For my money, document it as attach() is called just before the item is detached, if it is being detached to inventory, as opposed to it's behaviour when being detached to world. Maybe the reliability of the event can be hacked on in future.
_____________________
Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
10-13-2005 07:35
One idea that was kicked around the lab about how the attach() event could be used when detaching an attachment to inventory would be as a "I'm going away now" message to anything else that might be interested in knowing that the attachment was around or not, such as a backpack or sword that notifies a game controller that the player is leaving the game.

Anybody ever do that yet? Can anyone think of other useful things that can be done in that event before the attachment is derezed?
Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
10-13-2005 07:44
Seagel, that sounds like a crazy bugged horse. If we find each other in world and you rez it for me then I can take a copy of a no-transfer item for debugging purposes. Better yet, if you leave a copy of it rezzed somewhere I can just yank a copy of the entire region and run it in a local grid on my workstation. I'd need the name of the object and its location. Send me an IM if you do that and a I'll make it an official bug entry on my end.

Tateru, attach() should not be called before the object is actually detached, because that is different than the 'drop into world' case, and will cause things to do different things in each case. It is the discrepancy between the two cases that I need to fix.
Nathan Stewart
Registered User
Join date: 2 Feb 2005
Posts: 1,039
10-13-2005 07:46
I think its used in crystalshard foo's dance-foo sphere, so when you teleport out of the sim dancing with the sphere attached to you, it tells it to stop the dance, so you dont tp into somewhere dancing lol
_____________________
Tateru Nino
Girl Genius
Join date: 13 Sep 2005
Posts: 312
10-13-2005 07:49
I think it makes sense as a sort of destructor. I mean, for the obsessively tidy, abort your scans, terminate your listens, report pending detachment to the wearer, owner, or other dinguses that might be hanging around your person.
_____________________
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
10-13-2005 07:49
From: Andrew Linden
I can just yank a copy of the entire region and run it in a local grid on my workstation.

*drools*
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Digi Vox
Registered User
Join date: 10 Apr 2005
Posts: 25
10-13-2005 08:18
I'd really like to be able to do llDie() when an object is detached to prevent the object from going back into inventory. I've used the attach() event to just remove all the old content from the object when it's dettached and then have it die the next time it's rezzed, but you end up with a messy inventory. It would be great to use a HUD just while you're playing a game and not have to worry about keeping it around for next time or end up with a thousand HUDs if you play something often.
Upshaw Underhill
Techno-Hobbit
Join date: 13 Mar 2003
Posts: 293
10-13-2005 09:42
From: Andrew Linden
I can just yank a copy of the entire region and run it in a local grid on my workstation.

From: Jesrad Seraph
*drools*


ROFL, I actually said that IRL when I saw him say that.

As far as content, the backpack for DarkLife says "see you next time" or some such when you detatch. I can certainly see instances where it would be nice for it to fire... such as the HUD example above. For one time use or game/sim specific items. It would be a lot easier for game 'system' to try to keep track of people by just listening for the attach/detatch messages from an attachment than trying to poll each user on a semi-regular basis. </me shudders>

L8r,
UU
_____________________
Afir Zagato
fjnord
Join date: 2 Sep 2005
Posts: 4
10-15-2005 07:06
Does this bug affect the function llDetachFromAvatar()? If it does/does not, could someone explain?
_____________________
"A little nonsense now and then, is cherished by the wisest men."
-- Roald Dahl, (Willy Wonka) Charlie and the Chocolate Factory
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
10-15-2005 08:51
Andrew, I could't find you whenever I log in. So I called another Linden, Harry. He made sure that bug and enjoyed. :D He could also disappear completely. ;)
_____________________
:) Seagel Neville :)
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-15-2005 09:26
More people use this then you might expect. I'm pretty sure attach() is used in those particle poof scripts to make them poof when you tp in and out.
_____________________
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
Fractal Mandala
Registered User
Join date: 15 Dec 2003
Posts: 60
10-15-2005 10:23
When an object is detached to inventory, is there ever a time when it's no longer attached to the avatar but still exists in-world? If not, having the attach() event fire just before the object is actually detached seems like the most appropriate behavior.
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
10-15-2005 11:11
From: Andrew Linden

...

So, I'm curious is anyone knows of content they have seen or made that relies on the attach() event being processed before "detach to inventory". What scenarios could you imagine where the fact that the event is called before derez is important?


I'm not exactly sure I understand the question here. Are you saying that the solution to the discrepancy between drop and detach-to-inventory would be to run the attach() event after the object is already off the avatar and sitting in the inventory? What does it even mean for a script to be running in an object that doesn't even exist in-world? What happens if it tries to rez objects, llSay, or do other "in-world" things? Silent failure?

I know one very common thing for scripts to do during detaching is to stop animations. Whatever solution you come up with, that still needs to work, so my arm doesn't stay stuck out when I detach my beer ;) Your explanation of how this can happen when a script is too busy to allow the detach event to happen makes a lot of sense... it explains why sometimes attachments I've created will fail to stop their animations on detach.

I do definitely have at least one object that depends on being able to proclaim its death to a server object when it detaches. It's a game called HoloBall that's set up in the northwest corner of Eldora... although to play, you'll need to get a copy of the racket attachment from me. The way it's scripted, it's not CRITICAL that rackets let the server know they've gone away when they detach, because we also have to deal with the case that the player just wanders off, racket attached.

Still, from the sound of it, unless I'm misunderstanding, if the attach() event happens after the object is already removed from the avatar, lots of "in-world" things would fail, which I think would be a bad (and potentially very confusing) thing.
Nathan Stewart
Registered User
Join date: 2 Feb 2005
Posts: 1,039
10-15-2005 11:19
From a quick test it seems this is working as well kinda like it was bugged lol

Its firing on attach, detach to floor and detach to inventory (also the hovertip in the script editor says it should fire on detach too)
_____________________
Andrew Linden
Linden staff
Join date: 18 Nov 2002
Posts: 692
10-17-2005 08:34
Yes, attach() is fired when the object is attached and when it is detached. There is no detach() event at this time; attach() serves for both cases. To distinqush between the two you must examine the 'key' that is provided as an argument to the event.

I've submitted my fix for this problem in 1.7 already. The script will still try to execute its attach() event on detach-to-inventory. Under the hood the object is still attached to the avatar at this time however I added some trickery to make llGetAttached() correctly return '0', and calls to llSetRot() or llSetPos() will do nothing after the detach operation is started. It may be that a few other calls are "broken" in this case... such as llGetLocalPos(), which may actually return the attachment's avatar-local position instead of whatever an in-world object would return.

As mentioned earlier there is no gaurantee that the attach() event will complete before the object gets derezed. In particular, if you call an expensive operation within the attach() event the script may be descheduled enough to cause the derez to happen before the attach() event is complete. Although llSetPos() is a no-op during detach-to-inventory it will still cost the script the same amount of execution time because the schedule cost is computed before the operation fails -- an inflexibility of the script engine that exists at this time.


Seagel, I'm almost never in-world. Send me an IM when you're in and if I can I'll try to log in. But not late today, because I'll be out unavailable after 11:00 this morning.
Fox Stirling
Certified Lunatic
Join date: 16 Aug 2004
Posts: 120
10-17-2005 08:49
From: Andrew Linden
I can just yank a copy of the entire region and run it in a local grid on my workstation.


From: Jesrad Seraph
*drools*


seconded!! :D
Fox
_____________________
...
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
10-17-2005 19:49
From: Andrew Linden
Seagel, I'm almost never in-world. Send me an IM when you're in and if I can I'll try to log in. But not late today, because I'll be out unavailable after 11:00 this morning.
Sorry for soiling this thread with my personal bug reporting. Andrew, I told you that I'd already given it to Harry Linden. Should I contact to you, too? My usual time for login is around 6:00 a.m. :D
_____________________
:) Seagel Neville :)
Eggy Lippmann
Wiktator
Join date: 1 May 2003
Posts: 7,939
10-18-2005 11:55
I have relied on it more than once in the past. It's even in the wiki code samples, I think. The content doesn't matter to me anymore though so personally I wouldn't care if this was removed.