Scripting again!!!

February 5, 2012 at 9:24 am (Uncategorized)

This time I am following this:

http://www.youtube.com/user/MayaHowTos

And learn what is going on in there of course!

While doing this whole exercise, I came upon this problem:

When I came across this problem, I was very confused, because I typed exactly the same as what the tutorial said. Then I actually went and look around my keyboard, searching for any other symbol that could replace this:

and it happen to be this:

Haha

Soooo, after looking at all the six videos, I need to create a random number of zombies and create a number of zombie.

Here’s the code for the whole thing:

if (`window -ex zacp_win`) deleteUI zacp_win; //deleting the window if it exist

window -wh 400 100 -t “Zombie Apocalypse Control Panel” zacp_win;

columnLayout -adj true;

intSliderGrp -l “Number of Zombies” -f true -v 5 -min 1 -max 10 slider_zombies;

button -l “Create” -c “create_zombies()”; // creating a button called create

button -l “Random” -c “create_random()”; // creating a button called random

showWindow zacp_win; //show the window

proc create_zombies(){

           string $all_characters[] = `ls -tr “human*” “zombie*”`;

          if(size($all_characters)) delete $all_characters;//deleting the existing zombie

         int $num_zombies = `intSliderGrp -q -v slider_zombies`;

         for ($i = 0; $i < $num_zombies; $i++)

                 {

                            string $new_zombie[] = `duplicate -rr -un -n “zombie_GRP#” original_zombie_GRP`;

                          //creating a new zombie at the humans place and grouping together with zombie GRP

                           setAttr ($new_zombie[0] + “.v”)true;

                           float $randx = rand(-1120,0);

                          float $randz = rand(-1120,0);

                         move $randx 0 $randz $new_zombie[0];

                 }

}

proc create_random(){

           string $all_characters[] = `ls -tr “human*” “zombie*”`;

           if(size($all_characters)) delete $all_characters;

           float $random = rand(1,10); //the random number zombie

          for ($i = 0; $i < $random; $i++)

                {

                            string $new_zombie[] = `duplicate -rr -un -n “zombie_GRP#” original_zombie_GRP`;

                           setAttr ($new_zombie[0] + “.v”)true;

                            float $randx = rand(-1120,0);

                            float $randz = rand(-1120,0);

                          move $randx 0 $randz $new_zombie[0];

                }

}

And here’s the result:

Here’s what happen once I pressed the create button:

and here’s what happen once I pressed random:

Relatively speaking it is quite easy to do this haha. Also, I just notice that I was suppose to create the window with the title “Zombiemaker” ,I had totally forgotten about it haha. To create this, I simply need to change this:

window -wh 400 100 -t “Zombie Apocalypse Control Panel” zacp_win;

To this:

window -wh 400 100 -t “Zombiemaker” zacp_win;

 

Leave a comment

Design a site like this with WordPress.com
Get started