Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multi Sit Script - Anxiousness Chair v.1

Tifosa Twang
Registered User
Join date: 26 Mar 2006
Posts: 25
07-14-2007 08:43
Hi there,

I am trying to find a script that can use animations in furniture without pose balls. I came across an older script called "Multi Sit Script - Anxiousness Chair v.1." Unfortunately, once I input the script into the cushion of the chair and link the prims, I get an error message when I sit down. The error reads "Object: Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set" I searched the forums and found 1 thread about it from '04, but can't figure out how to solve for this error. Can anyone help? I'm fairly new to scripting, so appreciate any dumbed down explanations/solutions :) Thanks in advance!

Below is the script.

//Anxiousness Chair v.1
//By: Kaneda Akenbono
//Enjoy, and I'd appreciate it if you left this on the script. :)
//
//Add the animations you want to your object.
//I pulled the stuff below into globals so you can easily modify this script without understanding any of the code. :)

vector Angle = <0,0,270>; //Enter a vector rotation for the sit...
vector SitLoc = <0.08,0,.45>; //This is the sitTarget positioning... CANNOT EQUAL 0
string LoadText = "I'm exhaused"; // The text you want to show when the object loads...
string Context = "sit"; //The text you want in the context menu...

//Globals!! WOOO!!
key user;
list animations;
integer animNum;
integer nextAnim = 1;
integer curAnim = 0;

//This part dynamically gathers all of the animations you've placed in the object for usage later...
initialize()
{
integer x;
list oldAnim;
animNum = llGetInventoryNumber(INVENTORY_ANIMATION);
for (x = 0; x < animNum; x++)
{
animations = oldAnim + [x];
oldAnim = animations;
}
}

default
{
state_entry()
{
initialize();
//For easy rotation in the llSitTarger enter the vector rotation below..
vector eul = Angle; //45 degrees around the z-axis, in Euler form..
eul *= DEG_TO_RAD; //convert to radians...
rotation quat = llEuler2Rot( eul ); //convert to quaternion...
llSay(0, LoadText);
//Text it says under the context menu...
llSetSitText(Context);
//Adjust the positioning of the user while siting... also need for llAvatarOnSit... if this value is equal to 0, it doesn't work, so set it to make it look right for your object
llSitTarget(SitLoc, quat);
}
touch_start(integer num_detected)
{
if (user = llAvatarOnSitTarget())
{
if (animNum > 1)
{
llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, curAnim));
llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, nextAnim));
curAnim = nextAnim;
if (nextAnim < (animNum - 1))
{
nextAnim++;
}
else
{
nextAnim = 0;
}
}
}
}
changed(integer change)
{
//If the user sits on the object...
if (change & CHANGED_LINK)
{
user = llAvatarOnSitTarget();
if (user)
{
llRequestPermissions(user, PERMISSION_TRIGGER_ANIMATION);
}
else
{
llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
llMessageLinked(LINK_SET, FALSE, "ChangeDisplay", NULL_KEY);
}
}
}
run_time_permissions(integer perm)
{
if (perm)
{
//This starts the first animation...
llStopAnimation("sit";);
llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
llSleep(1);
llMessageLinked(LINK_SET, TRUE, "ChangeDisplay", NULL_KEY);
curAnim = 0;
}
}
}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-14-2007 08:53
Well, buried in the changed() event, there's a line:
From: someone

llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
which will get called when you link the items together (or unlink them). It should work to just protect that statement inside a conditional, something like

From: someone
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));


[edit: well, kinda. Now that I re-read the title of the post, I realize this script intends to cycle through a bunch of animations, and yet the script only tries to stop the 0th one in inventory, regardless of which one it's gotten 'round to pushing on the avatar at the time s/he stands up. So while the "fix" should get around the error message when linking the prims, the script should really be changed to call llStopAnimation on whatever animation it was playing at the time. There may be other problems, too, just haven't looked that closely.]
Tifosa Twang
Registered User
Join date: 26 Mar 2006
Posts: 25
07-14-2007 09:05
Thanks Qie!

So all I have to do is replace the statement:

llStopAnimation(llGetInventoryName(INVENTORY_ANIMA TION, 0));

with

if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
llStopAnimation(llGetInventoryName(INVENTORY_ANIMA TION, 0));

And, the revised script would be (please correct me if I'm wrong, new to this):

//Anxiousness Chair v.1
//By: Kaneda Akenbono
//Enjoy, and I'd appreciate it if you left this on the script.
//
//Add the animations you want to your object.
//I pulled the stuff below into globals so you can easily modify this script without understanding any of the code.

vector Angle = <0,0,270>; //Enter a vector rotation for the sit...
vector SitLoc = <0.08,0,.45>; //This is the sitTarget positioning... CANNOT EQUAL 0
string LoadText = "I'm exhaused"; // The text you want to show when the object loads...
string Context = "sit"; //The text you want in the context menu...

//Globals!! WOOO!!
key user;
list animations;
integer animNum;
integer nextAnim = 1;
integer curAnim = 0;

//This part dynamically gathers all of the animations you've placed in the object for usage later...
initialize()
{
integer x;
list oldAnim;
animNum = llGetInventoryNumber(INVENTORY_ANIMATION);
for (x = 0; x < animNum; x++)
{
animations = oldAnim + [x];
oldAnim = animations;
}
}

default
{
state_entry()
{
initialize();
//For easy rotation in the llSitTarger enter the vector rotation below..
vector eul = Angle; //45 degrees around the z-axis, in Euler form..
eul *= DEG_TO_RAD; //convert to radians...
rotation quat = llEuler2Rot( eul ); //convert to quaternion...
llSay(0, LoadText);
//Text it says under the context menu...
llSetSitText(Context);
//Adjust the positioning of the user while siting... also need for llAvatarOnSit... if this value is equal to 0, it doesn't work, so set it to make it look right for your object
llSitTarget(SitLoc, quat);
}
touch_start(integer num_detected)
{
if (user = llAvatarOnSitTarget())
{
if (animNum > 1)
{
llStopAnimation(llGetInventoryName(INVENTORY_ANIMA TION, curAnim));
llStartAnimation(llGetInventoryName(INVENTORY_ANIM ATION, nextAnim));
curAnim = nextAnim;
if (nextAnim < (animNum - 1))
{
nextAnim++;
}
else
{
nextAnim = 0;
}
}
}
}
changed(integer change)
{
//If the user sits on the object...
if (change & CHANGED_LINK)
{
user = llAvatarOnSitTarget();
if (user)
{
llRequestPermissions(user, PERMISSION_TRIGGER_ANIMATION);
}
else
{
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
llStopAnimation(llGetInventoryName(INVENTORY_ANIMA TION, 0));
llMessageLinked(LINK_SET, FALSE, "ChangeDisplay", NULL_KEY);
}
}
}
run_time_permissions(integer perm)
{
if (perm)
{
//This starts the first animation...
llStopAnimation("sit";);
llStartAnimation(llGetInventoryName(INVENTORY_ANIM ATION, 0));
llSleep(1);
llMessageLinked(LINK_SET, TRUE, "ChangeDisplay", NULL_KEY);
curAnim = 0;
}
}
}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
07-14-2007 11:27
I can't get in-world to test it all just now, but that should work... except that, as I mumbled in the "edit" thing, it would be a little more functional if, instead 0, it used curAnim, otherwise the avatar will be stuck in the wrong animation when they try to stand up after the chair has moved past the 0th animation... so, the changed event handler section would look something like this:
CODE

changed(integer change)
{
//If the user sits on the object...
if (change & CHANGED_LINK)
{
user = llAvatarOnSitTarget();
if (user)
{
llRequestPermissions(user, PERMISSION_TRIGGER_ANIMATION);
}
else
{
if (llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, curAnim));
llMessageLinked(LINK_SET, FALSE, "ChangeDisplay", NULL_KEY);
}
}
}

(The forum text formatting seems intent on sticking a space in the middle of words, a la "ANIMA TION" which will probably have to be edited out.)
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
09-24-2007 11:21
This script also allows anyone clicking on it to change your pose, if you do not wish this, you can change the line:

if (user = llAvatarOnSitTarget())

to read this way:

if (llDetectedKey(0) == llAvatarOnSitTarget())

This tests who clicked against who is sitting on the prim.

(on a side note, that code "if (user = llAvatarOnSitTarget())" assigns the key to user and then tests the result of llAvatarOnSitTarget() for not being NULL_KEY. This assignment is a side effect which coulld cause bugs later, the writer may have meant to use == instead of = to test the one value against the other, instead of testing for NULL_KEY.)
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
09-24-2007 11:23
From: Qie Niangao
<snip>
(The forum text formatting seems intent on sticking a space in the middle of words, a la "ANIMA TION" which will probably have to be edited out.)

Qie you can prevent that by putting some spaces in the line, it's the word wrap code which is forcing the space because it sees one long word, e.g:

llStopAnimation(llGetInventoryName(INVENTORY_ANIMA TION, curAnim));

becomes

llStopAnimation( llGetInventoryName( INVENTORY_ANIMATION, curAnim ) );