How to reference 2 different nodes to single variable?

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

This is my scene:
slot (script is here)
-specs
-details

What I am trying to achieve is to have exported integer that determines which of these nodes are assigned to var info. This is what I have so far.

export(int,"bag","armor") var slot_type
onready var details = get_node("details")
onready var specs = get_node("specs")
var info
func _ready():
	if slot_type == 1: #armor
		info = specs
		details.queue_free()
	else: #bag
		info = details
		specs.queue_free()

The problem is when I try to do something with info. It tells me that the var is null.

could you try to run it with set breakpoint and check what values are assign to details and specs?

Bartosz | 2018-03-28 15:58

I created details and specs in the scene. There is no need to check those. Trying to debug info did not move me anywhere.

Sprowk | 2018-03-28 18:44

I tried your code and it works perfectly fine. I can successfully access info in each frame. Problem must lie somewhere else. We need more info to find source of problem.

Bartosz | 2018-03-28 19:06

I found the problem. Such a blunder from me. I was trying to reference infos children but in reality i was referencing not existing ones.

get_node("info/size") #old
info.get_node("size") #new 

It is working now because it means get_node("specs/size") or in second case: get_node("details/size")

Bartosz thank you for your time and effort.

Sprowk | 2018-03-28 19:40