Incorrectly given label names from signals?

Godot Version

Godot 4.7

Question

hello! i’m running into a problem that probably has to do with signals getting mixed up somewhere. i’m trying to have the name of an item go from point A (a shelf) to point B (a maintainer node to hold everything together) to point C (a list of items) whereupon it marks the item as “done”.

everything seems fine with the shelf telling the maintainer the name, but something seems to go wrong with the maintainer giving the name to the list; when interacted with, the shelf gives the wrong name and the list only changes for one specific shelf (“thang three”). so when i go to the “thang two” shelf, interacting with it still shows it as “thang three.” their names are changed to what they should be in their respective exported variables. i have probably bungled up a function somewhere.

i’m considering getting rid of the maintainer node altogether since everything’s going to be in the same tree anyway. other shelves (“thang two”) are a copy of the first one, labeled “thang three” below.

thank you for looking!

shelf code:

extends StaticBody2D

@onready var area_2d: Area2D = $Area2D
@onready var collision_shape_2d: CollisionShape2D = $Area2D/CollisionShape2D
@onready var label: Label = $Label

@export var item_name: String

var pc_in: bool = false

signal has_item(item_name) #has whatever the item_name label is

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	label.text = item_name


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if pc_in == true and Input.is_action_just_pressed("interact"):
		has_item.emit(item_name) #if player is In the area and interacts, emit item name


func _on_area_2d_area_entered(area: Area2D) -> void:
	pc_in = true
	print(item_name)

maintainer code:

extends Node

@onready var shelf: StaticBody2D = $"../shelf"
@onready var list: Node2D = $"../list_popup"

signal item(item_name)

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	shelf.has_item.connect(_has_item) #gets the item name from the shelf...


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass

func _has_item(item_name):
	item.emit(item_name) #and sends it to the shopping list
	print(item_name)

relevant list code:

extends Node2D

@onready var maintainer: Node = $"../Maintainer"
@onready var shelf: StaticBody2D = $"../shelf"

@onready var item_1: RichTextLabel = $"Sprite2D/VBoxContainer/item 1"
@onready var item_2: RichTextLabel = $"Sprite2D/VBoxContainer/item 2"
@onready var item_3: RichTextLabel = $"Sprite2D/VBoxContainer/item 3"
@onready var item_4: RichTextLabel = $"Sprite2D/VBoxContainer/item 4"
@onready var item_5: RichTextLabel = $"Sprite2D/VBoxContainer/item 5"

# @export var item_list: Array[RichTextLabel]

var list_size: int = 5
var item_names: Array[String] = ["thang one", "thang two", "thang three", "thang four", "thang five"]

#HEY YOU GOTTA REMEMBER THAT ARRAYS START WITH ZERO. ITS [NUMBER OF ITEMS]-1. REMEMBER

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	global_position.y = 800
	maintainer.item.connect(check_item)
	randomize_items()

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	var item_name: String
	
	if Input.is_action_pressed("check_list"):
		check_list()
	else:
		put_away_list()
	if shelf.pc_in == true and Input.is_action_just_pressed("interact"):
		check_item(item_name)
		#seems to be where the breakdown is? pressing interact shows the wrong name

---

func randomize_items() -> void:
	item_names.shuffle()
	item_1.text = item_names[0]
	item_2.text = item_names[1]
	item_3.text = item_names[2]
	item_4.text = item_names[3]
	item_5.text = item_names[4]

func check_item(item_name: String):
	if item_name == item_1.text:
		item_1.text = "done"
	elif item_name == item_2.text:
		item_2.text = "done"
	elif item_name == item_3.text:
		item_3.text = "done"
	elif item_name == item_4.text:
		item_4.text = "done"
	elif item_name == item_5.text:
		item_5.text = "done"
	else:
		pass

scene tree layout:

you declare item_name but never assign to it