Change font size
It is currently Sun Mar 18, 2018 6:14 am

Forum rules


Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: sit scripts
PostPosted: Sun Mar 09, 2008 3:00 am 
Site Admin
User avatar

Joined: Sat Feb 02, 2008 6:15 pm
Posts: 4
Location: The Woods Of Oregon
I just added sit scripts to the 4 sculpty chairs, at the computer terminals, in the Wright Plaza building. CKrinke asked me to share the sit script and explain its operation. I'll do my best.

Here's the script:

vector rot=<180.0, -90.0, 0.0>*DEG_TO_RAD;
rotation finalrot=llEuler2Rot(rot);
llSitTarget(<0.5, 0.0, 0.5>,finalrot);

I'll give an overview of what the script is designed to do. Then, I'll explain line by line.

The script is designed to be dropped into a prim chair. If you're using a multiple-prim chair, drop the script into the root prim. The script sets a prim property called the SIT TARGET. The SIT TARGET is the spot where your avatar's butt will attach to the prim. Interestingly, the SIT TARGET, once set, becomes a permanent property of a prim. If you delete the script which was used to set the target, the target remains in the prim.

The SIT TARGET consists of two sets of values: position values and rotation values. You control where an avatar sits on your chair and how the avatar is rotated while sitting on the chair. These values are relative to the position and rotation of the prim in which the script is dropped; if you move or rotate your chair, the SIT TARGET still works properly.

Setting the SIT TARGET requires a bit of trial and error. You SIT on the chair, note the position and rotation in which you sat, STAND UP, tweak the values in the script, resave the script, and SIT again.

Now, I'll go over the script line by line.

The default and state_entry() lines are just boilerplate code, required by all scripts.

The action starts with the llSay() line. The llSay() line is not required for the script to function. However, I prefer to include an llSay() line in the state_entry() block of all my scripts. The llSay() line prints a message on the client chat line when the script starts or resets. It gives an indication that your script is alive and working.

The "vector rot=" line contains rotation values (in degrees) for our SIT TARGET, in the < > brackets. This controls how an avatar will be rotated when sitting on our chair. We assign three values: for the X, Y and Z components of the avatar's rotation. When I'm attempting to set rotation values for a SIT TARGET, I always start with all three values at zero and set one axis at a time. Get the X axis correct, then work on the Y axis, then the Z axis. You'll have to set a value, SIT, note the rotation of your sitting avatar, STAND UP, tweak the value, resave the script, and SIT again.

When tweaking values for rotation, use increments of 90 degrees. Try 0, then 90, then 180, then 270. Negative versions of these values work, also. You'll notice in the example script, I ended up with values of <180.0, -90.0, 0.0>.

The next line, with the "rotation finalrot=llEuler2Rot(rot)" statement, is required to convert our sane rotational values into the infernal, arcane format which Second Life prefers, internally. Don't stare directly at it. Look away.

The last line, with "llSitTarget", assigns position values (in the < > brackets) and our converted rotation values to the SIT TARGET. The position values are X, Y and Z positions relative to the root prim of our chair. As an example, position values of <0,0,0> should cause the avatar to sit in the center of the root prim. I say "should" because position values of <0,0,0> don't actually do what you would expect. A position value of <0,0,0> will cause the SIT TARGET to break and not work at all. Always use a non-zero position value. Even <0,0,.1> will work. Never leave all three values at 0.

Setting the position values will require trial and error, just like setting the rotation values. SIT, look, STAND UP, tweak values, resave, SIT again. Try using increments of .1, like .1, .2, .3. Very small changes in the position values will have a noticeable effect.

That's all there is to it. Play with the values until your avatar is sitting where you want.

Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]

Who is online

Users browsing this forum: No registered users and 5 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of