Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Linking Prims with Scripts

Phelan Corrimal
Registered User
Join date: 2 Jul 2006
Posts: 15
10-28-2006 17:50
I'm trying to figure out the best way to store an object. In this case its a couch containing about 6 prims for the base and 6 prims for each of the seating cushions. Each cushion has a pose and a script for controlling the pose as part of it rather than using pose balls. So now that it is all ready --- how do I store this as one object?

If I link them all together then the scripts start complaining. I think this has something to do with a base script between set for all prims as part of the collection. However I want each script to operate independently.

Is there something around that explains how to do this? I've seen other couches, fountains, hot tubs, etc. that rez as a complete set with each of the scripts working just fine without having to link / delink / or fiddle with the set-up, so I assume this is possible.

Pc
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
10-28-2006 21:04
From: Phelan Corrimal
If I link them all together then the scripts start complaining. I think this has something to do with a base script between set for all prims as part of the collection. However I want each script to operate independently.

It's possible the script(s) you're using don't do proper checks and get confused whenever someone sits on any of the prims... try maybe this one, instead:

(place copy in each prim which is supposed to be sitting spot. The values in first two lines can be adjusted to position the AV properly. the script will automatically play first animation placed in the same prim, or default sit animation if there's none)
CODE

vector sit_offset = <0.0, 0.0, 0.5>;
rotation sit_angle = ZERO_ROTATION;

// do not change anything below this point unless you know what you're doing ^^;
key attached_agent = NULL_KEY;

play_pose( string Pose ) {

if( attached_agent == NULL_KEY ) return;

if( !( llGetPermissions() & PERMISSION_TRIGGER_ANIMATION ) ) { return; }

list current_animations = llGetAnimationList( attached_agent );
integer i;
for( i = 0; i < llGetListLength(current_animations); ++i ) llStopAnimation( llList2Key( current_animations, i ) );

llStartAnimation( Pose );
}

default {

state_entry() { llSitTarget( sit_offset, sit_angle ); }

on_rez( integer Parameter ) { llResetScript(); }

changed( integer Change ) {

if( Change & CHANGED_LINK ) {

key new_agent = llAvatarOnSitTarget();

if( (attached_agent == NULL_KEY) && (new_agent != NULL_KEY) ) {
// there's new user on the stand
llRequestPermissions( new_agent, PERMISSION_TRIGGER_ANIMATION );
}
else if( (attached_agent != NULL_KEY) && (new_agent == NULL_KEY) ) {
// current user left
if( llGetPermissions() & PERMISSION_TRIGGER_ANIMATION ) { play_pose( "stand" ); }
}

attached_agent = new_agent;
}
}

run_time_permissions( integer Permissions ) {

if( Permissions & PERMISSION_TRIGGER_ANIMATION ) {

string pose = "sit";
if( llGetInventoryNumber( INVENTORY_ANIMATION ) ) { pose = llGetInventoryName( INVENTORY_ANIMATION, 0 ); }
play_pose( pose );
}
else { llUnSit( attached_agent ); }
}
}