Overwatch Workshop Superset - ItsDeltin/Overwatch-Script-To-Workshop GitHub Wiki

OSTW supports mixing in vanilla Workshop code (English only) directly next to existing OSTW code. However, the following rules must be observed to successfully utilize this feature in compilation:

  1. Vanilla variable declarations MUST precede any OSTW variable links (explained below).
  2. A rule MUST be entirely vanilla Workshop OR OSTW. Mixing the two syntaxes within the bounds of a rule will not work.

Linking

Variable Linking

OSTW code may link an OSTW variable to a vanilla variable declaration as follows:

variables
{
	player:
		0: checkpoint_reached
}

playervar Number checkpointIndex {'checkpoint_reached'};

The output will only contain one variable (checkpoint_reached).

Subroutine Linking

The following code will output a subroutine

void mySubroutine() 'Description of the OSTW subroutine': 'vanillaSubroutine'
{
	// ...
}

Example:

// Vanilla Overwatch Workshop Script
variables
{
	global:
		0: bot1
		1: bot2
}
// OSTW variable declaration. Note the link to the vanilla global variables
globalvar Player bot1 {'bot1'};
globalvar Player bot2 {'bot2'};

globalvar Number delay = WorkshopSettingReal("Settings", "Delay", 1, 0, 10, 0);

// Vanilla Workshop Rule
rule("Initialize bots")
{
	event
	{
		Ongoing - Global;
	}

	actions
	{
		Create Dummy Bot(Hero(Tracer), Team(Team 1), 1, Vector(0, 0, 0), Vector(0, 0, 0));
		Global.bot1 = Last Created Entity;
		Create Dummy Bot(Hero(Tracer), Team(Team 1), 2, Vector(0, 0, 0), Vector(0, 0, 0));
		Global.bot2 = Last Created Entity;
	}
}

// OSTW rule
rule: "When host player presses melee, kill bots within time period"
if (HostPlayer().IsButtonHeld(Button.Melee))
{
  Kill(bot1, null);
  Wait(delay, WaitBehavior.IgnoreCondition);
  Kill(bot2, null);
}

The above results in the following output:

variables
{
    global:
        0: bot1
        1: bot2
        2: delay
}

rule("Initial Global")
{

    event
    {
        Ongoing - Global;
    }

    // Action count: 1
    actions
    {
        Set Global Variable(delay, Workshop Setting Real(Custom String("Settings"), Custom String("Delay"), 1, 0, 10, 0));
    }
}

rule("When host player presses melee, kill bots within time period")
{

    event
    {
        Ongoing - Global;
    }

    conditions
    {
        Is Button Held(Host Player, Button(Melee)) == True;
    }

    // Action count: 3
    actions
    {
        Kill(Global Variable(bot1), Null);
        Wait(Global Variable(delay), Ignore Condition);
        Kill(Global Variable(bot2), Null);
    }
}

rule("Initialize bots")
{

    event
    {
        Ongoing - Global;
    }

    // Action count: 4
    actions
    {
        Create Dummy Bot(Hero(Tracer), All Teams, 1, Vector(0, 0, 0), Vector(0, 0, 0));
        Set Global Variable(bot1, Last Created Entity);
        Create Dummy Bot(Hero(Tracer), All Teams, 2, Vector(0, 0, 0), Vector(0, 0, 0));
        Set Global Variable(bot2, Last Created Entity);
    }
}