Pages

Monday, May 17, 2010

Whoopie! (A quick sit detect script)

Nettrice's first question referred to detecting when an avatar has planted their big fat butt on a prim. Of course we've all seen this before with lucky chairs, as well as any poseball. Here's a quick example:

vector sitoffset=<0.0, 0.0, 0.1>; // sit position offset (x = front back, y = left right, z = updown)
default{
    state_entry(){
        llSitTarget(sitoffset, ZERO_ROTATION);
    }
    changed(integer change)
    {
        if (change & CHANGED_LINK)
        {
           
            if (llAvatarOnSitTarget() != NULL_KEY)
            {
                 llSay(0, "zomgz!!");
            }
               
        }
    }
}
You don't have to do this, but I put in a sit target function (llSitTarget) just so that I could sit on the object easier. I would probably recommend this though, I had a rough time getting my av to sit down on the prim without it ("no room to sit here, try somewhere else").  All you would have to do to change this script to make it do what you want is put all your functions where " llSay(0, "zomgz!!");" is right now, and to implement it into another script just copy and paste everything in the "changed" event.

Happy sitting!

0 comments:

Post a Comment