Author Topic: Iban Explains it All  (Read 24222 times)

So that when the loop ends of its own accord, the action will happen once, only once, and only after the loop terminates.
The answer to this is so amazingly simple you're going to hit yourself for overthinking this.

Code: [Select]
function doSomething()
{
for(%a = 0; %a < 10; %a++)
{
echo("Loop Iteration #" @ %a);
}

doSomethingElse(); // Post-Loop Function Call
}

Just put the function call after the loop.


The whole cat/datablock comparison really helped me understand how datablocks work better. :D
:3

The answer to this is so amazingly simple you're going to hit yourself for overthinking this.

Code: [Select]
function doSomething()
{
for(%a = 0; %a < 10; %a++)
{
echo("Loop Iteration #" @ %a);
}

doSomethingElse(); // Post-Loop Function Call
}

Just put the function call after the loop.
Hmmm.

I did that, and it appears that you can only do a function call after the loop, because an echo statement feeds back syntax errors.

What are you talking about?

Post the actual script you're doing something terribly, terribly wrong.

What are you talking about?

Post the actual script you're doing something terribly, terribly wrong.
Code: [Select]
function GenerateTerrain(%dim1,%dim2)
{
for(%i=0;%i<%dim1;%i++)
{
ServerCmdPlantBrick(5975);
ServerCmdSuperShiftBrick(5975, 1, 0, 0);
}

echo("whatever words" SPC %i)
}

Dude, there's no semicolon after the echo.




Yes, that would be a semicolon.
It's also called a semikolon in Swedish.

For the motherland, indeed!

These are really well written and not too hard to understand.  Nice job.
Manty, make me an avatar :(

Manty, make me an avatar :(
This isn't really the topic to ask about that.

Anyhow, looks interesting, maybe i can learn a thing or two from it. :D

can you use "and" or "or" inside a "if" statement like you can use in php?

 ALSO: when using notepad++ which language is closest to torque?
« Last Edit: March 04, 2011, 12:43:20 PM by Anybody »

can you use "and" or "or" inside a "if" statement like you can use in php?
Yes, but be very careful with your order of operations.

if(%a && %b || %c)

I'm pretty sure this equates to

if( ( %a && %b) || %c)

so if you wanted it to be

if(%a && (%b || %c) )

You'd have to state that explicitly. I always find it better to be safe, rather than sorry, with complex ifs, so I use a liberal amount of parenthesis.

(Unless you're talking about the actual "AND" and "OR" operators, in which case, no lol).

ALSO: when using notepad++ which language is closest to torque?
C# (hence .cs file extensions).
« Last Edit: March 04, 2011, 12:53:48 PM by Iban »

Dude, there's no semicolon after the echo.

I just hit myself.