Don't click here unless you want to be banned.

LSL Wiki : llAvatarOnSitTarget

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are xcrawl107.alexa.com
key llAvatarOnSitTarget()

If an avatar is sitting on the sit target, this function will return the avatar's key; NULL_KEY otherwise. This will only detect avatars sitting on sit targets defined with llSitTarget. At some point prior to SL 1.6.5, it would apparently work without, but has apparently not been the case for some time. Scripts compiled prior to the change will function correctly, but recompiling them will cause them to break.

Agents that sit on the object, are linked to the object and are added to the end of the link set. See llGetNumberOfPrims for example functions.

Example:
default {
    state_entry() {
        llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
        // Note that if both the vector and the rotation are zero,
        // the SitTarget is removed instead of set and the following will not work:
    }
    
    changed(integer change) { // something changed
        if (change & CHANGED_LINK) { // and it was a link change
            llSleep(0.5); // llUnSit works better with this delay
            if (llAvatarOnSitTarget() != NULL_KEY) { // somebody is sitting on me
                llSay(0, "Get off!");
                llUnSit(llAvatarOnSitTarget()); // unsit him or her
            }
        }
    }
}

Q: It's only returning NULL_KEY! What's up with that?
A: llAvatarOnSitTarget will only work if llSitTarget has been set.


Agent/Avatar | Functions | sit | target
Comments [Hide comments/form]
As of today (1.8.4) the sit target doesn't have to be in the same script as the llAvatarOnSitTarget call, and different scripts (one with a sit target using the call, one just using the call and saying the key of the sitting avatar) correctly say the keys. This sort of makes sense to me - the sit target is a property of the prim after all, but wasn't what I was expecting really.
-- EloisePasteur (2006-03-12 05:19:34)
Apparently now (1.9.0(21))we have a new behavior as well (possibly temporary) where if you're using this in a child prim without a sit target defined, it will return the key of whomever is sitting on the parent prim (or possibly the next prim up in the linkset).
-- AislinWallaby (2006-04-09 08:31:40)
Attach a comment to this page: