Miscellaneous - ItsDeltin/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".

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;
}