I started with this:
CODE
// Open Pose Ball
// from Dolyn Foley
// Feel free to ask me about this code
// Please pass it on, a la GPL
list gAnimations = ["express_open_mouth" ];
restartAnimations()
{
integer i ;
integer max = llGetListLength(gAnimations) ;
string ani ;
for (i=0;i<max;i++)
{
ani = llList2String(gAnimations, i) ;
llStopAnimation(ani) ;
llStartAnimation(ani) ;
}
}
string sitAnimation = "";
// if sitAnimation is left blank
// the script will grab the first animation in the container.
// if a value is set, it will use that instead.
//string sitAnimation = "yoga_float";
default {
on_rez(integer start_param) {
llResetScript();
}
state_entry() {
llSetText("Sit to Pose", <0.0,1.0,0.0>, 1);
llSitTarget( <0,0,0.75>, ZERO_ROTATION );
// if blank, we look in inventory
if (sitAnimation == "") {
sitAnimation = llGetInventoryName(INVENTORY_ANIMATION, 0);
// oops, use default
if (sitAnimation == "") {
sitAnimation = "sit";
}
}
}
// Using state to control sitting
// If you're in this state, no one is sitting
changed(integer change) {
if (change & CHANGED_LINK) {
key avatar = llAvatarOnSitTarget();
if ( avatar != NULL_KEY ) {
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
llSetTimerEvent(0.5) ;
}
}
}
run_time_permissions(integer parm) {
if(parm == PERMISSION_TRIGGER_ANIMATION) {
llStopAnimation("sit");
llStartAnimation(sitAnimation);
state sitting;
}
}
}
state sitting {
state_entry() { //intentionally left blank
}
touch_start(integer total_number) {
}
// Assume sitting, thus any CHANGED_LINK means standing.
changed(integer change) {
if (change & CHANGED_LINK) {
llStopAnimation(sitAnimation);
llSetTimerEvent(0);
llResetScript();
}
}
timer()
{
restartAnimations() ;
}
}
But the trouble with that was that, while it worked fine when I was the only person on the pose ball, but when someone got onto the other ball in the linkset to join me, it fired off " if (change & CHANGED_LINK)" and stopped the timer that was keeping my mouth open.
So.. I tried this:
CODE
string sitAnimation = "";which not only keeps the facial expression going when my tormentor gets on his pose ball, which is what I want, but also keeps it going until he gets off and (p = llGetNumberOfPrims()) again . That's not the end of the world, but it would be nice to stop my facial expression when my animation stops, too.
string sittext = "Floggee";
list gAnimations = ["express_open_mouth" ];
integer p;
restartAnimations()
{
integer i ;
integer max = llGetListLength(gAnimations) ;
string ani ;
for (i=0;i<max;i++)
{
ani = llList2String(gAnimations, i) ;
llStopAnimation(ani) ;
llStartAnimation(ani) ;
}
}
default {
on_rez(integer start_param) {
llResetScript();
p = llGetNumberOfPrims();
}
state_entry() {
llSetText(sittext, <0.0,1.0,0.0>, 1);
llSitTarget( <0,0,0.75>, ZERO_ROTATION );
llSetTimerEvent(0.5);
// if blank, we look in inventory
if (sitAnimation == "") {
sitAnimation = llGetInventoryName(INVENTORY_ANIMATION, 0);
// oops, use default
if (sitAnimation == "") {
sitAnimation = "stand";
}
}
}
changed(integer change) {
if (change & CHANGED_LINK) {
key avatar = llAvatarOnSitTarget();
if ( avatar != NULL_KEY ) {
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
}
}
run_time_permissions(integer parm) {
if(parm == PERMISSION_TRIGGER_ANIMATION) {
llStopAnimation("sit");
llStartAnimation(sitAnimation);
state sitting;
}
}
}
state sitting {//intentionally blank
state_entry() {
}
touch_start(integer total_number) {
}
// Assume sitting, thus any CHANGED_LINK means standing.
changed(integer change) {
if (change & CHANGED_LINK) {
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
{ llStopAnimation(sitAnimation);
if (p = llGetNumberOfPrims()) //bad- should be if (p == llGetNumberOfPrims())
llResetScript();}
}
}
timer()
{
restartAnimations() ;
}
}
Any suggestions? I'm sure there's a solution, but I can't quite see how to approach it.
Update.. I spotted an error in the code.. if (p = llGetNumberOfPrims()) -- I've fixed that to if (p == llGetNumberOfPrims()) and made a couple of other adjustments which I will post when next I am in world, but it still ain't working properly.