View Single Post
# 5 01-06-2003 , 08:54 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Hehe, don't cry. It's not that serious :p
Anyway, I though I'd break down this little script with comment lines so you could possibly learn something from it...

Code:
// Define a global procedure called randomTY which takes nothing as input
global proc randomTY()
{
	// Define a string array variable $list[] and store a list of selected transform nodes in it
	string $list[] = `ls -tr -sl`;
	// Define an integer variable $size and store the size of the $list[] array in it.
	// Also we define another integer variable $i for later use.
	int $size = size($list), $i;

	// If there is something in the $list[] then go on. Otherwise just quit
	if ($size > 0)
		// Iterate though the list ($i goes from 0 to $size - 1)
		for($i = 0; $i < $size; $i++)
			// Set the .translateY (aka .ty) attribute of each object in the list to a random value of 1-9
			// Note the extra parenthesis'. They are needed so the clauses inside gets executed first before the setAttr command.
			setAttr ($list[$i] + ".ty") (rand(1,9));
	// End of story
}


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!