For in UnrealScript

class ForExample extends Object;

function Main()
{
    local int i, j, n;

    // The most basic type, with a single condition.
    i = 1;
    while (i <= 3)
    {
        `log(i);
        i = i + 1;
    }

    // A classic initial/condition/after for loop.
    for (j = 0; j < 3; j++)
    {
        `log(j);
    }

    // UnrealScript doesn't have a direct equivalent to Go's range over integers,
    // but we can simulate it with a for loop.
    for (i = 0; i < 3; i++)
    {
        `log("range" @ i);
    }

    // A loop that will continue until explicitly broken.
    while (true)
    {
        `log("loop");
        break;
    }

    // You can also continue to the next iteration of the loop.
    for (n = 0; n < 6; n++)
    {
        if (n % 2 == 0)
        {
            continue;
        }
        `log(n);
    }
}

UnrealScript provides several looping constructs. Here are some basic types of loops.

The most basic type is a while loop with a single condition. This is equivalent to the first example in the original code.

A classic for loop is available in UnrealScript, similar to many other languages. It includes an initializer, condition, and increment statement.

UnrealScript doesn’t have a direct equivalent to Go’s range over integers. However, we can simulate this behavior using a standard for loop.

To create an infinite loop that can be broken out of, we use a while(true) loop. This can be exited using a break statement.

The continue statement is also available in UnrealScript, allowing you to skip to the next iteration of a loop.

Note that UnrealScript uses the backtick () symbol for logging, which is similar to Go's fmt.Println(). Also, UnrealScript uses the @` symbol for string concatenation.

To run this code in Unreal Engine:

  1. Create a new UnrealScript file named ForExample.uc in your project’s Classes folder.
  2. Paste the above code into the file.
  3. Compile the script in the Unreal Editor.
  4. You can then call the Main() function from other parts of your game code or set it up to run when the game starts.

Remember that UnrealScript is an older language and has been largely replaced by C++ and Blueprint in modern Unreal Engine development. The exact method of execution may vary depending on your specific Unreal Engine setup.