0 votes

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.

in Engine by (333 points)

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

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

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.

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories