0 votes

I am using arrays to store data at runtime, and frequently have to debug data-related issues, but the debugger will only show the first 9 entries in an array, regardless of how big it is. This is really frustrating, as often the problem value is not in that first few entries, but I have not been able to find anything that tells me how else to show more. Seeing as some things are generated randomly, re-running the project with a print() statement or similar isn't guaranteed to find the problem.

Alternatively, is there a way to watch a variable and break if it is set to a particular value? (And would this work with the contents of a dictionary or a specific item in an array?)

Thanks in advance.

Godot version 3.2.3
in Engine by (27 points)

you could do a break down and print individual elements of an array.

assuming you have :

array = ["test", "test2", "test3"]

Then:

for n in array:
 print(n)
 if n=="test2":
  print("..found")

Output:

test
test2
..found
test3

Have you ran the project and looked at the nodes in real time, i.e. clicked on "Remote" in the Scene dock? This may help you to view the contents of the array in real time.

This still gets me to the same place, i.e. only showing the first 9 entries in an array.

Then the issue probably lies elsewhere.
If printing the elements of the array one by one only leads to 9 elements and checking the nodes in real time says that the array has only 9 elements, then there's probably only 9 elements in the array.

the for n in array statement should always allow you to iterate to every element in the array. Also as suggested by @Ertain, looking at the [Remote] scene tree should allow you to view real time what is happening to your array. If you click on the relevant node that holds the array, the [Inspector] tab should give you information regarding the array under the [Members] section. From there you'll see your array and it's number of elements. Clicking that specific array, should expand it to allow you to view the values it contains.

It would help if you could post a snippet of your code. It's hard to guess why there's only 9 elements.

Edit:
PS: If your array has more than 10 elements, you'll see another entry called "Page",
where Page 0 shows the 0-9 elements, Page 1 shows 10-19 elements, etc...

The only other option I can think of is writing the contents of the array to a file, and examining that. If the array is too large to use a simple print() function (i.e. print(the_array), and the debugger panel can't fit the array, then writing the file seems to be the best option.

The "Page" option was the answer I was looking for. Thank you. If you repost that part of your comment as an answer, I can mark it as the solution. :-)

I am wondering if it's worth putting in an enhancement request to suggest having an easier way to debug large arrays and dictionaries...

1 Answer

0 votes

Just look at the console window behind your editor :). You know, this small, black console which opens before and alongside with Godot. It works the same as in-editor console, but prints full content, it is never overloaded by text.

Alternatively You can slow down text output :

for entry in array :
     yield(get_tree().create_timer(0.1),"completed")
     print(entry)
by (2,416 points)

This doesn't really answer the problem though: yes, I could print( ) and read through some output to find the bit I want, but it's still going to be awful for large arrays – and I have to go back through and add a print( ) statement somewhere; I can't do this interactive live while debugging. What I was hoping for was a way to view arrays like how they show in the debugger, but with more than just the first 9 entries.

But the big debugger can fit more than 9 entries, just minimalize editor and see it in the other window. You know, when you open editor exe file 2 programs are opened - editor itself and additional console window. If You don't want to print in process, you can always print on input event

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.