Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Trying to gradually change prim size?

Synthia Gynoid
PRIMAL DREAMS
Join date: 10 Jul 2007
Posts: 52
04-20-2008 15:13
Hi! This is probably a stupidly simple question, but I'm going to ask the experts here anyway, lol. :)

I'm trying to write a script that will change the properties of a prim by a small amount when the prim is touched. I've tried to set this up as a touch_start event that randomizes a small vector addition to the current PRIM_SIZE vector value. It seemed like I would want to get the current prim size, then add my random-adjustment to that, then set the primitive parameters to the new value.... but I can't get it to work, and I don't know enough to know why.

Okay, having explained all that, why isn't my script doing the job I describe above? :)

CODE


default
{
touch_start(integer total_number)
{
float xnew1 = llFrand(0.1);
float xnew2 = -llFrand(0.1);
float xnew = (xnew1 + xnew2);

float ynew1 = llFrand(0.1);
float ynew2 = -llFrand(0.1);
float ynew = (ynew1 + ynew2);

float znew1 = llFrand(0.1);
float znew2 = -llFrand(0.1);
float znew = (znew1 + znew2);

vector addsize = <xnew, ynew, znew>;
vector newsize = llVecMag(llGetPrimitiveParams([PRIM_SIZE]) + addsize);

llSetPrimitiveParams([PRIM_SIZE, newsize]);

}
}

Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
04-20-2008 16:07
Not stupid question at all. The thing about llGetPrimitiveParams is it actually returns a *list*, since you can feed it a list of parameter types to get all at once. In your case it's returning a list with a single vector in it, but it's a list just the same, square brackets and all. So do something like this:

vector newsize = llVecMag(llList2Vector(llGetPrimitiveParams([PRIM_SIZE]),0) + addsize);


Maybe not the easiest to read though. Look at this too, same thing in 2 steps.

vector myvector = llList2Vector(llGetPrimitiveParams([PRIM_SIZE]),0);
vector newsize = llVecMag(myvector + addsize);


Hope that helps some :)
_____________________
Designer of sensual, tasteful couple's animations - for residents who take their leisure time seriously. ;)

http://slurl.com/secondlife/Brownlee/203/110/109/

Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
04-20-2008 16:13
From: Synthia Gynoid
It seemed like I would want to get the current prim size, then add my random-adjustment to that, then set the primitive parameters to the new value.... but I can't get it to work, and I don't know enough to know why.



CODE

default
{
touch_start(integer total_number)
{
float xnew1 = llFrand(0.1);
float xnew2 = -llFrand(0.1);
float xnew = (xnew1 + xnew2);

float ynew1 = llFrand(0.1);
float ynew2 = -llFrand(0.1);
float ynew = (ynew1 + ynew2);

float znew1 = llFrand(0.1);
float znew2 = -llFrand(0.1);
float znew = (znew1 + znew2);

vector addsize = <xnew, ynew, znew>;
vector newsize = addsize + llList2Vector( llGetPrimitiveParams([PRIM_SIZE]), 0 );
llSetPrimitiveParams([PRIM_SIZE, newsize ]);
}
...
}


You have confused the 'PeimitiveParams'- function calls, see http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetPrimitiveParams
to learn all about it.

happy scripting
_____________________
From Studio Dora
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
04-20-2008 16:18
From: Anti Antonelli


vector myvector = llList2Vector(llGetPrimitiveParams([PRIM_SIZE]),0);
vector newsize = llVecMag(myvector + addsize);


llVecMag returns a Float not a Vector... so what shall it be?
_____________________
From Studio Dora
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
04-20-2008 16:22
llVecMag returns a float that is the "length" of a vector, so I'm not sure what you're attempting to do with it.

Side note:

I'm guessing you want values from -0.1 to 0.1:
CODE

vector current;
vector add;
vector new;

default
{
state_entry()
{
current = llGetScale();
}

touch_start(integer total_number)
{

add.x = llFrand(0.2) - 0.1;
add.y = llFrand(0.2) - 0.1;
add.z = llFrand(0.2) - 0.1;

new = current + add;

if (new.x < 0.01) { new.x = 0.01;}
else if (new.y < 0.01) { new.y = 0.01;}
else if (new.z < 0.01) { new.z = 0.01;}
else if (new.x > 10.0) { new.x = 10.0;}
else if (new.y > 10.0) { new.y = 10.0;}
else if (new.z > 10.0) { new.z = 10.0;}

current = new;
llSetScale(new);
}
}


I'm not sure whether or not you actually need the size checks or not.
_____________________
Though this be madness, yet there is method in't.
-- William Shakespeare

Warburton's Whimsies:
In SL
Apez.biz
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
04-20-2008 20:58
From: Dora Gustafson
llVecMag returns a Float not a Vector... so what shall it be?

That part was copy/pasted from the OP, my bad I guess? It seems there is more than one issue with data types going on here :)
_____________________
Designer of sensual, tasteful couple's animations - for residents who take their leisure time seriously. ;)

http://slurl.com/secondlife/Brownlee/203/110/109/

Synthia Gynoid
PRIMAL DREAMS
Join date: 10 Jul 2007
Posts: 52
04-21-2008 07:16
Cool, thanks for all the replies, everyone! You've helped me figure out where I was going wrong, and now it works like it should! :D