-
Notifications
You must be signed in to change notification settings - Fork 27
Functions
Most function names in OverPy follow these rules:
- The function name is camelCased:
Create Effect
->createEffect
. - Functions that take a player, or player array, as the first argument are member functions:
Teleport(Event Player, Vector(1,2,3))
->eventPlayer.teleport(vect(1,2,3))
.
Exceptions arekill()
,heal()
anddamage()
. - Event-related variables are keywords:
Event Was Critical Hit
->eventWasCriticalHit
.
They have a special color in the VS Code extension. - Function names are sometimes modified to better reflect how they would be in an actual programming language:
Control Mode Scoring Percentage
->getControlScorePercentage()
,Count Of(array)
->len(array)
. - Functions to get constants such as
Hero
,Map
orGamemode
are replaced by enums:Hero(Ana)
->Hero.ANA
.
It is advised to rely on the VS Code autocompletion. If you cannot find a function name, decompile the workshop function to get the OverPy name.
The list of functions that just have the name change applied are here.
Below are the functions that have a special syntax. The italic words indicate arguments; these should be replaced by the appropriate arguments.
OverPy follows the same operator precedence as python's.
Workshop function | OverPy representation |
---|---|
And(op1, op2) |
op1 and op2 |
Or(op1, op2) |
op1 or op2 |
Not(op1) |
not op1 |
Compare(op1, operator, op2) |
op1 operator op2 |
Add(op1, op2) |
op1 + op2 |
Subtract(op1, op2) |
op1 - op2 |
Multiply(op1, op2) |
op1 * op2 |
Divide(op1, op2) |
op1 / op2 |
Modulo(op1, op2) |
op1 % op2 |
Raise To Power(op1, op2) |
op1 ** op2 |
If-Then-Else(condition, op1, op2) |
op1 if condition else op2 |
Workshop function | OverPy representation |
---|---|
Global Variable(variable) |
variable |
Set Global Variable(variable, value) |
variable = value |
Modify Global Variable(variable, Add, value) |
variable += value 1
|
Modify Global Variable(variable, Append To Array, value) |
variable.append(value) |
Modify Global Variable(variable, Divide, value) |
variable /= value |
Modify Global Variable(variable, Max, value) |
variable max= value |
Modify Global Variable(variable, Min, value) |
variable min= value |
Modify Global Variable(variable, Modulo, value) |
variable %= value |
Modify Global Variable(variable, Raise To Power, value) |
variable **= value |
Modify Global Variable(variable, Remove From Array By Index, value) |
del variable[value] |
Modify Global Variable(variable, Remove From Array By Value, value) |
variable.remove(value) 2
|
Modify Global Variable(variable, Subtract, value) |
variable -= value 3
|
1 variable++
can be used if value
is 1.
2 Unlike Python, this removes all occurrences of the value in the specified array.
3 variable--
can be used if value
is 1.
For player variables, player.
is prepended to the variable. For array indexes, [index]
is appended to the variable. For example:
Workshop function | OverPy representation |
---|---|
Player Variable(player, variable) |
player.variable |
Set Global Variable At Index(variable, index, value) |
variable[index] = value |
Set Player Variable(player, variable, value) |
player.variable = value |
Set Player Variable At Index(player, variable, index, value) |
player.variable[index] = value |
Modify Global Variable At Index(variable, index, Add, value) |
variable[index] += value |
Modify Player Variable(player, variable, Add, value) |
player.variable += value |
Modify Player Variable At Index(player, variable, index, Add, value) |
player.variable[index] += value |
Workshop function | OverPy representation |
---|---|
Append To Array(array, value) |
array.concat(value) |
Remove From Array(array, value) |
array.exclude(value) |
Index Of Array Value(array, value) |
array.index(value) |
Empty Array |
[] |
Sorted Array(array, valueRankFunction) |
sorted(array, lambda elem: valueRankFunction) 1
|
Mapped Array(array, mappingFunction) |
[mappingFunction for elem in array] 1 3
|
Filtered Array(array, condition) |
[elem for elem in array if condition] 1
|
Is True For All(array, condition) |
all([condition for elem in array]) 1
|
Is True For Any(array, condition) |
any([condition for elem in array]) 1
|
Array Slice(array, start, length) |
array.slice(start, length) 2
|
Array Contains(array, value) |
value in array |
Value In Array(array, index) |
array[index] |
First Of(array) |
array[0] |
Last Of(array) |
array.last() |
1 elem
represents the Current Array Element
workshop value. It must be given a name (usually i
or x
).
2 Python's slice syntax [start:end]
is not used because the workshop slice is start/length instead of start/end.
3 A mapped array containing a filtered array can be combined using Python's syntax: Mapped Array(Filtered Array(A, Current Array Element == B), Current Array Element + 2)
-> [i+2 for i in A if i == B]
.
The Current Array Index
can be specified with another parameter, that is placed after Current Array Element
, separated by a comma. For example:
[elem+index for elem, index in array]
Or, to reverse an array:
sorted(array, lambda _, i: -i)
Note that the Current Array Element
is specified by an underscore, as it is not used.
Workshop function | OverPy representation |
---|---|
Skip(constant) |
goto label 1
|
Skip(variable) |
goto loc+variable |
Skip If(constant, condition) |
if condition: goto label 1
|
Skip If(variable, condition) |
if condition: goto loc+variable
|
Abort |
return |
Abort If(condition) |
if condition: return
|
Abort If Condition Is False |
if not RULE_CONDITION: return
|
Abort If Condition Is True |
if RULE_CONDITION: return
|
If(condition) |
if condition: |
Else If(condition) |
elif condition: |
Else |
else: |
For Global Variable(variable, start, stop, step) |
for variable in range(start, stop, step): |
For Player Variable(player, variable, start, stop, step) |
for player.variable in range(start, stop, step): |
End |
unindent |
Loop |
while true 2or goto RULE_START
|
Loop If(condition) |
while condition 2or if condition: goto RULE_START
|
Loop If Condition Is False |
while not RULE_CONDITION 2or if not RULE_CONDITION: goto RULE_START
|
Loop If Condition Is True |
while RULE_CONDITION 2or if RULE_CONDITION: goto RULE_START
|
While(condition) |
while condition: |
1 label
represents the label that the goto
instruction will jump to. Labels are an alphanumeric word followed by a colon, such as lbl_0:
. They can only be placed after the goto
statement, in the same rule.
2 The while
instruction is only used if not within another block; in that case, a do:
instruction must be added at the beginning of the rule, with the necessary indentation. Note that the while
instruction has no colon at the end.
Workshop function | OverPy representation |
---|---|
Raycast Hit Normal(start, end, include, exclude, includePlayerObjects) |
raycast(start, end, include, exclude, includePlayersObjects).getNormal() |
Raycast Hit Player(start, end, include, exclude, includePlayerObjects) |
raycast(start, end, include, exclude, includePlayersObjects).getPlayerHit() |
Raycast Hit Position(start, end, include, exclude, includePlayerObjects) |
raycast(start, end, include, exclude, includePlayersObjects).getHitPosition() |
Workshop function | OverPy representation |
---|---|
Chase Global Variable At Rate(variable, destination, rate, reevaluation) |
chase(variable, destination, rate=rate, reevaluation) |
Chase Global Variable Over Time(variable, destination, duration, reevaluation) |
chase(variable, destination, duration=duration, reevaluation) |
Chase Player Variable At Rate(player, variable, destination, rate, reevaluation) |
chase(player.variable, destination, rate=rate, reevaluation) |
Chase Player Variable Over Time(player, variable, destination, duration, reevaluation) |
chase(player.variable, destination, duration=duration, reevaluation) |
Stop Chasing Global Variable(variable) |
stopChasingVariable(variable) |
Stop Chasing Player Variable(player, variable) |
stopChasingVariable(player.variable) |
Workshop function | OverPy representation |
---|---|
Round To Integer(value, Up) |
ceil(value) |
Round To Integer(value, Down) |
floor(value) |
Round To Integer(value, To Nearest) |
round(value) |
Workshop function | OverPy representation |
---|---|
X Component Of(vector) |
vector.x |
Y Component Of(vector) |
vector.y |
Z Component Of(vector) |
vector.z |
Workshop function | OverPy representation |
---|---|
Call Subroutine(subroutine) |
subroutine() |
Start Rule(subroutine, behavior) |
async(subroutine, behavior) |
Workshop function | OverPy representation |
---|---|
Custom String("{0}abc{1}", arg1, arg2) |
"{0}abc{1}".format(arg1, arg2) |
String("{0}abc{1}", arg1, arg2) |
l"{0}abc{1}".format(arg1, arg2) |
String Slice(str, start, length) |
str.substring(start, length) |
Workshop function | OverPy representation |
---|---|
Workshop Setting Integer(category, name, default, min, max, sortOrder) |
createWorkshopSetting(int[min:max], category, name, default, sortOrder) |
Workshop Setting Real(category, name, default, min, max, sortOrder) |
createWorkshopSetting(float[min:max], category, name, default, sortOrder) |
Workshop Setting Toggle(category, name, default, sortOrder) |
createWorkshopSetting(bool, category, name, default, sortOrder) |
Workshop Setting Combo(category, name, Array(opt1, opt2), default, sortOrder) |
createWorkshopSetting(enum[opt1, opt2], category, name, default, sortOrder) |
Workshop Setting Hero(category, name, default, sortOrder) |
createWorkshopSetting(Hero, category, name, default, sortOrder) |
Types such as unsigned int
(0 to infinity), signed int
(-infinity to 0), or int
(-infinity to +infinity) can also be used (same for float
).
Workshop function | OverPy representation |
---|---|
Wait(time, behavior) |
wait(time, behavior) |
Wait(time, Ignore Condition) |
wait(time) |
Wait(0.016, Ignore Condition) |
wait() |
Create HUD Text(..., header, subheader, text, ...) |
hudText(..., header, subheader, text, ...) |
Create HUD Text(..., header, null, null, ...) |
hudHeader(..., header, ...) |
Create HUD Text(..., null, subheader, null, ...) |
hudSubheader(..., subheader, ...) |
Create HUD Text(..., null, null, text, ...) |
hudSubtext(..., text, ...) |
OverPy:
- Overview
- General Usage
- General Syntax
- Rules and Events
- Functions
- Control Flow
- Strings
- Compiler Options
- Custom game settings
- Preprocessing
- Advanced Constructs
Various stuff:
Development:
- [Coming soon]