Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Teleport and on_rez

Phoenix Linden
SL's Angel of Death
Join date: 3 Dec 2002
Posts: 168
02-16-2006 09:54
A bug report landed in my lap from the 1.9 preview indicating that scripts do not get an on_rez() event after teleport while they do get the event on the 1.8 grid. This surprised me since scripts should not be getting an on_rez() notification except when rezzed -- such as when dragged from object/agent inventory to the world or when llRezObject() is called.

The current behavior is conceptually a bug since the object is being reconstituted as the same object and not really rezzed. Who relies on this current behavior, and how is it being used?
Aliasi Stonebender
Return of Catbread
Join date: 30 Jan 2005
Posts: 1,858
02-16-2006 09:57
From: Phoenix Linden
A bug report landed in my lap from the 1.9 preview indicating that scripts do not get an on_rez() event after teleport while they do get the event on the 1.8 grid. This surprised me since scripts should not be getting an on_rez() notification except when rezzed -- such as when dragged from object/agent inventory to the world or when llRezObject() is called.

The current behavior is conceptually a bug since the object is being reconstituted as the same object and not really rezzed. Who relies on this current behavior, and how is it being used?


Most particle poofers/teleport effects do, and a great many scripts rely on this to reset themselves after a teleport.

It's a bug that's been present for so long, it's a feature.
_____________________
Red Mary says, softly, “How a man grows aggressive when his enemy displays propriety. He thinks: I will use this good behavior to enforce my advantage over her. Is it any wonder people hold good behavior in such disregard?”
Anything Surplus Home to the "Nuke the Crap Out of..." series of games and other stuff
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
02-16-2006 10:11
From: Aliasi Stonebender
It's a bug that's been present for so long, it's a feature.

Ditto.
_____________________
Introvert Petunia
over 2 billion posts
Join date: 11 Sep 2004
Posts: 2,065
02-16-2006 10:18
Thirded.
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
02-16-2006 10:39
I use the attach event myself I think. That is suppose to fire on teleport isn't it?
_____________________
Rizado DaSilva
Merchant
Join date: 12 May 2005
Posts: 30
02-16-2006 10:57
Personally I think it should be fixed, I always wondered about this behaviour and it's caused me indigestion in the past and extra code so that things set on_rez aren't reset on teleport. (not to mention I hate poofers anyways)

=Riz
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
02-16-2006 11:03
I've got several freebie teleport effects that rely in this wandering around. I also rely on it for certain attachment tools that behave better and take fewer resources if it doesn't have to costantly check to see if it's in the same sim as it was (in combo with moving_start()).

Please let us keep that!
_____________________
Reitsuki Kojima
Witchhunter
Join date: 27 Jan 2004
Posts: 5,328
02-16-2006 11:06
I use it the way it is now, and while it wouldn't be a *major* hassle for me, since I don't sell any products based on it, I would as soon it not be changed.
_____________________
I am myself indifferent honest; but yet I could accuse me of such things that it were better my mother had not borne me: I am very proud, revengeful, ambitious, with more offenses at my beck than I have thoughts to put them in, imagination to give them shape, or time to act them in. What should such fellows as I do crawling between earth and heaven? We are arrant knaves, all; believe none of us.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
02-16-2006 11:46
I use this in products I sell. One of them it probably wouldn't break a whole lot, one of them I'm pretty sure I'm going to have to re-write some of the logic if this changes.
Fractal Mandala
Registered User
Join date: 15 Dec 2003
Posts: 60
workaround for "proper" behavior?
02-16-2006 12:04
Is there an easy way to determine in an on_rez event whether the event was triggered because of a teleport? If so, leaving it as is might be okay. If not, you could add another event that works properly, but keep the behavior of the current event. The bug with rotations for child prims was solved like this, though I don't remember the exact functions and I can't find the link to the LSL wiki (why isn't linked from the public site somewhere?).
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
02-16-2006 12:11
How would we go about detecting whether a user teleported to a destination without on_rez? Is not the user's avatar "rezzed" at the new destination?
As p2p teleport now allows one to teleport to a location less then 1 meter away from ones previous location, the only way to check for this condition would be to schedule a timer event that checks for continuous movement position to position. In order for this to be reasonably accurate, the timer must execute at a quick interval - less then 1 second between events, an obvious contributer to lag. The moving_start/end events cannot be used to detect teleport, as the teleport itself does not trigger them.

Dont take functionality away from us. If you correct this "bug", add a new on_teleport() event.
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Coal Edge
I'm here
Join date: 20 Apr 2005
Posts: 18
02-16-2006 12:27
I agree that there should be an on_teleport call for LSL and would help everyone out, though cause some minor rewrites.

I have seen it used but never currently liked the on_rez triggered on teleport. For things such as usage command triggers for certain stuff I moved it from on rez that triggered it to on attatch and that way it tiggered on login I think too, but otherwise only when worn.

As for poofers, since particle effects stay on a prim once set, would it still need the script to trigger on_rez to poof? I thought that once set, anytime the prim "rezzed" so to speak with the avatar it would still trigger until removed. (I just woke up and thought I would add some thoughts to this subject so my facts may be a little off)

I guess its true, so many people have used it as a feature for so long that without a backup solution, it will be considered a bug that it no longer works on teleport with the update.
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
02-16-2006 12:29
From: Christopher Omega
How would we go about detecting whether a user teleported to a destination without on_rez? Is not the user's avatar "rezzed" at the new destination?
As p2p teleport now allows one to teleport to a location less then 1 meter away from ones previous location, the only way to check for this condition would be to schedule a timer event that checks for continuous movement position to position. In order for this to be reasonably accurate, the timer must execute at a quick interval - less then 1 second between events, an obvious contributer to lag. The moving_start/end events cannot be used to detect teleport, as the teleport itself does not trigger them.

Dont take functionality away from us. If you correct this "bug", add a new on_teleport() event.
==Chris


I believe attach is the correct event to use. It should fire when teleporting.

CODE

integer was_dettached = TRUE;

default
{
attach(key id)
{
if (id != NULL_KEY) {
if (was_dettached) { // Go ahead and do your attach stuff, it wasn't a teleport.
was_dettached = FALSE;

} else {
// Oops, this thing wasn't dettached, this must be a teleport.
}
} else {
was_dettached = TRUE;

// Do your dettached stuff here. Dettached isnt fired on teleport.
}
}
}
_____________________
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-17-2006 10:10
You probably want to check with the Gorean sims, they have a lot of gadgets that have to keep track of attachment and detachment, and may be using workarounds for teleports that would run into problems...

I'd say Rickard's code is the right way to do things (thanks) but you might want to go slow on this fix... even to the point of having on_rez fire for existing scripts until they're recompiled.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
02-17-2006 10:25
So, conceptually, if an object isn't re-rezzed when you materialize after a teleport, why is it re-attached? :) Seems to me that the attach event firing is another "that's just the way it happens" thing, just like the on_rez event. Or is there a logical reason why an object should get a new attach event after a teleport and not an on_rez event?

The best solution is probably an on_teleport event. Failing that, everything else seems about equally hacky to me. I'm happy to code using the attach instead of the on_rez, if there is any guarantee that that won't change some time in the future too :)
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
02-17-2006 11:53
And if it isn't rerezzed why does it get a new key each time?
Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
02-17-2006 13:33
Having on_rez() triggered after teleport makes perfect sense to me. When you teleport, you and your attachments do indeed de-rez from the world for a brief moment before being rezzed anew in the destination sim.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-17-2006 14:45
From: Eloise Pasteur
And if it isn't rerezzed why does it get a new key each time?
Oooh, I think that's the smoking prim there. Do we need to move all the code to reset stuff that might depend on the object key so it's called on attach as well as on_rez?
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
02-17-2006 15:14
From: Argent Stonecutter
Oooh, I think that's the smoking prim there. Do we need to move all the code to reset stuff that might depend on the object key so it's called on attach as well as on_rez?


yes. And the reason the key changes on teleport and sim crossing is because objects are serialized (converted to a flat data stream) and sent between simulators. When they get where they are going they are deserialized and assigned a new local uuid on that server.
_____________________
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-18-2006 10:39
If they get serialised (to inventory format?) and recreated from scratch on the new server, then shouldn't they get on_rez events?

What about teleports within the same sim?
Cid Jacobs
Theoretical Meteorologist
Join date: 18 Jul 2004
Posts: 4,304
02-18-2006 17:04
From: Rickard Roentgen
yes. And the reason the key changes on teleport and sim crossing is because objects are serialized (converted to a flat data stream) and sent between simulators. When they get where they are going they are deserialized and assigned a new local uuid on that server.

I don't remember objects changing keys on sim crossings :confused:
_____________________
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
02-19-2006 00:20
Same as Cid - keys change on tp, not on crossing sim borders in the virtual flesh.
Val Fardel
Registered User
Join date: 11 Oct 2005
Posts: 90
02-19-2006 20:00
LOL,

You all just realized that there is currently no way to tell the difference between an on_rez event (or an attach event) from:

1. An actual rez or attachement from inventory,
2. Login and
3. A teleport?

Sure would be nice to know how to distinguish between those three...

And, yeah, it's extremely annoying that you get new keys for attachments during a TP.
Val Fardel
Registered User
Join date: 11 Oct 2005
Posts: 90
02-19-2006 20:05
From: Rickard Roentgen
I believe attach is the correct event to use. It should fire when teleporting.

CODE

integer was_dettached = TRUE;

default
{
attach(key id)
{
if (id != NULL_KEY) {
if (was_dettached) { // Go ahead and do your attach stuff, it wasn't a teleport.
was_dettached = FALSE;

} else {
// Oops, this thing wasn't dettached, this must be a teleport.
}
} else {
was_dettached = TRUE;

// Do your dettached stuff here. Dettached isnt fired on teleport.
}
}
}


I hope you realize that the amount of CPU time your script gets on a detach event is pretty minimal and is at least partly affected by server load. There is NO guarantee that any code in a detach event will have time to execute. This got particularly worse after 1.7.
Zepp Zaftig
Unregistered Abuser
Join date: 20 Mar 2005
Posts: 470
02-19-2006 20:22
I think the best solution would be to make two new events. teleport_start and teleport_end, where teleport_start would fire on teleport and teleport_end would fire on arrival.
1 2