OSTW v1.2 - Class inheritance!
OSTW v1.2
Syntax changes
Scripts will need to be updated to match the new syntax.
New Keywords
Variables or methods with these names will need to be changed.
voidprotectedoverridebasevirtualswitchcasedefaultiscontinuebreakrefasyncabstract(currently unused)
These are no longer keywords:
methodmacro
New method syntax
The method keyword is removed. Instead, use void, define, or the type of the value that is returned.
// Old:
method myMethod() ...
// New:
void myMethod() ... // void
define myMethod() ... // returns valueNew macro syntax
// Old:
macro paramMacro(): ...
macro paramVar: ...
// New:
define paramMacro(): ...
define paramVar: ...Modify Variable and Chase Variable
Methods that reference a variable and take a player as a parameter now have the variable and player parameter combined, keeping it consistent with variable setting.
// Old:
ModifyVariable(playerVar, player, Operation.AppendToArray, 1);
// New:
ModifyVariable(player.playerVar, Operation.AppendToArray, 1);CreateHudText
Now uses the HudTextRev type instead of the StringRev type for the Reevaluation parameter.
Loops
for, foreach, and while no longer have a 16 millisecond delay between each iteration.
Class Inheritance
OSTW now supports extending classes. Child classes can extend or change parent class functions.
Parameters will accept child classes if the child class extends the parameter type.
Switch
A switch has sections of code, only one of which will be chosen based off of the condition and the section's case. Fallthrough will occur in OSTW, so be sure to use break statements to break out of the case.
Continue and Break
continue can be used to restart at the beginning of the loop. break can be used to exit a loop.
Lobby Settings
Lobby settings can now be changed using a json file. Lobby, hero roster, hero, map, and mode settings can all be changed. The settings will output alongside the workshop code.
Files called customGameSettings.json will have the schema used to create the settings json. Import the json as you would with a script file.
ref attribute
By default, parameters are stored as another variable. Using the ref parameter, the input expression is used directly. This makes it possible for parameters to be strings!
Workshop constant types like Color and Effect have the ref attribute by default. Depending on the scenario, this can reduce the number of elements in the output.
Vector type
The Vector struct gives an alternate syntax for doing vector operations.
The vector struct has the following members:
X: The X component of the vector.Y: The Y component of the vector.Z: The Z component of the vector.VerticalAngle: The vertical angle of the vector.HorizontalAngle: The horizontal angle of the vector.Normalized(): The unit-length normalization of the vector.DistanceTo(other): The distance between 2 vectors.CrossProduct(other): The cross product of the specified vector.AsLocalVector(relativePlayer, transformation): The vector in local coordinates corresponding to the vector in world coordinates.AsWorldVector(relativePlayer, transformation): The vector in world coordinates corresponding to the vector in local coordinates.ClosestPlayer(team): The closest player to the vector, optionally restricted by team.FarthestPlayer(team): The farthest player from the vector, optionally restricted by team.DirectionTowards(other): The unit-length direction vector to another vector.Towards(other): The displacement vector from the vector to another.IsInLineOfSight(other, barriers)Whether the vector has line of sight with the specified vector.
Math operations work on the Vector struct as normal.
Auto-for
The new for variant uses the workshop's For() action rather than a while loop.
When the for runs, the variable will be set to the initial start expression. After each iteration, the step expression is added to the variable. Iteration will stop when the variable exceeds end.
It will have less output elements than a normal for.
However, this for variant requires an entire variable. Variables in the extended collection will not work. Additional conditions also do not work, you can only input a number
where the variable will stop counting.
// Creates a variable that can only be accessed inside the for.
for (define = start; end; step) { ... }
// Uses an already existing variable.
for (var = start; end; step) { ... }Subroutines
Subroutines are created by adding a string after the parameters of a defined method. The string will be the rule name of the subroutine.
void MySubroutine() "My Subroutine!" { ... }Rather than inserting the actions of the method into the caller's action set, it will call the subroutine. This can reduce the number of elements in the output since the method's actions won't need to be reimplemented every call. Multiple calls to the same subroutine at the same time may cause conflicts. This however will not be a problem if there are no waits inside the subroutine or any other subroutine that it calls.
Asynchronous subroutine calls can be done by prefixing the method call with the async keyword.
async MySubroutine(); // If the subroutine is already executing, it will be restarted.
async! MySubroutine(); // Adding ! will do nothing if it is already executing.OSTW's implementation of subroutines is not final and is still being worked on. Planned features are class constructor subroutines and improved recursive capabilities.
New Workshop Elements
Actions
EnableInspectorRecordingDisableInspectorRecordingStartHealingModificationStopHealingModification
Values
EventWasHealthPackLastHealingModificationID
Constants
HealingModificationRevIfAlreadyExecutingHudTextRev
New Custom Methods
LinePlaneIntersection: Gets the point where a line intersects with an infinite plane.DoesLineIntersectSphere: Determines if a point intersects with a sphere.
Bug fixes and optimizations
- Static methods and variables work properly now.
- Fixed language server deadlock.
- Fixed exception when variable count exceeds 128.
- Updated the Pathmap class to work with the new class system.
- Added a syntax error for non-static workshop-constant variables.
- Fixed some bugs with renaming variables.
- Fixed signature help closing while typing methods.
- Fixed incorrect completion list after typing '.'.
- Fixed signature and type resolving inside methods in classes.
- Fixed type convert exception.
- Fixed some optimization bugs.
- Fixed
new Class()syntax highlighting. - Fixed casting to type arrays not working.
- Calling
returninside rules will abort rather than skip. - Optimized recursion.
- Optimized classes. Class components are no longer stored as multi-dimensional arrays.
- Inverse now uses
x*-1instead of0-xin order to support vectors. - Hid the following workshop methods.
AddSubtractMultiplyDivideModuloRaiseToPowerAndOrCompareTeamVarHeroVar
if,for,foreach, andwhileall use their respective workshop variants instead of skip and loop.forandforeachwill output using theWhile()action rather thanFor().
Use the alternateforsyntax to output using the workshop'sFor().
Modules
- Split
Debug Tools.delintoDebug Tools.delandDebug Camera.del. Debug Camera.delno longer spams the inspector using a single-action-freecam method.
VSCode extension
Codelens
View references or implementations of a method or class.
New settings
ostw.codelens.references: Determines if theReferencescode lens is visible.ostw.codelens.implements: Determines if theImplementscode lens is visible.
New command: ostw.virtualDocumentOutput "Create a panel for workshop code output."
Creates a virtual document for the workshop output. The document has syntax highlighting. The virtual document updates faster than vscode's output window, so use this if vscode's output has trouble updating.
Known Bugs
- Calling base methods from a deriving class doesn't work properly.
v1.2.1
- Fixed generating
.pathmapfiles. - Fixed calling an object member directly from
newwhen the class type does not exist throwing an exception. (new NonExistantClass().ClassMember)
v1.2.2
- Subroutines now work outside of classes. (Thanks @derwangler!)
- Fixed some pathfinding bugs.
- The Pathfind module now shows nodes/segments dynamically so the effect limit shouldn't be an issue anymore. New editor code:
SE2AG




