Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Texture animation script - Help?!

Raven Ivanova
Registered User
Join date: 4 Dec 2006
Posts: 70
02-21-2007 15:19
Completely new to scripting -- how can I run through (and loop) a sequence of *many* texture animations contained in one object?

First of all, obviously I don't want my SetTextureAnim to "Loop". Just want it to run through the animation once, and then move to the next animation in sequence.
0 or 1 works for me instead of "Loop", but I'm not sure if it's right. For example:

default
{
state_entry()
{
llSetTextureAnim(ANIM_ON | 0, ALL_SIDES,6,5,0,0,8.0);

}
}


Currently, if I put all my texture animations in one State, it works to the extent that I run through the animations once, then all stops on the last animation because of no loop.

So instead I try to put the texture animations in different states, and loop through each of the states. I start with the default state and loop back to it at the end.
I would think that would work, but it doesn't for some unknown reason.

Can someone show me a script of how to do this, if it's possible?
Icarus DuCasse
Registered User
Join date: 28 Jan 2007
Posts: 27
02-21-2007 16:25
Im not sure what you mean but this works fine with me.

default
{
state_entry()
{
llSetTexture("chromewheel1",ALL_SIDES);
llSetTextureAnim(ANIM_ON | 0, ALL_SIDES,6,5,0,0,8.0);
//llSleep(3);
state new;
}
}
state new
{
state_entry()
{
llSetTexture("jet", ALL_SIDES);
llSetTextureAnim(ANIM_ON | 0, ALL_SIDES,6,5,0,0,8.0);
llResetScript();
}
}
Raven Ivanova
Registered User
Join date: 4 Dec 2006
Posts: 70
Almost working
02-21-2007 18:26
Thanks Icarus. Now my animations are looping in sequence, but only the first animation works properly, and it plays properly just once.

From the second animation and onwards through the loops, the animations stop playing and all I see is a single frame showing all 16 animation frames as laid out in each of my TGA files. As if the script has stopped reading the frames of the TGA's.

What else could be wrong? (example of 2 animations):


default
{
state_entry()
{
llSetStatus(STATUS_PHANTOM, TRUE);
llSetTexture("texture1", ALL_SIDES);
llSetTextureAnim(ANIM_ON | 0, ALL_SIDES, 4, 4, 0, 0, 15.0);
llSleep(3);
state spin;
}
}

state spin
{
state_entry()
{
llSetStatus(STATUS_PHANTOM, TRUE);
llSetTexture("texture2", ALL_SIDES);
llSetTextureAnim(ANIM_ON | 0, ALL_SIDES, 4, 4, 0, 0, 10.0);
llSleep(2);
state default;

}

}
titatovernaar Balder
Registered User
Join date: 9 Nov 2006
Posts: 17
maby use one state ?
02-21-2007 23:28
hi i am newby but i learn one state a time maby thats the probleme


default
{
state_entry()
{
llSetTexture("chromewheel1",ALL_SIDES);
llSetTextureAnim(ANIM_ON | 0, ALL_SIDES,6,5,0,0,8.0);
//llSleep(3);
state new; ????????????
}
}
state new ??????????????
{
state_entry() ???????????????
{
llSetTexture("jet", ALL_SIDES);
llSetTextureAnim(ANIM_ON | 0, ALL_SIDES,6,5,0,0,8.0);
llResetScript();
}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-22-2007 03:14
I'm not absolutely sure (I have no textures to test with :p) but I think the problem is that you need to stop the animation (with llSetTextureAnim(FALSE, ALL_SIDES, 0, 0, 0, 0, 0.0); ) and then restart the animation effect to be able to change it.

I was also a little worried about the creative ideas for looping through the different animations. If you use combinations of llSleep and, llResetScript or state, you're really going to lock your script into an impenetrable loop which I don't think is a good idea.

Here's the same idea but using a timer which allows the script to breath... ie. it can still easily respond to other events.

CODE
integer track;
list textures = ["texture1", "texture2"];

default
{
state_entry()
{
llSetStatus(STATUS_PHANTOM, TRUE);
llSetTimerEvent(2);
}

timer()
{
if (track >= llGetListLength(textures)) track = 0;

llSetTextureAnim(FALSE, ALL_SIDES, 0, 0, 0, 0, 0.0);
llSetTexture(llList2String(textures, track), ALL_SIDES);
llSetTextureAnim(ANIM_ON, ALL_SIDES, 4, 4, 0, 0, 10.0);

track += 1;
}
}
Raven Ivanova
Registered User
Join date: 4 Dec 2006
Posts: 70
Entire texture showing
02-22-2007 12:00
Pale, thanks to your sophisticated solution (and thankyou for introducing me to SetTimerEvent), the animations are now playing.

There is one last problem, though. The animations play, but with each one I still have the entire texture showing all 16 frames flashing once on the prim before the animation plays through the frames.

I just found another thread addressing this same problem:

/54/c4/141663/1.html


I sort of understand the logic of the solution, having to do with fixing llOffsetTexture and llScaleTexture since each new animation begins with the original texture size and offset (bad thing).

However llScaleTexture is not compatable with llSetTextureAnim, so they had to use SetPrimitiveParams to fix the problem.
Not sure how to incorporate this solution into Pale's script, though.
Can anyone enlighten me?
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
02-22-2007 12:39
From: Ishtara Rothschild
In short: Let the animation run one time, then edit the prim and open the texture tab in teh edit window. Close it again - SL will act as if you manually entered the changed size+offset. Means, what you see now is what you'll see between animations. Then change the script to repair the offset only for one animation direction.
Or: before adding the animation script, tweak the texture parameters in the edit window to show the first frame only. Will have the same effect.
...did you try this?

Trouble is I know more about scripting than I do animation. :)