массив в GDScript
var array = [1,2,3,4]
print(array)
Crowded Chinchilla
var array = [1,2,3,4]
print(array)
//create an array like so:
var colors = ["red","blue","green"];
//you can loop through an array like this:
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
var colors = [ "red", "orange", "yellow", "green", "blue" ]; //Array
console.log(colors); //Should give the whole array
console.log(colors[0]); //should say "red"
console.log(colors[1]); //should say "orange"
console.log(colors[4]); //should say "blue"
colors[4] = "dark blue" //changes "blue" value to "dark blue"
console.log(colors[4]); //should say "dark blue"
//I hope this helped :)
var array = ["One", 2, 3, "Four"]
print(array[0]) # One.
print(array[2]) # 3.
print(array[-1]) # Four.
array[2] = "Three"
print(array[-2]) # Three.
extends Node2D
func _ready():
# Ways to create an array instance
var a = Array()
var b = []
var c = ["a","b","c"]
# Add some items to array 'a'
a.append("Item 1")
a.append("Item 2")
# Pass array by reference to a function
change(a)
# Confirm that changes were made
print(a[0])
# Print the size of array 'b'
print(b.size())
# Shuffle the values of array 'c'
c.shuffle() # This function doesn't return a value
# Check that the element order was changed
print_elements_of(c)
func change(a):
a[0] = 1
func print_elements_of(array):
# Here we are using one of the Pool array types
print(PoolStringArray(array).join(""))