I'm learning randomness from Godot Doc. This code works in GD3 but gives me the error "non existing function empty() in Array" in GD4. (The code is to print random unique fruit until it runs out and start again)
How to update the code for GD4? Thanks
var _fruits = ["apple", "orange", "pear", "banana"]
var _fruits_full = []
func _ready():
randomize()
_fruits_full = _fruits.duplicate()
_fruits.shuffle()
for i in 100:
print(get_fruit())
func get_fruit():
if _fruits.empty():
_fruits = _fruits_full.duplicate()
_fruits.shuffle()
var random_fruit = _fruits.pop_front()
return random_fruit