Get_line_count() isn't working right

Godot Version

4.3

Question

I’m working on an RPG textbox system. It can successfully print text, and also add up to 4 selectable options that the player can pick from. They’re assembled as separate labels in a VBoxContainer, and I tried to make it so that options that take up more than 1 line of text will cut out the others in order to make space. I spent a while making a somewhat probably overcomplicated system that changes the “Lines Skipped” and “Max Lines Visible” variables as well as hiding the labels, but suddenly I found that a previous dialogue tree that used to work fine now does not, when it only had 2 options with 1 line of text each. I used both get_line_count() and get_visible_line_count() on the first option, and printed the values; 15 and 4 respectfully, when a label that should have plenty of space to spare was printing “Avoid stealing”. This first option actually does print normally, but the second one gets cut out due to the strange values. When I move down in-game to select it and then back up again, it becomes somewhat normal, with only an incorrect scroll down indicator to show for it. It should only be one line of text, so why is it returning these strange values? Am I misunderstanding the functions? Are the labels colliding with eachother in weird ways?

I find the easiest way to work out what is happening is to create an entirely new test scene, and to recreate the problem in the simplest way possible. It sounds like a vbox with some labels and then some strange formatting which to be honest I am unable to follow. If your test scene continues to show behaviour you did not expect, the code can then be easily shared since all the contextual complexities have been removed.

Often the problem comes to light pretty quickly when doing this. And so far it has always been a problem with my implementation rather than a system or Godot bug. However this is how bugs are discovered.

Try this and then share your code with the problem, and I am sure someone will be able to help, but without any code to look at, it really is difficult to offer any advice.

All my functionality starts in test scenes. I find this not only a great way to learn new things, but to really tear apart a problem to find out what is going on with unexpected behaviour. It might seem a PITA at first, but honestly it does not take long to do, and is a great way to investigate these bugs that within the context of a real scenario and the in the depths of a serious game component, can sometimes seem impossible.

Hope you get it fixed, and look forward to looking at some code should you not be able to find the issue in your simplified test scene.

PS There is also a get_visible_line_count(). Might be worth checking you are using the right one. It is here in the docs: