Currently, I'm trying to make my code more flexible and dynamic. Originally I had a variable set to a node like so: var inv_slot = get_node("Equip/EquipContainer/" + i ) which worked perfectly. Now I'm using a dynamic variable that holds a node. Here's a few things I've tried that all resulted in error: var inv_slot = DynamicNode + i var inv_slot = str(DynamicNode + i) var inv slot = DynamicNode + str(i) ... And the list goes on. However, I'm not sure how to do this and would appreciate some direction. Here is part of my code below.

onready var EquipContainer = get_node("Equip/EquipContainer/")
onready var FoodContainer = get_node("Food/FoodContainer/")
onready var ItemContainer = get_node("Item/ItemContainer/")

var DataContainer = EquipContainer

func _ready():
	for i in DataType.inv_data.keys():
		var inv_slot = DataContainer + i

What's stopping you from just calling get_node() on the container node, with relative path to a child node as an argument?

for i in DataType.inv_data.keys():
	var inv_slot = DataContainer.get_node(i)

I did actually try get_node() as well previously and got, Invalid call. Nonexistent function 'get_node' in base 'Nil' Same goes with get_tree()

Could you post actual code that caused that error?

I just figured out the problem. I set DataContainer to onready var DataContainer = EquipContainer instead of var DataContainer = EquipContainer and that fixed the issue

I'd need to see more of your could to understand what you are doing. What is stored in DataType.inv_data? What does the Node hierarchy look like? But just looking at what you posted, this would never work:

var inv_slot = DataContainer + i

DataContainer is of a Node type, AFAIK you can't add Nodes. And what is "i", an int, a string path?

I just figured out the problem by making my DataContainer variable a onready var, however here's the rest of the code.

extends Control

onready	var EquipTab = get_node("Background/TabContainer/EquipTab")
onready	var ConsumablesTab = get_node("Background/TabContainer/ConsumblesTab")
onready	var ItemsTab = get_node("Background/TabContainer/ItemsTab")

onready var Equip = get_node("Equip")
onready var Food = get_node("Food")
onready var Item = get_node("Item")

onready var EquipContainer = get_node("Equip/EquipContainer/")
onready var FoodContainer = get_node("Food/FoodContainer/")
onready var ItemContainer = get_node("Item/ItemContainer/")

onready var DataType = PlayerData
onready var DataContainer = EquipContainer

func _ready():
	for i in DataType.inv_data.keys():
		var inv_slot = DataContainer.get_node(i)
		if DataType.inv_data[i]["Item"] != null: 
			var item_name = GameData.item_data[str(DataType.inv_data[i]["Item"])]["Name"]
			inv_slot.set_text(item_name)
			inv_slot.visible = true
	
	for button in EquipContainer.get_children():
		button.connect("pressed", self, "_on_Inv_pressed", [button])


func _on_Inv_pressed(button):
	var ItemImage = get_node("Background/ItemImage")
	var SelectedItem = get_node("Background/ItemInfo/SelectedItem")
	var ItemDescription = get_node("Background/ItemInfo/Description")
	for i in DataType.inv_data.keys():
		var inv_slot = DataContainer.get_node(i)
		if inv_slot == button:
			var item_name = GameData.item_data[str(DataType.inv_data[i]["Item"])]["Name"]
			var item_description = GameData.item_data[str(PlayerData.inv_data[i]["Item"])]["Description"]
			var icon_texture = load("res://Assets/Icon_items/" + item_name + ".png")
			SelectedItem.set_text(item_name)
			ItemDescription.set_text(item_description)
			ItemImage.set_texture(icon_texture)

DataType.inv_data stores the Inv slot which holds the Item number. So like
inv_data = { "Inv1": { "Item": 10001 }, "Inv2": { "Item": 10002 }, . Here's how the nodes look.

a year later