Skip to content

General syntax

Zezombye edited this page Aug 23, 2020 · 16 revisions

OverPy takes its syntax and most function names from Python. However, take note that OverPy is NOT Python, both in syntax and behavior: there are some slight differences and pitfalls.

Syntax-wise, the following has been changed from Python:

  • The True/False/None keywords have been replaced by true/false/null.
  • The ++ and -- postfix operators have been added (same effect as +=1 and -=1).
  • The "do: ... while x" loop has been added.

Behavior-wise, knowledge of the workshop is helpful to know what is possible and what isn't. Here are some of the things that change from Python:

  • String concatenation is not done using the "+" operator, but using the format function.
  • The range() function is only usable in a for loop, and its behavior changes a little from Python. For example, take the following code:
A = [10,20,30]
B = []
for A in range(len(A)):
    B.append(A)

B will be [0,1,2] in Python, however in the workshop the for loop won't even run. (though you shouldn't do this kind of code in the first place)

Other than that, the syntax is pretty much the same as python:

  • Comments start with #; multi-line comments are C-like comments /*comment*/.
  • Blocks are delimited by indentation. OverPy solves the tabs vs spaces problem by hardcoding tabs as 4 spaces.
  • Preprocessing directives and compiler options start with #!.

Some keywords have been added to better suit the workshop. Declaring global variables is done by the globalvar keyword, such as:

globalvar myVar 100

This will declare a global variable with name myVar and index of 100. The index can be omitted; if omitted, OverPy will automatically assign a free index. Default variable names (A-Z, AA-DX) don't need to be declared.

Declaring player variables and subroutines is done in a similar way with the playervar and subroutine keywords.

Declaring lobby settings is done by the settings keyword, which must be followed by an object. It is recommended to edit the settings within Overwatch, then decompile it, to get the necessary syntax.

As explaining the whole syntax would be too verbose, it is recommended that you decompile one of your existing gamemodes, to get a feel of how the language is structured.