Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Pose/Anim Script Cycler - Keyboard Key to Change Pose

Lucrezia Lamont
Neko Onmyoji
Join date: 25 Jan 2007
Posts: 808
07-12-2007 22:13
Hello, all. I've scoured the forums for the past hour and I'm either blind (more than likely) or it's not been posted yet, but...

I'm looking for the script that will cycle through a number of poses/animations in a prim (i.e. a chair) by pressing the <Page Up> and <Page Down> keys.

It's got to be simple -- so simple I can't see the forest through the trees.

Any assistance would be greatly appreciated. Thanks kindly.

Cheers.
_____________________
Ronin Neko Onmyoji
Jole Greenberg
Registered User
Join date: 29 Dec 2006
Posts: 8
06-23-2008 02:51
Hi @ all!

That would be really interesting. Does someone maybe has a script doing this to place in the forum here?

Thx and cya out there.
Jole
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
06-23-2008 02:54
I have one for sale In World... but that wasn't the question?
_____________________
From Studio Dora
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
06-23-2008 07:27
None of the following is remotely helpful, but...

A basic version of this isn't a very difficult script. It's pretty much a poseball script engaging in unnatural acts with llTakeControls(). To do it right, though, for arbitrary animations, one might support different positions and rotations per animation, to compensate for different offsets in the anims. One could even get clever (I've seen this somewhere) and let the agent slide their avatar around to "fit" and then remember where they ended up for a particular animation, so as to position them there the next time they sit.

I've done the basic version of this a couple of places. It always feels a little weird, though, having the script take controls just because the avatar sat on a chair (as opposed to a vehicle, say). And I'm never quite sure which controls I want to use for this. Mine cycle through a sequence of anims using the "strafing" arrow keys, some use PgUp/PgDn to do the same thing, and some just assign a different animation to each of the arrow keys. One problem with using those arrow key controls is that some folks actually use those to control their cam while seated, so it's not obvious whether to just override that or try to mix it in with the animation control.

If there could be some convention on which keys to use for what here, my chairs wouldn't have to IM their occupants about how to properly sit on them.
_____________________
Archived for Your Protection
Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
06-23-2008 08:24
This script is in a freebie provided by Yadni from his Junk Yard and since Yadni is very careful about only using Open Source I trust it as being okay to give to people.

It uses Shift + arrow keys (right and left) to cycle thru anims. I'm not a scriptor so I don't know if it is a well written script or not but I do know that Seagle Neville has a good reputation.






// Created by Seagle Neville

vector sit_pos = <-1, 0, -0.5>;
vector sit_rot = <0, -90, 0>;

string DISPLAY_TEXT = "";
string ANIMATION;
integer is_sitting = FALSE;
integer anim_num;
integer fire_anim_num;

list SIT_ANIMATIONS = [];

RANDOM_SELECT_ANIMATION()
{
anim_num = llGetInventoryNumber(INVENTORY_ANIMATION) - 1; // Count from 0
fire_anim_num = llRound(llFrand(anim_num));
}

SIT_ANIMATION()
{
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, fire_anim_num);
}

default
{
state_entry()
{
is_sitting = 0;
llSitTarget(sit_pos, llEuler2Rot(sit_rot*DEG_TO_RAD));
llSetText(DISPLAY_TEXT,<1,1,1>,1);
}
on_rez(integer start_param)
{
llResetScript();
}
changed(integer change)
{
if(change & CHANGED_LINK)
{
key av = llAvatarOnSitTarget();
RANDOM_SELECT_ANIMATION();
if(av != NULL_KEY)
{
llRequestPermissions(av, (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS));
}
else
{
if((llGetPermissions() & (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS)) && is_sitting)
{
is_sitting = 0;
llStopAnimation(ANIMATION);
llSetText(DISPLAY_TEXT,<1,1,1>,1);
llReleaseControls();
}
}
}
SIT_ANIMATION();
}
run_time_permissions(integer perm)
{
if(perm & (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS))
{
llTakeControls(CONTROL_RIGHT | CONTROL_LEFT, TRUE, FALSE);
is_sitting = TRUE;
llStopAnimation("sit_generic";);
llStopAnimation("sit";);
llStartAnimation(ANIMATION);
llSetText("",<1,1,1>,1);
}
}
control(key id, integer level, integer edge)
{
// llOwnerSay("fire_anim_num is " + (string)fire_anim_num); //Debug
// llOwnerSay("anim_num is " + (string)anim_num); //Debug
if(level & CONTROL_RIGHT)
{
llSleep(0.1);
fire_anim_num = fire_anim_num + 1;
if(fire_anim_num > anim_num)
{
fire_anim_num = 0;
}
llStopAnimation(ANIMATION);
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, fire_anim_num);
llStartAnimation(ANIMATION);
}
if(level & CONTROL_LEFT)
{
llSleep(0.1);
fire_anim_num = fire_anim_num - 1;
if(fire_anim_num < 0)
{
fire_anim_num = anim_num;
}
llStopAnimation(ANIMATION);
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, fire_anim_num);
llStartAnimation(ANIMATION);
}
}
}
Dekka Raymaker
thinking very hard
Join date: 4 Feb 2007
Posts: 3,898
06-23-2008 08:26
the freebie prim sitter does this I thought:

/54/a8/202339/1.html
_____________________