Basic syntax - levkopo/VenusScript GitHub Wiki
VenusScript has a simple syntax. Lines of code are written on a new line without semicolons, which makes writing code easier.
Example:
print("Hello World!")
Variable types
Type | Description |
---|---|
any | Combines all types |
array | Array value |
bool | Boolean value |
decimal | Double value |
ref | Function reference |
int | Number value |
string | String value |
void | Nobody (only for functions) |
map | Table (Map) value |
Variable declaration
name = value
Functions
Function having string and int parameters with string return type:
def func(string a, int b): string{
return a+b
}
Functions do not require anything to be returned. Therefore, if the code does not return a value, then the function will return null. Specify a void return type if you don't return anything. You can choose not to specify the return type. The parser will understand this and indicate the return type any. Example:
def func(){
return "string value"
}
Comments
Only single-line comments work in VenusScript, but block comments may appear soon
#This is single-line comment
Conditional expressions
if a==b {
println("Nope...")
}else {
println("Yeah!")
}
Get and verify variable type
a = "I <3 COMPUTER SCIENCE!"
println(*a) #Print "string"
println((*a) == (*string)) #Print true
for
loop
# 0..10
for i in (0, 10) {
println(i)
}
# 16, 18, 20, 22, 24
for i in (16, 24, i + 2) {
println("i = " + i)
}
# Array
array = [1, 5, 3, 5, 6]
for i in array {
print(i + " ")
}
while
loop
i = 0
while i < 3 {
println("i = " + i)
i = i + 1
}