← Back to 2D Structs
Array
⚠️ Experimental - Pre-Release
Array is a dynamic array type that can hold multiple values of the same type. Arrays are created using Array<Type> syntax.
Methods
new Array<Type>() → Array
Creates a new empty array.
var items = new Array<string>()var numbers = new Array<int>()Array.push(item: Type) / Array.append(item: Type)
Adds an item to the end of the array.
var items = new Array<string>()items.push("apple")items.append("banana")Array.insert(index: int, item: Type)
Inserts an item at the specified index.
var items = new Array<string>()items.push("apple")items.push("banana")items.insert(1, "orange") // Insert at index 1Array.remove(index: int)
Removes the item at the specified index.
Array.pop() → Type
Removes and returns the last item in the array.
Array.len() → int / Array.size() → int
Returns the number of items in the array.
var items = new Array<string>()
items.push("apple")
items.push("banana")
Console.print("Count: " + items.len()) // 2Usage Example
@script Inventory extends Node var items = new Array<string>() fn init() { items.push("sword") items.push("shield") items.push("potion") } fn add_item(item: string) { items.push(item) Console.print("Added: " + item) } fn remove_item(index: int) { items.remove(index) }