Cypher Olsen
Registered User
Join date: 7 Aug 2004
Posts: 54
|
08-19-2004 12:31
I've built a head for a custom AV I'm working on, and I need to make the facial sphere texture blink. This is the script I've come up with, but I haven't got a chance to test it at home yet. Does this look Valid? It's my first real script. Any changes to suggest? My main worries are... Will the script sucessfully call the default state_entry after every blink and choose a different BlinkTime? Or will it choose BliinkTime once the first time it's run and do nothing else? Let me know what you think. Thanks. //Script by Cypher Olsen //Random Blink Script - version 0.1
//This Script should cause the Texture to animate and 'blink' every 3 to 8 seconds.
//Setup for a 4-frame texture, formatted as follows. // |-----|-----| // | 1 | 2 | // |-----|-----| // | 3 | 4 | // |-----|-----|
//Global Variables float BlinkTime = 0.0;
default { begin_state() { //llWhisper(0, "Default State: Not blinking."); //Create a Random # between 3.0 and 8.0 BlinkTime = llFrand(5.0) + 3.0; llSetTimerEvent(BlinkTime); }
timer() { //llWhisper(0, "default timer triggered. Switching states.); state blink_state; } }
state blink_state { state_entry() { //llWhisper(0, "Blinking..."); //Start Blink Animation llSetTextureAnim(ANIM_ON, ALL_SIDES, 2, 2, 0, 0, 5); llSetTimerEvent(1.0); }
timer() { //llWhisper(0, "Blink done, going back to default state."); state default; } state_exit() { //Disable Blink Animation llSetTextureAnim(FALSE, ALL_SIDES, 2, 2, 0, 0, 5); } }
|
Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
|
08-19-2004 12:51
There are some syntax errors, but you'll figure them out. Other than that it looks mostly correct. However, you can make this script much much simpler. Don't forget that animations don't loop unles you explicitly make them. So you could do something like this instead: default { state_entry() { // set the next timer event llSetTimerEvent(llFrand(5.0) + 3.0); }
timer() { // blink, first turn anim off, then on llSetTextureAnim(0, ALL_SIDES, 2, 2, 0, 0, 5); llSetTextureAnim(ANIM_ON, ALL_SIDES, 2, 2, 0, 0, 5);
// when the animation completes, it will stay on the last frame // if you wanted it to go through all frames forwards and the // backwards, ending up on the first frame, you could use // llSetTextureAnim(ANIM_ON | PING_PONG, ALL_SIDES, 2, 2, 0, 0, 5);
// set the next timer event llSetTimerEvent(llFrand(5.0) + 3.0); } }
In answer to your concerns, yes, the state_entry event is called *every* time the state is entered from a different state.
_____________________
Sarcasm meter: 0 |-----------------------*-| 10 Rating: Awww Jeeze!
|
Cypher Olsen
Registered User
Join date: 7 Aug 2004
Posts: 54
|
08-19-2004 12:55
Thanks for the reply Wednesday!
Your script is certainly much simpler, and does just what I was trying to accomplish. Thanks for the post!
Now I just have to try it in SL... Last time I did, I almost had it working, but every time I 'blinked' my eyes moved to the side of my head, then back to the front. Grrr, not sure what that was about.
If I have the same problem this time and can't figure it out on my own. I'll be back =)
|