Code:
Variables:
# GDScript equivalent of VB.NET variables
var age: int = 0
var isComplete: bool = false
var str1: String = "morning"
const num: int = 2
Strings:
# GDScript equivalent of VB.NET string
var name: String = "John"
var age: int = 30
var result: String = "Hello, " + name + ". You are " + str(age) + " years old."
Classes:
# GDScript equivalent of VB.NET class
class_name MyClass extends SomeSuperClass:
var myProperty: int
func _init():
myProperty = 12
Methods:
# GDScript equivalent of VB.NET methods
func myMethod() -> bool:
return true
func methodWithParams(a: int, b: int) -> int:
return a + b
Varargs (Variable Arguments):
# GDScript equivalent of VB.NET varargs
func sum1(numbers: int...) -> int:
var total: int = 0
for number in numbers:
total += number
return total
var test: int = sum1(1, 2, 3)
print(test)
Lists (ArrayLists):
# GDScript equivalent of VB.NET lists
var dClasses: Array = [] # Initialize an empty array
var websites: Array = ["yotamarker", "livingrimoire"]
# Access element at index 0
print(websites[0]) # Outputs: "yotamarker"
Dictionaries:
# GDScript equivalent of VB.NET dictionary
var dic1: Dictionary = {
"one": 1,
"two": 2
}
for key in dic1.keys():
print(key + str(dic1[key]))
Conditional Statements (If):
# GDScript equivalent of VB.NET if statement
if true:
print("True")
else:
print("False")