key llGetOwner()
Returns the
key of the
owner of the
scripted object.
Note: a script will only check to see its owner when
llGetOwner is called. This can be annoying if you transfer ownership of the object to another
user. If you're using
llGetOwner in
llListen or
llRequestPermissions, consider putting
llResetScript in the
on_rez event, or even
llListen in on_rez. Remember to remove your old
listens with
llListenRemove or they'll pile up! Depending on what you have in
state_entry,
llResetScript is usually the best method.
Is your script listening to or animating the object's old owner? It may seem like
llGetOwner is broken, but this is not the case. Functions like
llListen and
llRequestPermissions remember the key that you passed to them and continue to act on that person even if ownership of the object changes. If you set up a
llListen to listen for the owner of an object, the script will continue to listen to that specific person after ownership is changed. If you
llRequestPermissions to animate the owner of an object and ownership changes,
llStartAnimation will continue to animate the old owner of the object. If calling
llResetScript in the
on_rez event is unfeasible, consider checking the
CHANGED_OWNER in the
changed event to detect a change in ownership, and reinitialize
llListens and call
llRequestPermissions on the new owner as needed.
You can retrieve the owner of a specific object other than the one containing the script with
llGetOwnerKey.
Examples:
default
{
touch_start(integer num_detected)
{
if (llDetectedOwner(0) == llGetOwner())
{
llOwnerSay("Greetings!");
}
}
}
default {
state_entry() {
llListen(0, "", llGetOwner(), ""); // listen to my owner
}
listen(integer channel, string name, key id, string message) {
llSay(0, name + " said: " + message); // repeat owner's text
}
on_rez(integer start_param) {
// every time we're rezzed, reset the script
// this ensures that if we're transferred to a new owner, we're listening to them and not still to the previous one
llResetScript();
}
}
Q: What happens if I call llGetOwner() in an object owned by a group (deeded)?
A: The group's UUID will be returned.
Q: How do I get the owner's name instead?
A: If the owner is in the same sim as the object at the time it's called, (IE, if your script is within an attachment) use llKey2Name. Otherwise, you need to use llRequestAgentData and the dataserver event, which takes longer and is more complicated.
Q: Does llGetOwner work correctly in a child prim? I'm getting NULL returned when I try to call it.
A: Yes. The problem lies elsewhere in your code.
This article wasn't helpful for you? Maybe the
related article at the LSL Portal is able to bring enlightenment.
Functions |
Keys