- Edited
I was not sure how to title this. But I have a basic card game with a dictionary that houses the cards info. I have a random number generated that will correspond with the dictionary. Once the random number is generated it will either grab the correct card and add that number to an array OR if the number generated is in the array it will generate a new number until it grabs one, not in the array. What I've done is not working. I was hoping someone could look at my code and tell me what I did wrong. I also would ultimately like the array to be cleared once it reaches 252. I hope I explained that well enough. Below is my code. Thanks in advance for any advice!!
onready var index = OnStartData.random_numbers.find(OnStartData.random_numbers)
var rand = RandomNumberGenerator.new()
func _ready():
OnStartData.score = 3
rand.randomize()
OnStartData.random_number = rand.randi_range(1,252)
if index == -1:
OnStartData.random_numbers.append(OnStartData.random_number)
print("not found")
print (OnStartData.random_numbers)
else:
while index.has(OnStartData.random_number):
rand.randomize()
OnStartData.random_number = rand.randi_range(1,252)
print(index)