Join us in Phaze Demesnes or follow us:

Home   Show All
Category: Contributor: Creator
Eye Blinking Eye  

Blinking Eye

Blinking-eye Script

Category: Eye
By : Ferd Frederix
Created: 2013-09-06 Edited: 2013-09-07
Worlds: Second Life + OpenSim

the Zip file

Download all files for Blinking Eye
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1 // This blink script uses a single texture with the frames set up as follows within the image.
2 //
3 // +-----+-----+
4 // | 1 | 2 |
5 // +-----+-----+
6 // | 3 | 4 |
7 // +-----+-----+
8
9 // The minimum time between blinks
10 float minBlinkTime = 0.5; // in seconds
11
12 // The Maximum time between blinks
13 float maxBlinkTime = 12.0; // in seconds
14
15 // The animation frame speed
16 float animationSpeed = 7; // in fps
17
18 // number of frames in the animation
19 integer numberFrames = 4;
20
21 // temporary variable
22 float waitTime;
23
24
25 // Returns a reandom number between min and max
26 float randBetween(float min, float max)
27 {
28 return llFrand(max - min) + min;
29 }
30
31
32 default
33 {
34 // Main part of the program
36 {
37 // Sets the size and position of the default frame
38 llOffsetTexture(0.25,0.25,ALL_SIDES);
40 // Intialize time even
41 llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime));
42 waitTime = (numberFrames * 2) / animationSpeed;
43 }
44
45 // Timer event
46 timer()
47 {
48 // Temporarily turn off the timer event
49 llSetTimerEvent(0.0);
50 // Animate the eyes onces.
51 llSetTextureAnim(ANIM_ON|PING_PONG,ALL_SIDES,2,2,1,4,animationSpeed);
52 // Wait for the eyes to finish animating
53 llSleep(waitTime);
54 // Turn off animation
55 llSetTextureAnim(FALSE,ALL_SIDES,2,2,1,4,animationSpeed);
56 // Reset Timer for next event
57 llSetTimerEvent(randBetween(minBlinkTime,maxBlinkTime));
58 }
59 } // end
60 // CREATOR: