Beginner here. This was supposed to be easy. I'm deseperate. Please help me.
What I want to do:
When I click on a "draw" button, the game draws one out of 33 cards (a different one at each draw until all 33 are used & then it restarts).
What I was able to do so far:
I could write the part where the cards are preloaded as new textures (examples below),
onready var drawMenu = get_node("Drawacardscene")
var new_texture_card1 = preload("res://Cards/card1.png")
var new_texture_card2 = preload("res://Cards/card2.png")
var new_texture_card3 = preload("res://Cards/card3.png")
and the part where it selects a number randomly (a different one at each draw until all 33 are used & then it restarts).
arrayDraw = initArray()
func initArray():
var _card = []
for i in range(33):
_card.append("_card"+str(i))
return _card
func _on_draw_pressed():
var randomDraw = randi() % arrayDraw.size()
# the line I'm loosing hope to find
arrayDraw.remove(randomDraw)
if arrayDraw == null:
arrayDraw = initArray()
What I can't seem to do is connect the too things together. I've been trying different versions of this (instead of the #comment above):
drawMenu.texture = new_texture_card+str(arrayDraw[randomDraw])
And godot tells me I can't because I'm "trying to make a sprite out of a string".
So here it is. Does anyone have any idea what I'm supposed to write instead? Or should I try something else (what)?
I've also tried to use the .hide() / .show() option instead of the new_texture one but it seems to lead to the same kind of error which means I've probably just missed some obvious thing I'm hoping you guys can point out to me.
Thanks in advance!