UnRun func and UnRun code breaking Resource

Godot Version

v4.3.stable.arch_linux

Question

I have a Resource to store player inventory, and isolated the game breaking code, to some unrun code that is quite innocuous.

This, dispite not being called (according to debugger), breaks things in the resource.

if item is HealthItem:
		pass

No related errors and breakpoints suggest code not run, but my resource for items that are HealthItem show as null. Here is the complete func, that also is unrun.

func item_NOTCALLEDFROMANYWHERE(item):# InvItem)-> void:
	if item is WeaponItem:
		pass
	if item is HealthItem:
		pass

Commenting HealthItem statement, and bug gone. Despite unreferencing function.

This works.

func item_NOTCALLEDFROMANYWHERE(item):# InvItem)-> void:
	if item is WeaponItem:
		pass
	#if item is HealthItem:
		#pass

I’m still learning Godot, so any ideas as to what to try next to figure out what is going on, are much appreciated.
Using the stacktrace, breaks never occur.
No errors in the debugger.
Any other tools or suggestions, as developing with such black magic is disconcerting and I have not much hair left to pull out.

Thanks is advance for any suggestions. More info below.
Cheers
Dan

playerinv.tres



[gd_resource type="Resource" script_class="Inv" load_steps=25 format=3 uid="uid://cxjv1bkh4h06t"]

[ext_resource type="Script" path="res://Inventory/inv.gd" id="2_lxnvg"]
[ext_resource type="Script" path="res://Inventory/inv_slot.gd" id="2_srt7n"]
[ext_resource type="Resource" uid="uid://dumj1lxvfga26" path="res://Objects/Weapons/fishing_rod.tres" id="2_xigps"]
[ext_resource type="Resource" uid="uid://d1ed7flcg3i56" path="res://Inventory/Health/heart.tres" id="3_16nlk"]
[ext_resource type="Resource" uid="uid://bky30mwsy1ui0" path="res://Objects/Clothing/baseball_hat.tres" id="4_61uol"]
[ext_resource type="Resource" uid="uid://4f4t3lcjt6q5" path="res://Inventory/Items/goldfish.tres" id="5_w77qw"]
[ext_resource type="Resource" uid="uid://c860hmkxd7pf2" path="res://Objects/Weapons/sword.tres" id="5_xd347"]
[ext_resource type="Resource" uid="uid://bv3h1mf5il37i" path="res://Inventory/Items/egg.tres" id="6_0bnev"]
[ext_resource type="Resource" uid="uid://cld6ekiqhvsaf" path="res://Inventory/Items/yucca_fruit.tres" id="8_51a85"]
[ext_resource type="Resource" uid="uid://ccdba4w8fc4ko" path="res://Inventory/Items/yucca_seed.tres" id="9_fayps"]
[ext_resource type="Resource" uid="uid://bpnv7m0x7vuto" path="res://Objects/Weapons/sickle.tres" id="10_k8wuf"]
[ext_resource type="Resource" uid="uid://cgh0wctvdhfux" path="res://Inventory/Items/worm.tres" id="11_djwyd"]
.....
[resource]
script = ExtResource("2_lxnvg")
slots = Array[ExtResource("2_srt7n")]([SubResource("Resource_jil6i"), SubResource("Resource_m6yxg"), SubResource("Resource_saeee"), SubResource("Resource_a58xb"), SubResource("Resource_bcdxs"), SubResource("Resource_1ijsn"), SubResource("Resource_cwgo3"), SubResource("Resource_ja33a"), SubResource("Resource_w5dwj"), SubResource("Resource_y1563"), SubResource("Resource_mkrtj"), SubResource("Resource_26uwg")])

What is the expected output of your code, and what output are you getting? What is the full script attached to the player inventory resource?

This, dispite not being called (according to debugger), breaks things in the resource.

How does this break things? Is it a visual bug? If so, what does it look like?

Thank you for your reply and questions.

Seems my CustomClass, or rather asking questions about the class, causes the issue. Also seems posing the question about the class, even in code not executed, also results in issues. Ex using is_instance_of should return a bool.

I have with two Items (sword and heart) of class_name WeaponItem and HealthItem in an array.

func test_inventory():
	for slot in inv.slots:
		if slot.item:
			print(slot.item.name,' : ',is_instance_of(slot.item, HealthItem))
		else:
			print('Error: ',slot)

Expected result.

sword : false
heart : true

Actual result

sword : false
Error: <Resource#-9223371993770883678>

Expected result from is_instance_of WeaponItem is correct.

sword : true
heart : false

Thank you for any ideas or suggestions.

I may just write a custom return class, even though it shouldn’t be necessary.

Cheers

What does inv.gd and inv_slot.gd look like? Where is the array stored, and what is the script of that? I suspect your HealthItem doesn’t have an item variable, or that variable is null or something similar.