Can someone with script knowledge please help me

Creating scripts
Post Reply
User avatar
Kimm Starr
Posts: 214
Joined: Wed Jan 30, 2019 7:59 pm
Has thanked: 307 times
Been thanked: 388 times

Can someone with script knowledge please help me

Post 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
These users thanked the author Kimm Starr for the post:
Ilan Tochner
I'm obsessed with Animesh and soon you will be too!
User avatar
John Mela
Posts: 91
Joined: Tue Feb 04, 2014 9:50 pm
Has thanked: 139 times
Been thanked: 127 times
Contact:

Re: Can someone with script knowledge please help me

Post 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
These users thanked the author John Mela for the post (total 4):
Ilan TochnerKim McCabeRamesh RamlollShandon Loring
User avatar
Min Tigerpaw
Posts: 223
Joined: Sun Mar 24, 2013 3:52 pm
Has thanked: 332 times
Been thanked: 160 times

Re: Can someone with script knowledge please help me

Post 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
These users thanked the author Min Tigerpaw for the post (total 2):
Ilan TochnerJohn Mela
User avatar
Kimm Starr
Posts: 214
Joined: Wed Jan 30, 2019 7:59 pm
Has thanked: 307 times
Been thanked: 388 times

Re: Can someone with script knowledge please help me

Post by Kimm Starr »

Thanks so much for your help, both of you. It works!
These users thanked the author Kimm Starr for the post (total 2):
John MelaMin Tigerpaw
I'm obsessed with Animesh and soon you will be too!
Post Reply