Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Eye Blink Script problem

Salen Welesa
Kupo? Dook?
Join date: 13 Jul 2005
Posts: 65
05-21-2006 14:50
Hi. I'm trying to edit this blinking eye script I picked up, and I can figure out how to partly modify it, but its not working quite right.

CODE

// This blink script uses a single texture with the frames set up as follows within the image.
//
// +-----+-----+
// | 1 | 2 |
// +-----+-----+
// | 3 | 4 |
// +-----+-----+

// The minimum time between blinks
float minBlinkTime = 0.5; // in seconds

// The Maximum time between blinks
float maxBlinkTime = 12.0; // in seconds

// The animation frame speed
float animationSpeed = 7; // in fps

// number of frames in the animation
integer numberFrames = 4;

// temporary variable
float waitTime;


// Returns a reandom number between min and max
float randBetween(float min, float max)
{
return llFrand(max - min) + min;
}


default
{
// Main part of the program
state_entry()
{
// Sets the size and position of the default frame
llOffsetTexture(-0.25,0.25,ALL_SIDES);
llScaleTexture(0.7,0.5,ALL_SIDES);
// Intialize time even
llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime));
waitTime = (numberFrames * 2) / animationSpeed;
}

// Timer event
timer()
{
// Temporarily turn off the timer event
llSetTimerEvent(0.0);
// Animate the eyes onces.
llSetTextureAnim(ANIM_ON|PING_PONG,ALL_SIDES,2,2,1,4,animationSpeed);
// Wait for the eyes to finish animating
llSleep(waitTime);
// Turn off animation
llSetTextureAnim(FALSE,ALL_SIDES,2,2,1,4,animationSpeed);
// Reset Timer for next event
llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime));
}
}


Ok, the texture I want to use looks fine with a 0.7 on the horizontal repeat, but when the animation gets playing, it jumps back to 0.5 on the next 3 frames, then back to 0.7 when its done. How can I force it to stay 0.7 when its running? Hope this isn't too simple of a question. ^_^;
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
05-22-2006 05:29
Uhhh, I could be wrong, but I am 99% sure that you can't.

The whole point of how llSetTextureAnim works is that for a 2x2 anim, you get each 0.5x0.5 scaled part in turn.

The only ways you could change the size of the eyes are either to change the size of the prim you are running the script on, or edit the texture to resize the eye portion in the middle of each 'frame' (quarter).
Salen Welesa
Kupo? Dook?
Join date: 13 Jul 2005
Posts: 65
05-22-2006 14:52
Darn. Thats what I was afraid of. Oh well, non-blinking eyes it is! ^_^;