Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Easy Sit Target Positioner

Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
12-06-2006 16:26
These two scripts let you very easily set sit target positions and rotations. You sit on a poseball, position yourself exactly where you want to be, and the sit target is calculated automatically for you.

This is an idea I had months ago, but I gave up because llSitTarget has a bug which makes exact calculation of target positions difficult. Thanks to the folks over at this thread and a little more detective work, we managed to come up with a way to work around the bug, and so I've produced the following scripts.

I'll be distributing this in-world via my store (for free), or you can construct it from the scripts below. Here's the instruction notecard:

From: someone

This system helps you easily calculate and set a sit target for any prim.

Written by Lex Neva. Please distribute willy-nilly.

Instructions:

1. Place the "sit target setter" script into a prim that will get the sit target.
2. Rez the Sit Target Helper.
3. Sit on the Sit Target Helper.
4. Move the Sit Target Helper so that you are positioned exactly where you want the sit target to be.
5. Click the prim you put the "sit target setter" script in.
6. Now the sit target is set. You can use the code the script outputs in a poseball script. Once the
sit target is set, you can remove the "sit target setter" script.

NOTE: To use a sit animation, place one copy in the helper and one copy in the base object. If the animation is no-copy, place the animation in the helper first while you position yourself, and then move it over to the base after you click it. Only the first animation in the inventory will be used.


MORE HELP: This is a completely free, open-source system. As such, I am not available to support it. Please feel free to ask for help on the forums.


Here's the "sit target setter" script:

CODE

// Sit target system by Lex Neva. Please distribute willy-nilly.

default
{
touch_start(integer total_number) {
llSensor("Sit Target Helper", NULL_KEY, ACTIVE|PASSIVE, 96, PI);
llSay(0, "Searching for Sit Target Helper...");
}

no_sensor() {
llSay(0, "Sit Target Helper not found. No sit target set.");
llSitTarget(ZERO_VECTOR, ZERO_ROTATION);
}

sensor(integer num) {
if (num > 1) {
llSay(0, "Multiple Sit Target Helpers found. Using closest helper.");
} else {
llSay(0, "Sit Target Helper found. Setting sit target.");
}

vector helper_pos = llDetectedPos(0);
rotation helper_rot = llDetectedRot(0);

vector my_pos = llGetPos();
rotation my_rot = llGetRot();

// calculate where the avatar actually is
vector avatar_pos = helper_pos + <0,0,1> * helper_rot; // due to helper's sit target
avatar_pos = avatar_pos - <0,0,0.186> + <0,0,0.4> * helper_rot; // correct for a bug in llSitTarget(), for helper sit target

vector target_pos = (avatar_pos - my_pos) / my_rot;
target_pos = target_pos + <0,0,0.186>/my_rot - <0,0,0.4>; // correct for the bug again, this time in my sit target
rotation target_rot = helper_rot / my_rot;

llSitTarget(target_pos, target_rot);
llSay(0, "llSitTarget(" + (string)target_pos + ", " + (string)target_rot + ");");
}

changed(integer change) {
if (llAvatarOnSitTarget() != NULL_KEY)
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perm) {
string anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
if (anim != "") {
llStopAnimation("sit");
llStopAnimation("sit_generic");
llStopAnimation("sit_female");
llStartAnimation(anim);
}
}
}


And this script goes into a ball named "Sit Target Helper" (make sure you get that name right):

CODE

default
{
state_entry()
{
llSitTarget(<0,0,1>, ZERO_ROTATION);
}

changed(integer change) {
if (llAvatarOnSitTarget() != NULL_KEY)
llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perm) {
string anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
if (anim != "") {
llStopAnimation("sit");
llStopAnimation("sit_generic");
llStopAnimation("sit_female");
llStartAnimation(anim);
}
}
}


Enjoy!
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
12-09-2006 18:30
/54/6a/153963/1.html
_____________________
i've got nothing. ;)
Silje Russell
lsl geek
Join date: 2 Oct 2005
Posts: 63
12-11-2006 18:11
sweet :D
_____________________
Yes i know i got typos..
I got writing and reading problems.
but i am still a humen!!
Lolita Pro
www.PhotosByLolita.com
Join date: 30 Oct 2006
Posts: 273
04-08-2007 17:04
I never could find this in your stores ... but thanks for posting the scripts. I'm working on building it now.