Pages

Showing posts with label changed. Show all posts
Showing posts with label changed. Show all posts

Friday, May 21, 2010

Hot Topics (Part 1)

Ok so I've helped several people with several questions pertaining to several things. None of which were answered on the blog so I figure I'll pick and choose and write a post about a few things I've helped with here and there. This one will be a quickie.

Shila was working on a script that reads a notecard, and she wanted to know how to reset the script whenever the notecard is edited and saved. The code for this is pretty quick and simple. All you have to do is add the "changed" event to your code.

changed(integer change){
    if ( change & CHANGED_INVENTORY){
        llResetScript();
    }
    }

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!