MEL scripts


#461

Babygirl, what you are asking is for someone to do your whole homework assignment for you.

Do your own assignment, and if you find that you are stuck on some part of it, ask for help. But this is not a service to do your whole homework. You have to make some effort. We are here to help, not to help you cheat at school.


#462

Read the docs, put some effort in, and come back with something to show and some problems you need to overcome.

If you dont do that why even bother passing it in, since you would not have learned anything.


#463

I know I do my job. but not as complicated start made ​​me just want to know how it could get started. thank you.


#464

[IMG]hello how are you a few days ago asking how to do a task I have solved almost 80% of all homework now only em need to create the expression to evaluate whether elicoptero is on the ground do not rotate the thruster., but if you move it up if you must rotate the thruster. tenog all that I do in the expression q editor plz help me ty

Prepare a script that allows me to create the proxy of a helicopter (model of a helicopter in
very low poly)
 must include a general controller type Nurbs Circle function as father of all
hierarchy.
 must create an expression that allows me to assess:
 If the helicopter is on the ground not moving propellers.
 If the helicopter rises must turn the propellers.


#465

Hi there,

You have a bit wrong style when you ask for help. This way it feels , like earlier stated, that more than help, you’d like some of us here to write the expression, or maybe even send you a ready scene file with a setup that you need 8)

I’m assuming this is not your intention so let me give you a hint: try to formulate precise, accurate questions concerning your particular problem, ie. “How do I know if my helicopter is on the ground or not?” and you might get an answer.

If you’re completely clueless how to query attributes with MEL or doing expression, you have to get back to your Maya books and / or class notes / papers and teach yourself the basics.

But the way you’ve presented yourself so far is not, I repeat, not going to work here 8)

All the best with your task and welcome to Maya forums.

/Risto

ps: if you look at your objects Y-axis transformation, you know when the object is on the ground or in the air


#466

ya you will find most you love to help people and teach, but will only put in effort when you do, have to meet half way when asking for help


#467

Sorry if I have already posted this, I’m not sure if my thread was created because I don’t see it.

I’m trying to make a shelf button to key all of the controls on a character. I’ve gotten as far as being able to select all of the controls, but cannot figure out how to key them within a loop.


// ======= Select All Controls ========
//Char to action
$chars = "MyChar_*:";

// List All Curves within char
select -cl;
$ctrls = `ls -type "nurbsCurve" ($chars + "*")`;

for( $ctrl in $ctrls ) {
    // Select ALL Curves
	//select -add $ctrl;

     // Add keys
        select -cl;
        select -r $ctrl;
	setKeyframe;
};

If you uncomment the first command you’ll see it selects everything as expected. However if you try to hit ‘s’ it doesn’t key the controls. Maya warns:

// Warning: file: C:/Program Files/Autodesk/Maya2014/scripts/others/doSetKeyframeArgList.mel line 641: Current manipulator and active objects have no keyable attributes, , or animation layers are present and the BaseAnimation bar is not selected or locked. //

The second unquoted commands are me trying to select each item individually and key them through the loop. The code doesn’t give any errors but it also doesn’t work. Hope you can help me out!


#468

Hi, don’t know if you fixed it, but there are couple of things to consider:
This, as you wrote it, will return a ‘shape’ node of the curve, which you can’t key in any case…

$ctrls = `ls -type "nurbsCurve" ($chars + "*")`;

I suggest you use a naming principle for your controls, suffix or such.
Apart from that, $ctrls must be an array to hold multiple values, so declare something like this:

string $controls[] = `ls ($chars + "*_ctrl")`;//_ctrl being a suffix of each control object

Then you can loop through them and do whatever needed:


for( $ctrl in $controls) {
// no need to use 'select' command, address an object through setKeyframe command:
setKeyframe $ctrl;
};

Cheers


#469

Thank you, aiming at the transforms instead works perfectly. The rig isn’t mine so unfortunately I don’t have control over the suffixes. That’s useful to know for when I make my own however so thank you!


#470

I currently have some mel scripts to import lithtech lta files to maya but i don’t seem how to get it work. Hope you guys help me out :smiley:
Here’s the download link of the script

https://www.mediafire.com/?w4eyvqchi6fjfhv

#471

Thanks these are really useful :smiley:


#472

I’ve created a dumb little script that creates an analogue clock on your viewport, and lets you know how long you’ve gone for lunch! It also insults the user if you input redundnat commands like “Make clock” when the clock is already made.

Hit ESC to abort the clock.

//Script starts here
/* bClock - a stupid program to leave running on my screen when I leave my desk for lunch 2015 Brent Forrest */

global int $randy;
global string $ins[];
global float $size;
$ins = {“idiot”, “stupid”, “dummy”, “retard”, “you beautiful specimen”, “Dean”, “baby-diapers”, “stinky”, “ugly”, “chumpy”, “numbnuts”, “dumpy”, “lumpy”, “friend”, “buddy”};
$size = size($ins);

if (window -exists bClock){
deleteUI bClock;}
window -title “Lunch Clock”
-iconName “bClock” -s 0
-widthHeight 600 500 bClock;
rowColumnLayout -w 400 -cw 300 300 -numberOfColumns 2;
button -bgc 0.1 0 0.5 -l “Delete the Clock” -command “deleteClock”;
button -bgc 0.1 0 0.5 -l “Make the Clock” -command “makeClock” ;
button -bgc 0.1 0 0.5 -l “Set the Time” -command “setTheTime” ;
button -bgc 0.1 0 0.5 -l “Start the Clock” -command “goClock” ;
button -bgc 0.5 0 0.1 -l “Do All” -command “go” ;
setParent …;
showWindow bClock;

proc go ()
{
if ( objExists mrMin ) deleteClock;
if ( !objExists mrMin ) makeClock;
setTheTime;
goClock;
}

proc deleteClock ()
{
global string $ins[];
global float $size;
if ( !objExists mrMin ){
int $randy = rand($size);
string $insult = $ins[$randy];
print ("No clock exists, " + $insult);
}else{
select “mrSec*” “mrHour*” “mrMin*” “mrFace*” “clockGP*” “pie*”;
string $clockIs[] = ls -sl;
delete $clockIs ;
}
}

// Create a couple nurbs circles and move the cvs to look like clock hands
proc makeClock ()
{
if ( !objExists mrMin ){
circle -c 0 0.0 0.0 -s 12 -d 1 -ch 1 -o on -nr 0 0 -1 -r 10 -n “mrFace”;
circle -c 0 0.05 0.2 -s 3 -d 1 -ch 0 -o on -nr 0 0 -1 -r 0.1 -n “mrSec”;
circle -c 0 0.4 0.1 -s 3 -d 1 -ch 0 -o on -nr 0 0 -1 -r 0.8 -n “mrMin”;
circle -c 0 0.5 0 -s 3 -d 1 -ch 0 -o on -nr 0 0 -1 -r 1 -n “mrHour”;
setAttr “mrMin.overrideEnabled” 1;
select -r mrMin.cv[0] mrMin.cv[3] ;
move -r -os -wd 0 10 0 ;
select -r mrSec.cv[0] mrSec.cv[3] ;
move -r -os -wd 0 10 0 ;
select -r mrHour.cv[0] mrHour.cv[3] ;
move -r -os -wd 0 8 0 ;
string $clockIs[] = {“mrSec”, “mrHour”, “mrMin”, “mrFace”};
for ($one in $clockIs){
setAttr ($one+".overrideEnabled") 1;
setAttr ($one+".overrideColor") 16;}
group -w -n “clockGP” $clockIs; xform -os -piv 0 0 0;
rotate 0 180 0 clockGP ;
select -d;
print “Clock has been made”;
}else{
global string $ins[];
global float $size;
int $randy = rand($size);
string $insult = $ins[$randy];
print ("There’s already a clock there, " + $insult);
}
}

proc setTheTime ()
{
if (objExists mrMin){
deleteClock;
makeClock;
string $theTime = date -t;
string $token[];
tokenize $theTime “:” $token;
$hour=$token[0];
$minute=$token[1];
$second=$token[2];
float $hour2 = $hour;
float $minute2 = $minute;
float $second2 = $second;
float $rotSec = (6 * $second2);
float $rotMin = (6 * $minute2);
float $rotHour = (30 * $hour2);
rotate 0 0 $rotSec mrSec;
rotate 0 0 $rotMin mrMin;
rotate 0 0 $rotHour mrHour;
refresh;
print ("Time has been set to " + $theTime) ;
}else{
global string $ins[];
global float $size;
int $randy = rand($size);
string $insult = $ins[$randy];
print ("There’s no clock there to set, " + $insult);
}
}

proc timer ()
{
if (!objExists "timer"){
cylinder -o 1 -ch 1 -ax 0 0 1 -hr 0.05 -r 10 -n “timer”;
parent timer clockGP;
nurbsPrimitiveCap 1 1 1;
pickWalk -d down;
pickWalk -d right;
rename “timePie”;
delete timerShape;
string $list[] = listConnections timePieShape;
rename $list[0] pieRevolve;
string $list[] = listConnections pieRevolve;
rename $list[0] pieMake;
rotate 0 0 90 timePie;
orientConstraint -o 180 0 90-n “tpOc” mrMin timePie ;
delete “tpOc”;
connectAttr mrMin.rotateZ pieMake.endSweep;
}
}

proc goClock ()
{
if (objExists mrMin){
global string $gMainProgressBar;
progressBar -edit
-beginProgress
-isInterruptable true
-status “Ticking Clock”
-maxValue 4500
$gMainProgressBar;
float $sec;
float $min;
float $hour;
string $clockIs[] = {“mrSec”, “mrHour”, “mrMin”};
if (!objExists pieColor) timer;
if (!objExists pieColor) mrColor;
makeIdentity -apply true -t 0 -r 1 -s 0 -n 0 $clockIs;
for($sec=0; $sec < 4500; $sec++) {
if(progressBar -query -isCancelled $gMainProgressBar)
break;
refresh ;
rotate 0 0 $sec mrSec;
$min = ($sec / 60);
rotate 0 0 $min mrMin;
$hour = ($min / 60);
rotate 0 0 $hour mrHour;
pause -sec 1;
progressBar -edit
-step 10 $gMainProgressBar;
}
progressBar -edit
-endProgress
$gMainProgressBar;
}else{
global string $ins[];
global float $size;
int $randy = rand($size);
string $insult = $ins[$randy];
print (“Do you see a clock there, " + $insult +”?");
}
}

proc mrColor ()
{
shadingNode -name “pieColor” -asTexture ramp;
setAttr “pieColor.colorEntryList[2].color” -type double3 1 0 0 ;
setAttr “pieColor.colorEntryList[0].color” -type double3 0 1 0 ;
setAttr “pieColor.colorEntryList[1].color” -type double3 1 1 0 ;
setAttr “pieColor.colorEntryList[2].position” 1;
setAttr “pieColor.colorEntryList[1].position” 0.6;
setAttr “pieColor.colorEntryList[0].position” 0.3;
setAttr “pieColor.interpolation” 4;
shadingNode -n “pieLambert” -asShader lambert;
shadingNode -n “pieUc” -asUtility unitConversion;
setAttr “pieUc.conversionFactor” 0.15;
connectAttr -force pieUc.output pieColor.uCoord;
setAttr “pieColor.type” 1;
connectAttr -force pieMake.endSweep pieUc.input;
connectAttr -force pieColor.outColor pieLambert.color;
setAttr “pieLambert.incandescence” 0.1 0.1 0.1 ;
setAttr “pieLambert.transparency” 0.5 0.5 0.5 ;
sets -renderable true -noSurfaceShader true -empty -name “pieColorSG”;
connectAttr -f pieLambert.outColor pieColorSG.surfaceShader;
sets -forceElement “pieColorSG” “timePie”;
refresh -f -cv;
}


#473

What a brilliantly dumb script that is - thanks for making my morning Brentorama :smiley:


#474

Got another one for you. Since my last one generated random insults, this one generates random compliments!

I’m still pretty new to MEL so as you can geuss my coding is rudimentary, that said, here is my first functional foray into ScriptJobs, getting userData and sampling info from an external text file.

Step one: Create a text file and write a compliment on as many lines as you like - or you can just copy / paste my list here. Save that file somewhere easy to navigate to, like C: emp\compliments.txt

you stallion
you champion
you superstar
you genius
you wonderful person
you handsome man
you killer
you maniac
you monster
you prince
you talented mofo
you awesome guy
you nice guy
you cool dude
you amazing specimen
you champ
you’re incredible
you’re amazing
you’re the best
you did it
you’ve done well
you’re quite good looking
you’ve done it
there’s no stopping you
you’ve got charisma
you rule

Step two, edit line 10 of the code below to match up with your text file path.

Step three, run the code and shower yourself with praise! The compliments update when the playback state changes, so just scrub the timeline if you really want to feel good about yourself.

int $complimentMe = scriptJob -conditionChange "playingBack" "doSomething";
doSomething;

global proc doSomething ()
{
string $comps[];
string $filePath = “Y:/forrest/Scripts/compliments.txt” ;
$fileId = fopen $filePath "r" ;
string $nextLine = fgetline $fileId ;
while (size($nextLine) > 0) {
string $cleanLine = strip($nextLine) ;
$comps[size($comps)] = $cleanLine ;
$nextLine = fgetline $fileId ;
}
string $localUser = getenv userName ;
$localUser = capitalizeString $localUser ;
int $s = size($comps);
int $frame = currentTime -q;
int $randy = rand($s);
string $compl = $comps[$randy];
string $texties = ($localUser +", " + $compl+", you went to frame " + $frame+ “!”);
if ( objExists CompTextShape ) delete CompTextShape;
textCurves -name “CompText” -f “Times-Roman” -t $texties;
fclose $fileId;
fitPanel -selected;
}

global proc killComps(int $complimentMe)
{
if ( objExists CompTextShape ) delete CompTextShape;
scriptJob -kill $complimentMe;
deleteUI complimentMe;
}

;

if (window -exists complimentMe){
deleteUI complimentMe;}
window -mbv 0 -title “Compliment Me”
-iconName “complimentMe” -s 0
-widthHeight 600 500 complimentMe;
rowColumnLayout -w 400 -cw 300 300 -numberOfColumns 2;
button -bgc 0.1 0 0.5 -l “Compliments Disable” -c “killComps($complimentMe)”;
setParent …;
showWindow complimentMe;


#475

Can anyone help me to install THIS script? I know nothing of programming and I am really stuck with it. Could use some hand here, guys.

Care to give exact guidance? I seriously suck with Maya and do not know how to use .mel files and stuff.

Text is too long for the forum, so I am providing a link for it :

http://www.cedric3d.com/dl/MirrorMe.mel

What it does is : it mirrors any polygon with a simple command, but beware with the vertexes separating the polygon in half, they need to be in a meridional line in order to work, otherwise it can create diffrent results.


#476
global int $cSprite[64];
global int $tSprite[144];
//5 animation frames, 64 pixels stored
global matrix $coinAn [5] [64];
//6 animation frames, 144 pixels stored
global matrix $turtleAn [6] [144];
global int $cT, $tT;
global string $shaders[], $cPlane[], $tPlane[];

//assign names to new palette

$shaders = {"red","orange", "yellow", "green", "blue", "purple", "brown", "black", "white", "grey", "trans", "hilite"};

//assign rgba values to the new palette

float $r[] = {float(1),(1.0),(1.0),(0.0),(0.0),(0.5),(0.2),(0.0 ),(1.0),(0.5),(0.5),(1.0)};
float $g[] = {float(0),(0.5),(1.0),(1.0),(0.0),(0.0),(0.3),(0.0 ),(1.0),(0.5),(0.5),(1.0)};
float $b[] = {float(0),(0.0),(0.0),(0.0),(1.0),(1.0),(0.1),(0.0 ),(1.0),(0.5),(0.5),(1.0)};
float $a[] = {float(0),(0.0),(0.0),(0.0),(0.0),(0.0),(0.0),(0.0 ),(0.0),(0.0),(1.0),(0.0)};

//create the shaders 

$i = 0;
for ($one in $shaders)
{
shadingNode -n $one -asShader lambert;
sets -renderable true -noSurfaceShader true -empty -name ($one + "SG");
connectAttr -f ($one + ".outColor") ($one + "SG.surfaceShader");
setAttr ($one+".colorR") ($r[$i]) ;
setAttr ($one+".colorG") ($g[$i]) ;
setAttr ($one+".colorB") ($b[$i]) ;
addAttr -keyable true -ln "index" -at long -dv ($i) $one;
for ($rgb in {"R","G","B"}){
setAttr ($one+".transparency"+$rgb) ($a[$i]) ;
}
$i++ ;
}
//create an 8 x 8 sprite as a polyPlane

$cPlane = `polyPlane -ch on -o on -w 8 -h 8 -sw 8 -sh 8 -cuv 2 -n "coinPlane"`;
move 0 4 0;
rotate -x -90;
$tPlane = `polyPlane -ch on -o on -w 12 -h 12 -sw 12 -sh 12 -cuv 2 -n "turtlePlane"`;
move 10 4 0;
rotate -x -90;

//the default animation cycles 

$coinAn = << 10, 10, 11, 2, 2, 1, 10, 10, 10, 11, 2, 1, 2, 2, 1, 10, 10, 2, 2, 2, 1, 2, 1, 10, 10, 2, 2, 2, 1, 2, 1, 10, 10, 2, 2, 2, 1, 2, 1, 10, 10, 2, 2, 2, 1, 2, 1, 10, 10, 2, 2, 1, 2, 2, 1, 10, 10, 10, 2, 2, 2, 1, 10, 10;
10, 10, 10, 2, 1, 10, 10, 10, 10, 10, 2, 2, 2, 1, 10, 10, 10, 10, 2, 1, 2, 1, 10, 10, 10, 10, 2, 1, 2, 1, 10, 10, 10, 10, 2, 1, 2, 1, 10, 10, 10, 10, 2, 1, 2, 1, 10, 10, 10, 10, 2, 2, 2, 1, 10, 10, 10, 10, 10, 2, 1, 10, 10, 10;
10, 10, 10, 2, 2, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 10, 2, 2, 10, 10, 10;
10, 10, 10, 11, 2, 10, 10, 10, 10, 10, 11, 2, 2, 2, 10, 10, 10, 10, 11, 2, 11, 2, 10, 10, 10, 10, 11, 2, 11, 2, 10, 10, 10, 10, 11, 2, 11, 2, 10, 10, 10, 10, 11, 2, 11, 2, 10, 10, 10, 10, 11, 2, 2, 2, 10, 10, 10, 10, 10, 11, 2, 10, 10, 10;
10, 10, 8, 2, 2, 2, 10, 10, 10, 8, 2, 2, 8, 2, 2, 10, 10, 8, 2, 1, 2, 8, 2, 10, 10, 8, 2, 1, 2, 8, 2, 10, 10, 8, 2, 1, 2, 8, 2, 10, 10, 8, 2, 1, 2, 8, 2, 10, 10, 8, 2, 2, 1, 2, 2, 10, 10, 10, 8, 2, 2, 2, 10, 10>>;

$turtleAn = << 10, 10, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 3, 3, 10, 10, 1, 8, 8, 1, 10, 10, 10, 3, 11, 6, 3, 10, 1, 8, 7, 1, 10, 10, 3, 11, 11, 6, 6, 3, 1, 8, 7, 1, 1, 10, 3, 11, 6, 6, 6, 3, 1, 1, 1, 1, 1, 10, 3, 6, 6, 6, 6, 6, 3, 1, 8, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 0, 10, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 10, 10, 7, 7, 6, 6, 6, 7, 7, 7, 7, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10;
   10, 10, 10, 10, 10, 10, 10, 10, 8, 8, 10, 10, 10, 10, 10, 3, 3, 10, 10, 1, 8, 8, 1, 10, 10, 10, 3, 11, 6, 3, 10, 1, 8, 7, 1, 10, 10, 3, 11, 11, 6, 6, 3, 1, 8, 7, 1, 1, 10, 3, 11, 6, 6, 6, 3, 1, 1, 1, 1, 1, 10, 3, 6, 6, 6, 6, 6, 3, 1, 8, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 0, 10, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 10, 10, 7, 7, 6, 6, 6, 7, 7, 7, 7, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10;
   10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 3, 3, 10, 10, 10, 8, 8, 10, 10, 10, 10, 3, 11, 6, 3, 10, 1, 8, 11, 1, 10, 10, 3, 11, 11, 6, 6, 3, 1, 8, 7, 1, 1, 10, 3, 11, 6, 6, 6, 3, 1, 11, 7, 1, 1, 10, 3, 6, 6, 6, 6, 6, 3, 1, 8, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 0, 10, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 10, 10, 7, 7, 6, 6, 7, 7, 7, 7, 10, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10, 10;
   10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 3, 3, 10, 10, 10, 8, 8, 10, 10, 10, 10, 3, 11, 6, 3, 10, 1, 8, 11, 1, 10, 10, 3, 11, 11, 6, 6, 3, 1, 8, 7, 1, 1, 10, 3, 11, 6, 6, 6, 3, 1, 11, 7, 1, 1, 10, 3, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 0, 10, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 10, 10, 7, 7, 6, 6, 7, 7, 7, 7, 10, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10, 10;
   10, 10, 10, 3, 3, 10, 10, 10, 11, 11, 10, 10, 10, 10, 3, 11, 6, 3, 10, 1, 8, 8, 1, 10, 10, 3, 11, 11, 6, 6, 3, 1, 8, 7, 1, 1, 10, 3, 11, 6, 6, 6, 3, 1, 8, 7, 1, 1, 10, 3, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 0, 10, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 10, 10, 7, 6, 6, 7, 7, 7, 7, 6, 3, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10;
   10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 10, 10, 10, 10, 10, 3, 3, 10, 10, 1, 8, 8, 1, 10, 10, 10, 3, 11, 6, 3, 10, 1, 8, 7, 1, 1, 10, 3, 11, 8, 6, 6, 3, 1, 8, 7, 1, 1, 10, 3, 8, 6, 6, 6, 6, 3, 1, 1, 1, 1, 10, 3, 6, 6, 6, 6, 6, 3, 1, 0, 1, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 1, 3, 6, 6, 6, 6, 6, 6, 3, 1, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 6, 3, 1, 10, 10, 3, 6, 6, 6, 6, 6, 6, 6, 3, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 6, 3, 10, 10, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 10, 10>>;

//save the animation frame 

proc saveFrame(){
int $getIndex;
global string $cPlane[], $tPlane[];
global matrix $turtleAn [6] [144];
global matrix $coinAn [5] [64]; 
for ($i=0;$i<144;$i++){
select -r ($tPlane[0]+".f["+$i+"]");
hyperShade -smn;
$obj = `ls - sl`;
$getIndex = `getAttr ($obj[0]+".index")`;
$turtleAn [3] [$i] = $getIndex;
}
}

global proc animGo(){ 
global string $shaders[];
global string $sPlane[];
global string $tPlane[], $cPlane[];
global int $cSprite[], $tSprite[];
global matrix $coinAn [5] [64];
global matrix $turtleAn [6] [144];
global int $cT, $tT, $i;
if (timerquery() > 0.05) {
if ($cT > 4) $cT = 0;
if ($tT > 5) $tT=0;
for ($i=0;$i<64;$i++){
$cSprite[$i] = $coinAn [$cT] [$i];
}
for ($it=0;$it<144;$it++){
$tSprite[$it] = $turtleAn [$tT] [$it];
}
for ($i=0;$i<(size($cSprite));$i++){
sets -e -forceElement ($shaders[($cSprite[$i])]+"SG") ($cPlane[0]+".f["+$i+"]");
}
for ($it=0;$it<(size($tSprite));$it++){
sets -e -forceElement ($shaders[($tSprite[$it])]+"SG") ($tPlane[0]+".f["+$it+"]");
}
$cT++;
$tT++;
timerstart;
}
}

global proc timerstart()
{
global float $GstartTime;
$GstartTime = `timerX`;
}
global proc float timerquery()
{
global float $GstartTime;
return (`timerX -startTime $GstartTime`);
}

global proc animate()
{
global int $anIndex;
    if ($anIndex == 0)
    $anIndex = -1;
    if (!`scriptJob -ex $anIndex`)
    {
    $anIndex = `scriptJob -kws -e idle animGo`;
    }else{
    scriptJob -k $anIndex -f;
    }
}


// animate;

#477

Nice one Brentorama.

Watch this :
[VIMEO]100258372[/VIMEO]

:stuck_out_tongue:


#478

Well, naturally :wink:


#479

If anyone wants a select by angle script instead of the confusing consrtraings menu; This may require Maya 2015 and onwards;

global proc selectByAngle()
{
	polySelectConstraint -m 2;

	string $win = `window -title "Select By Angle" -tbm 0`;
	rowLayout -nc 2; 
	$command = ("deleteUI " + $win);

		intSliderGrp -label "Angle" -field true
			-fieldMinValue 0 -fieldMaxValue 180
			-minValue 0 -maxValue 180 -value 0
			-cc "polySelectConstraint -ap 1 -at #1";
		button -label "Quit and Reset" -command ($command+";resetPolySelectConstraint");

	showWindow;
}

#480

So this is the Nice Rice game - a candyBox style game with the workings of my ascii map editor. On the left you can see the entire world map. On the right you can see the “Visibility” map which gets updated as the player moves around. On the bottom is the result, which will be what the player sees.