Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Making an object grow slowly

Theoretical Quandry
Questionable
Join date: 16 Jul 2008
Posts: 12
10-22-2008 22:00
I've got a script that is triggered by a parent prim (using the standard controller methods), only the scaling doesn't seem to be working correctly. The object is meant to be worn as an attachment, with the child prim invisible until the trigger is received. At that point, the child prim should become visible and increase in size (and alter it's position of course), however, I don't want the size change to be instantaneous - I want it to be incremental. I tried putting the scaling into the timer script (necessary to keep the facial animation going), but it's not working, it just pops in full size.

If you need a visualization, parent prim is a small prim inside the mouth, child prim is a larger object outside the mouth (think blowing a bubble or balloon). Parent prim sends the following command when triggered:
llMessageLinked( LINK_SET, FALSE, CONTROLLER_ID, NULL_KEY );

This is the child prim code:
CODE

integer side = ALL_SIDES; // 0 = top side of prim, you can use ALL_SIDES too.
float off_alpha = 0.0; // 0.0(no-alpha) to 1.0(max)
float on_alpha = 1.0; // 0.0(no-alpha) to 1.0(max)
key p;
string CONTROLLER_ID = "A";
integer AUTO_START = TRUE;
integer grow = 0;
vector scale;

default {
state_entry() {
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
if ( AUTO_START )
llSetAlpha( off_alpha, side);
else
llSetAlpha( on_alpha, side);
}

on_rez(integer s)
{
if (p != llGetOwner())
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);
}

run_time_permissions(integer perm)
{
p = llGetOwner();
}

link_message( integer sibling, integer num, string mesg, key target_key ) {
if ( mesg != CONTROLLER_ID ) { // this message isn't for me. Bail out.
return;
} else if ( num == 0 ) { // Message says to turn alpha on (remove transparency):

llSetAlpha( on_alpha, side);
llSetTimerEvent(.1);

} else if ( num == 1 ) { // Message says to turn alpha off (set transparent):

llSetAlpha( off_alpha, side);
llSetPrimitiveParams([PRIM_POSITION, llGetPos() + <-0.038, 0, 0.047>, PRIM_SIZE, <0.040, 0.040, 0.094>]);
llSetTimerEvent(0);

} else { // bad instruction number
// do nothing.
}
}
timer()
{
grow ++;
llStartAnimation("express_surprise_emote");
if (grow < 10)
{
scale = llGetScale();
llSetPrimitiveParams([PRIM_POSITION, llGetPos() + <0.004, 0, -0.005>, PRIM_SIZE, <scale.x + 0.009,scale.y + 0.009,scale.z + 0.02>]);

}
else if (grow == 10)
{
scale = llGetScale();
llSetPrimitiveParams([PRIM_POSITION, llGetPos() + <0.002, 0, -0.002>, PRIM_SIZE, <scale.x + 0.004,scale.y + 0.004,scale.z + 0.02>]);

}
}


}



It compiles and runs, but the scaling doesn't seem to be happening. Any help is appreciated....
Galena Qi
Registered User
Join date: 9 Sep 2006
Posts: 249
10-23-2008 16:59
The script worked for me (once) when I made the following changes to the variable types in the llMessageLinked:

llMessageLinked( LINK_SET, 0, "CONTROLLER_ID", NULL_KEY );

And then changed the child message to:

link_message( integer sibling, integer num, string mesg, key target_key ) {
if ( mesg != "CONTROLLER_ID" )

The child prim appeared and grew. This script also did something odd to my avatar, making it bend over at the waist after I stopped the emote animation. I don't think I want to know what you are using this for ;-0.
Theoretical Quandry
Questionable
Join date: 16 Jul 2008
Posts: 12
10-23-2008 20:54
From: Galena Qi
The script worked for me (once) when I made the following changes to the variable types in the llMessageLinked:

llMessageLinked( LINK_SET, 0, "CONTROLLER_ID", NULL_KEY );

And then changed the child message to:

link_message( integer sibling, integer num, string mesg, key target_key ) {
if ( mesg != "CONTROLLER_ID" )

The child prim appeared and grew. This script also did something odd to my avatar, making it bend over at the waist after I stopped the emote animation. I don't think I want to know what you are using this for ;-0.


LOL - No clue why it did that - it's just the "surprise" facial animation. Anyway - I still can't get it to work. Think I'll go back to the basics and try again.
Eli Schlegal
Registered User
Join date: 20 Nov 2007
Posts: 2,387
10-24-2008 05:45
Ok admit it... this is a penis script isn't it?
Galena Qi
Registered User
Join date: 9 Sep 2006
Posts: 249
10-24-2008 08:35
Your problem may be that the script doesn't reset after it is run the first time, so it will only work once. I don't know why it would work for me and not for you. If you'd like, I can drop my test object in your inventory next time I'm in world.
Theoretical Quandry
Questionable
Join date: 16 Jul 2008
Posts: 12
10-30-2008 16:17
It's not a penis script. If you must know, it's for the "Ton Tongue Toffee" I'm working on. Sheesh.