IDE is working but export file is not

Godot Version

v4.3.stable.official [77dcf97d8]

Question

Hi community, I made a game that is running fine within Godot IDE. when exporting, it is not working. I followed the advice in the forum and ran a cmd debugger. The image is attached.


It seems for some of the objects, a particular class is not getting initiated.
The class definition is as below:
extends Node2D
class_name Target_Item

var item_name:String=“”
var is_active:bool=false
var matching_search_item : Search_Item

the error line 133 is occuring in the function below:
error line

Can anyone help me figure out how to explore this further?

This indicates that the target or item is empty, you can print them out before this line to check which is the problem

Thanks for quick response. I do not know how to print from an export file. If you can guide me it would be helpful. Also, a key question in my mind is if the item is working fine when in godot ide, what could lead to it not working on export pack.

Any help would be most appreciated.

Place this line before line 133 and export, in the console before these warnings the desired value should be printed:
print("target: {target}, item: {item}".format({"target": target, "item": item})

That helps me move a step but still does not resolve it as it is printing the random code name generated during runtime. Is there a way I can get to print the item_name property( that is a string) of the item?

Can I ask you to show us the output before that?


here it is

i need to figure out what is the item name in target so that i can know what is missing

The point is right here, what you have missed is not the target, but the item is empty, your function is called with an empty parameter.
Now you need to check where you called this function to figure out where the parameter being sent is null, you can check it manually, or you can change the function like this every time you call:

if not item:
  printerr(get_stack()) 
else:
  create_linked_target(item)

This structure determines the fault location stack

I really appreciate your help. I am nowhere close to figuring out the problem so far. A new thing that I have discovered is that the item itself is generating a target even before it is assigned which is strange.


The data in the console is for the highlighted print statement.
while printing the item it is showing-
SearchItem:<Button#48704259685>
target: Target:<Area2D#50633639580>, item: SearchItem:<Button#48704259685>
whereas i was expecting only button.

Could it be because of the way search item class is defined?

extends Button
class_name Search_Item

#declare property variables
var item_usage:String=“”
var item_name:String=“”
var linked_target:Target_Item=null
var has_target:bool=false

I am going nuts and value your feedback a lot

I’m really confused, I don’t know the structure of your project, and it’s so complicated that I dare not guess, but;

I guess as you said there is a problem here, maybe it can be fixed with @onready or @export, I am not really familiar with these two, I just know some of their uses, maybe it would be better to check the documentation about them…