PDA

View Full Version : Expression doesn't want to work.


CurtJ
06-27-2008, 08:59 AM
Just going through an old (2006) tutorial and I reach a point where I have to write some code. Each time I put it in the expression editor I get several syntax errors. I've double checked the code and even downloaded the exact same code as used on the tutorial and I still get the error, yet on the tutorial an expression is generated instead of errors.

Here's the code:
float $resX = petrol.resolutionW;
float $resY = petrol.resolutionH;

int $row, $column

//loop through rows and columns

for ($row = 0; $row < $resX; $row++){
for ($column = 0; $column < $resY; $column++) {
float $heat[] = `getFluidAttr -at "temperature" -xi $row -yi $column petrol`;
float $petrolDensity[] = `getFluidAttr -at "density" -xi $row -yi $column petrol`;
if($heat[0] > 0 && $petrolDensity[0] > 0){
setFluidAttr -at "density" -xi $row -yi 0 -zi $column -fv 1 fire;
setFluidAttr -at "fuel" -xi $row -yi 0 -zi $column -fv 4 fire;
setFluidAttr -at "temperature" -xi $row -yi 0 -zi $column -fv 2 fire;
}
}
}


And here's the error I get:
expression -s "float $resX = petrol.resolutionW;\r\nfloat $resY = petrol.resolutionH;\r\n\r\nint $row, $column\r\n\r\n//loop through rows and columns\r\n\r\nfor ($row = 0; $row < $resX; $row++){\r\n\tfor ($column = 0; $column < $resY; $column++) {\t\r\n\tfloat $heat[] = `getFluidAttr -at \"temperature\" -xi $row -yi $column petrol`;\t\r\n\tfloat $petrolDensity[] = `getFluidAttr -at \"density\" -xi $row -yi $column petrol`;\t\r\n\tif($heat[0] > 0 && $petrolDensity[0] > 0){\r\n\t\tsetFluidAttr -at \"density\" -xi $row -yi 0 -zi $column -fv 1 fire;\r\n\t\tsetFluidAttr -at \"fuel\" -xi $row -yi 0 -zi $column -fv 4 fire;\r\n\t\tsetFluidAttr -at \"temperature\" -xi $row -yi 0 -zi $column -fv 2 fire;\r\n\t\t}\r\n\t}\r\n}\r" -o "" -ae 1 -uc all ;

// Error: for ($row = 0; $row < $resX; $row++){
//
// Error: Syntax error //
// Error: for ($row = 0; $row < $resX; $row++){
//
// Error: Syntax error //
// Error: for ($row = 0; $row < $resX; $row++){
//
// Error: Syntax error //
// Error: for ($column = 0; $column < $resY; $column++) {
//
// Error: Syntax error //
// Error: for ($column = 0; $column < $resY; $column++) {
//
// Error: Syntax error //
// Error: if($heat[0] > 0 && $petrolDensity[0] > 0){
//
// Error: "$heat" is an undeclared variable. //
// Error: }; //
// Error: Syntax error //
// Error: } //
// Error: Syntax error //

I've never really used MEL to this extent before - am I missing something?

NaughtyNathan
06-27-2008, 09:27 AM
you need a ; at the "finishing point" of every "line" of code and there's no ; after the int $row, $column line. There should be. Everything else looks ok.

:nathaN

CurtJ
06-27-2008, 09:35 AM
Aha!

That's done the trick - blimey, I must have looked over that about a dozen times and didn't spot it. And of course, it is there on the original code.

That's what you get for staring at code at 1am I suppose.


Thanks nathan - appreciated.

CGTalk Moderation
06-27-2008, 09:35 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.