Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Scripts on worn objects?

Lexicon Svarog
Registered User
Join date: 5 Feb 2005
Posts: 3
02-26-2005 18:57
Is there some trick to running scripts on objects that are being worn? I have an object that has a child animation (just spinning blocks for now)- they work fine in the sandbox, but when I put them on, they stop. Is this a limitation of worn objects, or is there a flag or something I need to set to get that to work?
Zuzi Martinez
goth dachshund
Join date: 4 Sep 2004
Posts: 1,860
02-26-2005 21:17
i'm pretty sure you can't rotate attachments in any real way. best bet is either a rotating texture animation or set up a series of invisible objects and toggle the transparency in sequence so it looks like it's rotating. sorry.
Lexicon Svarog
Registered User
Join date: 5 Feb 2005
Posts: 3
02-26-2005 21:30
Hm- well, good thing I asked before spending more time at it- Thanks for your help.

So, is there anything special that needs to be done for texure animation? Does SL support animated GIFs, or do I have to do the animation manually by swapping textures or shifting UVs?

Thanks again--

--Lex
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
02-26-2005 21:42
It sounds like you are rotating them with the omega vector. When an object is attached, it's omega vector is overridden by the rotation specified for the attach point. Erm... well, see the wiki for further details:
http://secondlife.com/badgeo/wakka.php?wakka=llTargetOmega
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
02-26-2005 21:43
From: Lexicon Svarog
...

So, is there anything special that needs to be done for texure animation? Does SL support animated GIFs, or do I have to do the animation manually by swapping textures or shifting UVs?


Modulating U/Vs will do it.
Lexicon Svarog
Registered User
Join date: 5 Feb 2005
Posts: 3
02-26-2005 22:04
From: gene Poole
It sounds like you are rotating them with the omega vector. When an object is attached, it's omega vector is overridden by the rotation specified for the attach point. Erm... well, see the wiki for further details:
http://secondlife.com/badgeo/wakka.php?wakka=llTargetOmega


Actually, I was using llSetLocalRot so I could have the object rotate at an offset from the attachment points, but looks like I'll need a different solution (Hm... a different set of prims for each "frame" of animation, and cycle visibility- I guess that would work, but what a hack =)
Zuzi Martinez
goth dachshund
Join date: 4 Sep 2004
Posts: 1,860
02-26-2005 22:49
hehehe yeah the multi prim visibility cycle thing is a total pain in the ass. :D

here's the wiki entry for llSetTextureAnimation() . you can do it alot of different ways from rotating the texture to sliding it across the prim face to making a texture with multiple frames in it and switching between them.
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
02-26-2005 23:17
I wonder if you could use any sort of joint...? I've yet to see a use for joints. ;)

Maybe you could make an anim which twists the limb to which the object is attached a full 360 degrees, then snaps back to 0, giving the illusion of rotation?

IM from Some Person: Uhh... hey buddy... your wrist is doing complete revolutions. Just thought you'd like to know.

Seriously, though, I was trying to do something like that myself some time ago, and never resolved it. If I ever get back to it and figure it out, I'll post the trick. Please do the same, unless it's your bread and butter. :)
Zuzi Martinez
goth dachshund
Join date: 4 Sep 2004
Posts: 1,860
02-26-2005 23:33
i'm almost positive you can't attach joint objects. seems like i tried it but i might be imagining that :D

i totally forgot the animation method. that would work perfect if you had a weird av inside a bunch of attachments and didn't just want your watch to rotate or something.
Smigmee Pinkerton
Unlicensed Primologist
Join date: 1 Mar 2005
Posts: 42
Rotation Problems
03-10-2005 08:24
So am i to understand I use the:

llTargetOmega(vector axis, float spinrate, float gain)

For linked object rotation?

Ive seen in certain stores a box with a flat lid. And it was scripted to simply open (rotatio) by pivoting at the back. Like a cigar box. This is exactly what im trying to replicate. I made a joint and got the top to rotate perfectly. The problem is when i link it. I try linked the box first then the top, as well as clicking the top then the box to link. The whole box just wants to rotate.. Maybe i add a seperate script in the box telling it to stay put?

Anyways thanks for the help , (Due to this forum i have surpased many barriers thanks ppl)
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
03-10-2005 08:38
The cigar box hinge thing might have been a child-rotation. If you use llTargetOmega in a linkset, I believe either the whole object will spin (if it's the root that has an omega spin), or nothing. I tried to build a complex (linked) object with some spinning inner bits using llTargetOmega, and it didn't do jack.

Also, even if you do get your object spinning properly, as soon as you attach it, you lose any omega "factor" (as the new omega target is your attach point's vector) -- in other words, if you have a spinning basketball, as soon as you stick on your head, it turns to "aim" where your head is looking, but won't actually spin, unless you have an anim that makes your head spin (try 'find' with query "exorcist anim" *shrug* :) )

So, try to read the wiki about child rotations and stuff; it should help.

Good luck!
Smigmee Pinkerton
Unlicensed Primologist
Join date: 1 Mar 2005
Posts: 42
Ok Child Rotation
03-11-2005 07:35
I read the wiki it told me to make my objects position them then add this to my target moving prim:

default
{

state_entry() {

llSay(0, (string) llGetRot());

}

}

Ok so yeah i got some co-ords.. Great Now they told me to : \\\\\\\
" llSetLocalRot will now rotate your child prim correctly, relative to the rotation of the parent prim."

Ok so i clicked the link for llSetLocarRot , all it tells me is the following:
llSetLocalRot(rotation rot)

Pretty weak, im not really able to figre out what im supposed to do. Could someone help me continue getting this cigar box to open properly when linked. (i tried just putting llSetLocalRot( my co-ord ) and my co-ords where what the first script told me. did nothing :(
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-11-2005 09:48
llSetLocalRot will work with llGetLocalRot and then some adding quantities to the relevant part of the vectors. I don't have a script to hand, but have one in world that I will send if no one sends you one sooner.

Whether it works on attached objects, no idea I'm afraid, I use it for doors and the like.
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
03-11-2005 12:34
From: Zuzi Martinez
hehehe yeah the multi prim visibility cycle thing is a total pain in the ass. :D

here's the wiki entry for llSetTextureAnimation() . you can do it alot of different ways from rotating the texture to sliding it across the prim face to making a texture with multiple frames in it and switching between them.


A generic multi-prim visibility animation script... er, pair of scripts. Prims of course must be linked together. The first script is the main controller, copies of the second script must be placed in each prim that is to be animated, and modified to specify which frames that prim should be visible on. :)

The controller script:

CODE
// Alpha-animation Controller Script
//
// User speficies the total number of frames in the animation and
// the frame rate in frames per second. Try to keep this reasonably low...


integer NUMBER_OF_FRAMES = 4 ; // Total number of frames in this animation

float FRAMES_PER_SECOND = 5 ; // I doubt it could handle 10fps :)

integer running = TRUE ;

animcycle()
{
integer i ;

for( i = 0; i < NUMBER_OF_FRAMES; i++ )
{
llMessageLinked( LINK_SET, (integer)llPow( 2.0, (float)i ), "", "" ) ;
llSleep( 1.0 / FRAMES_PER_SECOND ) ;
}
}


default
{
state_entry()
{
llSetTimerEvent( (float)NUMBER_OF_FRAMES / FRAMES_PER_SECOND ) ;
}

timer()
{
animcycle() ;
}

touch_start( integer num )
{
running = !running ;

if( running ) llSetTimerEvent( (float)NUMBER_OF_FRAMES / FRAMES_PER_SECOND ) ;

else llSetTimerEvent( 0 ) ;
}
}
And this is the script for all the individual prims to be animated. Woo, I made my own bitflags, aren't you all proud of me? :D
CODE
// Framescript
//
// Place this script in every prim that should be changing between frames
//
// For the FRAME_NUMBERS integer, OR together ( | ) the FRAMEs on which this prim should be visible
// Ie. if it should be visible on the 0th and 3rd frames, FRAME_NUMBERS = FRAME0 | FRAME3 ;
//
// Frames are numbered starting at zero!

integer FRAME0 = 1 ;
integer FRAME1 = 2 ;
integer FRAME2 = 4 ;
integer FRAME3 = 8 ;
integer FRAME4 = 16 ;
integer FRAME5 = 32 ;
integer FRAME6 = 64 ;
integer FRAME7 = 128 ;
integer FRAME8 = 256 ;
integer FRAME9 = 512 ;
integer FRAME10 = 1024 ;

integer FRAME_NUMBERS ;

integer is_visible = FALSE ;

default
{
state_entry()
{
FRAME_NUMBERS = FRAME0 ; // OR together all the frames this prim should be -visible- on
}

link_message( integer sender, integer num, string message, key id )
{
if( FRAME_NUMBERS & num )
{
if( !is_visible )
{
is_visible = TRUE ;
llSetAlpha( 1.0, ALL_SIDES ) ;
}
}

else
{
is_visible = FALSE ;
llSetAlpha( 0.0, ALL_SIDES ) ;
}
}
}
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"