I can't call any array functions.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By even_nuller

I want to get the amount of elements in an array but when I try to call the .count() function it doesn’t recognize it and gives me an error

extends Node2D

export var min_room : int = 5
export var max_room : int = 10

export(Array, PackedScene) var room_scenes

var is_first_room = true

func _ready():
	generate_room()

func _process(delta):
	pass

func generate_room():
	var random_picked_room_int : int = rand_range(0, room_scenes.count())
	var random_picked_room_pc : PackedScene = room_scenes[random_picked_room_int]
	
	var instantiate_pos : Vector2
	if is_first_room:
		instantiate_pos = Vector2.ZERO
	
	var room_instance = random_picked_room_pc.instance
	room_instance.position = instantiate_pos * 128
	self.add_child(room_instance)
:bust_in_silhouette: Reply From: Inces

There is no such built-in method. There is size() instead.

:bust_in_silhouette: Reply From: rossunger

the count method return the number of times the parameter appears in the array. what you’re looking for is size()