Instancing and passing a value

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

The problem

I’m trying to make a card game, in which cards are a class and when instancing (e.g I intend to pass a value with _init so that“Cardname”) gives me a card based on the name. Also, I’m new to programming.
The idea is to have a CardDatabase that gets called by a Card Class, so that the specified card is drawn in the board (for now I’m just printing to console instead of this). The Card Class is instanciated by a Hand Class when drawing a Card from a Deck (I just included Hand to make it more easy to test and because I’m still noob). My problem is that when I instance the Card with a parameter it doesn’t change the intended variable, as shown below:

const DATA = {
	"TestCard": {
		"Name": "TestCard",
			["one", 2],

class_name Card
onready var CardDatabase = preload("res://")
var CardName:String
var CardInfo = []

func _init(Name: String):
	CardName = Name

func _ready():
	var CardInfo = [CardDatabase.DATA[CardName].Name,CardDatabase.DATA[CardName].Effects]

    var Card1 ="TestCard")
    func _ready():

#HERE is the problem, when I run this it returns [] instead of [TestCard,["one",2]]

Thanks in advance

:bust_in_silhouette: Reply From: AlexTheRegent

Since your card does not extends Node, you need to move _ready function code to _init (note that Node call _ready after it is added to scene using one of the add_child methods).