I'm currently working on a script that allows an avatar to sit on an object, which carries this script. Once the avatar sits on it, it should run an animation and rez a permanently rotating object at a certain height (about the height of sitting avatar's hips).
Here is what i got so far:
//lsl
vector position = <0, 0, .7>; // Adjust position here
integer visible = TRUE;
string animation;
show()
{
visible = TRUE;
llSetAlpha(1, ALL_SIDES);
}
hide()
{
visible = FALSE;
llSetAlpha(0, ALL_SIDES);
}
default
{
on_rez(integer start)
{
llResetScript();
}
state_entry()
{
llSitTarget(position, ZERO_ROTATION);
animation = llGetInventoryName(INVENTORY_ANIMATION, 0);
}
changed(integer change)
{
if(change == CHANGED_LINK) {
key avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY)
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
else if (llGetPermissionsKey() != NULL_KEY)
{
llStopAnimation(animation);
llWhisper(1111,"quit"
;show();
}
}
}
run_time_permissions(integer perm) {
if(perm == PERMISSION_TRIGGER_ANIMATION) {
llRezObject("spinning object", llGetPos() + <0, 0, 1.5>, ZERO_VECTOR, ZERO_ROTATION, 42);
llStopAnimation("sit"
;llStartAnimation(animation);
//missing code to rez spinning object at height of current avatar's hips at certain rotation, no matter what rotation this object (which holds scripts and animation) has.
hide();
}
}
}
//end lsl
This script animates the avatar, using the animation which is in this prim's inventory. Now I was trying to solve the rotation and "rez at certain height problem". I tried to get avatar's size and devide it by 2. This way I thought it was possible to detect the hips, as they are about in the middle of the avatar. Anyway, using llGetAgentSize didnt return a usable value (returned <0,0,0>
since I used the LSL-WIKI example: vector size = llGetAgentSize(llDetectedKey(0));The way my script is done I couldn't think of a way to get the avatar's key.
I guess my way to solve this is much too complicated. Got a certain feeling, there must be an easier way...
Any suggestions welcome!
Thanks in advance.