Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to use Random numbers in texture animation?

Incony Hathaway
Registered User
Join date: 18 Feb 2007
Posts: 235
06-26-2007 06:51
Hi Hi`s..:)

This is the standard animation script for a texture/ frame animation.:

llSetTextureAnim( ANIM_ON | LOOP , ALL_SIDES, 5, 5, 0, 25, 15);

5 by 5 frames, start frame top left = 0, frame end = 25 , 15 is the time.

can i substitute those numbers for a range defined previously?, ie.. instead of a fixed frame start.. say before this point in the script A= 10 for example.. and B = random number between 0 and A and put B in the line?

so the line would look like..


llSetTextureAnim( ANIM_ON | LOOP , ALL_SIDES, 5, 5, B, 25, 15);


then if possible to be able to have A and B to be defined live by action, ie an avatar does something that changes A or B.. or touch by an avatar or me...?

so.. the script runs... A is defined.. perhaps A might be the maximum time for example.. and B is a random time number selected automatically every script cycle


OR like i said, the frame start point.. end point..

Does SL use user defined globals.. ie values that are available anywhere?
Incony Hathaway
Registered User
Join date: 18 Feb 2007
Posts: 235
Well.. some of it answered..:)
06-26-2007 09:33
// anim SMOOTH Script
// By Doug Linden (I think)
//

// If you are interested in scripting, check out
// the Script Help under the help menu.

// The double slash means these lines are comments
// and ignored by the computer.

// All scripts have a default state, this will be
// the first code executed.
default
{
// state_entry() is an event handler, it executes
// whenever a state is entered.
state_entry()
{
// llSetTextureAnim() is a function that animates a texture on a face.
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, ALL_SIDES,0,0,0,0, 0,0.20);
// animate the script to scroll across all the faces.
}


}




//** Script by Vik Bethune ****
//** Created: 12/12/2006 ****
//** Updated 27/12/2006 ****
//** Copyright (C) 2006 ****
//******************************************************



float gSpeed = -0.01; // Speed (rate) of the texture
integer gChannel = 12; //Talk channel

float MIN_SPEED = 0.001;
float MAX_SPEED = 0.02;

integer SIDE = ALL_SIDES; // Which side of prim to animate, can use ALL_SIDES
float MOVEMENT = 1; // MOVEMENT(length) How far the texture moves
integer X_FRAMES = 1; // In Standard Mode - defines the number of Horizontal frames or pieces to subdivide the texture into
integer Y_FRAMES = 1; // In Standard Mode -defines the number of Vertical frames or pieces to subdivide the texture into
float START = 1.0; // specifies the frame number to begin animating from (frames are numbered from left to right, top to bottom, starting at 0)

string gUsage = "";


myHelp()
{
gUsage = "\n **** Current Speed is: " + (string)gSpeed + "\n" + "**** Current Channel is: " + (string)gChannel + "\n"+"Use channel /"+(string)gChannel+ " to Enter speed between: " + (string)MIN_SPEED + " and " + (string)MAX_SPEED +", example: /"+(string)gChannel+" 0.525 \n" +" To reset script enter: /"+(string)gChannel+ " reset ";
llOwnerSay(gUsage);
}

//+" To change channel enter: /"+channel+ " new channel number, example: /"+channel+" 639 \n"

default
{


state_entry()
{
llSetStatus(STATUS_PHANTOM, TRUE); // set object to phantom
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, SIDE, X_FRAMES, Y_FRAMES, START, MOVEMENT, gSpeed);
llListen(gChannel, "", llGetOwner(), "";); // listen to my owner
//myHelp( (string) gChannel, (string)gSpeed);
}

on_rez(integer start_param)
{
// this ensures that if we're transferred to a new owner, we're listening to them and not still to the previous one
llResetScript();
}

changed(integer change) { // something changed
if (change & CHANGED_OWNER) llResetScript(); // changed owner - reset script
}

// Alow only owner to set speed of animation on touch
touch_start(integer number)
{
myHelp();
//myHelp( (string) gChannel, (string)gSpeed);
//llListen(gChannel, "", llGetOwner(), "";); // listen to my owner
}

listen(integer channel, string name, key id, string message)
{

if (message == "reset";) llResetScript();
else if ((float)message >= MIN_SPEED && (float)message < MAX_SPEED)
{
gSpeed = (float)message;
llSetTextureAnim(ANIM_ON | SMOOTH | LOOP, SIDE, X_FRAMES, Y_FRAMES, START, MOVEMENT, gSpeed);
}
else{
llOwnerSay("*** Invalid Command ***";);
myHelp();
//myHelp((string)channel, message);
}
}

}


so the parameters can be predefined and redefined live.. but i still would like to know how
i can set a random variable and determine globals that can work across prims without linking.
Luth Brodie
Registered User
Join date: 31 May 2004
Posts: 530
06-26-2007 09:44
this is animation help not scripting. You'd find you answer much quicker there.
_____________________
"'Aarrr,' roared the Pirate Captain, because it seemed a good way to end the conversation."
The Pirates! In An Adventure With Scientists.

Reel Expression Poses and Animations:
reelgeek.co.uk/blog