Miscellaneous - GrandeurHammers/Overwatch-Script-To-Workshop GitHub Wiki

Miscellaneous

Importing files

Importing files is vital for organizing any decently-sized projects. Files can be imported by adding an import statement to the top of your script.

import "Player Controller.del";

rule: "My rule"
...

You can import custom game settings the same way, simply by writing import "customGameSettings.json".

Modules can be imported by preceeding the filename with !.

Modules

  • Debug Camera.del
    • Voice line down to toggle start camera.
      Voice line left to teleport to the camera's position.

Ternary Conditionals

Ternary conditionals are defined with a condition, a consequent, and an alternative. If the condition evaluated to true, the consequent will be chosen. Otherwise, the alternative is chosen.

condition ? consequent : alternative

In the example below, numberOfBosses will equal 1 if there are less than 5 players, otherwise it will equal 2.

define numberOfBosses = NumberOfPlayers() < 5 ? 1 : 2;

Ternary conditionals do not create any actions, so they can be used in conditions.

Boolean operations

The operators && and || can be used to compare booleans.

If-else

if (condition)
{

}
else if (another_condition)
{

}
else
{

}

Switch

Switches are similiar to if statements. Switches in OSTW will fallthrough, so be sure to add a break.

switch (currentMode)
{
    case Mode.Waiting:
        SmallMessage(EventPlayer(), "Waiting for players, please wait.");
        break;

    case Mode.Playing:
        SmallMessage(EventPlayer(), "Game is currently ongoing, please wait.");
        break;
    
    case Mode.Ending:
        SmallMessage(EventPlayer(), "Next game is starting soon!");
        break;
}

Strings

Custom strings are declared like "My String", and localized strings are declared like @"hello".

Formatting strings are declared as <"My String: <0> <1>", expr0, expr1> and <@"Hello: <0> <1>", expr0, expr1>. While the workshop only supports 3 formats ({0}, {1}, and {2}) OSTW does not have a limit.

⚠️ **GitHub.com Fallback** ⚠️