Page 1 of 1

Can someone with script knowledge please help me

Posted: Wed Jun 16, 2021 7:56 pm
by Kimm Starr
This script works all but the inventory animation. Does anyone know how to make the inventory animation work while avatar is climbing the stairs. Thanks!

// :SHOW:
// :CATEGORY:Animation
// :NAME:Easy Ladder
// :AUTHOR:Ferd Frederix
// :KEYWORDS:Ladder
// :CREATED:2015-07-15 10:04:12
// :ID:1081
// :NUM:1800
// :REV:2
// :WORLD:Second Life, Opensim
// :DESCRIPTION:
// Easy ladder script
// :CODE:

// Rev 2: 12-18-2015 added region pos for return

/* Climb ladder
http://community.secondlife.com/t5/Scri ... d-p/256433
Edited for opensimulator to unsit user at top via offset vector

BVH: climb-rope

Ferd Frederixz - removed cruft, added offsets and removed ugly hacks.

*/


float LADDERHEIGHT= 3.0; // how far to move up
float STEPHEIGHT = 0.25; // how far to move each step
float OFFSET = 0; // tilt of the ladder;
float Extra = 1; // extra move onto the roof or in the door before unsit

climbup()
{

llSetAlpha(0,ALL_SIDES);
llStopAnimation("sit");
llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));


integer i;
vector original;
float steps = LADDERHEIGHT / STEPHEIGHT;
float offset = OFFSET / steps; // to one side

original = llGetPos();
do
{
i++;
vector newPos = llGetPos() + <offset,0, STEPHEIGHT> * llGetRot();
llSetPos(newPos);
} while (i <= (steps));

llSetPos(llGetPos() + <Extra, 0, 0> * llGetRot()); // extra, then unsit

llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));

if (llAvatarOnSitTarget() != NULL_KEY)
{ // somebody is sitting on me
llUnSit(llAvatarOnSitTarget()); // unsit him or her
}

llSetRegionPos(original);
llSetAlpha(1,ALL_SIDES);
} // end climbup

default
{

state_entry() {
llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
}

changed(integer change)
{
if(change == CHANGED_LINK)
{
key avatar = llAvatarOnSitTarget();

if(avatar != NULL_KEY)
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
climbup();
}
}
} //end changed
} //end default

Re: Can someone with script knowledge please help me

Posted: Wed Jun 16, 2021 11:37 pm
by John Mela
I'm not able to log in and test anything at the moment.

However, it looks like the script is requesting permission to animate, but not waiting until permission is granted before starting the animation. One of those things you might be able to get away with sometimes, but it's certainly not recommended. The SL Wiki says:
Regardless of whether granting is automatic, you should always use the run_time_permissions event. Granting permissions takes time, and you shouldn't assume it's completed until the run_time_permissions handler gets invoked
Try this and see if it works (again, this isn't tested code):

Code: Select all


// :SHOW:
// :CATEGORY:Animation
// :NAME:Easy Ladder
// :AUTHOR:Ferd Frederix
// :KEYWORDS:Ladder
// :CREATED:2015-07-15 10:04:12
// :ID:1081
// :NUM:1800
// :REV:2
// :WORLD:Second Life, Opensim
// :DESCRIPTION:
// Easy ladder script
// :CODE:

// Rev 2: 12-18-2015 added region pos for return

/* Climb ladder
http://community.secondlife.com/t5/Scri ... d-p/256433
Edited for opensimulator to unsit user at top via offset vector

BVH: climb-rope

Ferd Frederixz - removed cruft, added offsets and removed ugly hacks.

*/


float LADDERHEIGHT= 3.0; // how far to move up
float STEPHEIGHT = 0.25; // how far to move each step
float OFFSET = 0; // tilt of the ladder;
float Extra = 1; // extra move onto the roof or in the door before unsit

climbup()
{

	llSetAlpha(0,ALL_SIDES);
	llStopAnimation("sit");
	llStartAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));


	integer i;
	vector original;
	float steps = LADDERHEIGHT / STEPHEIGHT;
	float offset = OFFSET / steps; // to one side

	original = llGetPos();
	do
	{
		i++;
		vector newPos = llGetPos() + <offset,0, STEPHEIGHT> * llGetRot();
		llSetPos(newPos);
	} while (i <= (steps));

	llSetPos(llGetPos() + <Extra, 0, 0> * llGetRot()); // extra, then unsit

	llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION,0));

	if (llAvatarOnSitTarget() != NULL_KEY)
	{ // somebody is sitting on me
		llUnSit(llAvatarOnSitTarget()); // unsit him or her
	}

	llSetRegionPos(original);
	llSetAlpha(1,ALL_SIDES);
} // end climbup

default
{

	state_entry() {
		llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
	}

	changed(integer change)
	{
		if(change == CHANGED_LINK)
		{
			key avatar = llAvatarOnSitTarget();

			if(avatar != NULL_KEY)
			{
				llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
			}
		}
	}
	run_time_permissions(integer permissions)
	{
		if (permissions & PERMISSION_TRIGGER_ANIMATION)
		{
			climbup();
		}
	}
} //end default

Re: Can someone with script knowledge please help me

Posted: Sun Jun 20, 2021 1:12 pm
by Min Tigerpaw
Hi Kim,
I checked the script with the "climb-rope" animation from here:

https://www.outworldz.com/lib/Easy%20La ... b-rope.bvh

This worked for me in the Kitely Merchants Sandbox without problem.
Of cause you need to add the animation to the ladder-object containg the script ;)
Only slight issue I have with the script is, that you first take the sit-pose before you start climbing up.
Cheers
Min

Re: Can someone with script knowledge please help me

Posted: Mon Jun 21, 2021 11:23 am
by Kimm Starr
Thanks so much for your help, both of you. It works!