Newb help - how do I do this in Godot? (lots of text with flags)

Godot Version

4.2

Question

Hi! I’ve got some experience in other engines and languages but this particular problem has me stumped on how to do it most elegantly in gdscript:

I have hundreds of lines of text which can be displayed according to the value of flags attached to each line. So, as a Struct, it would be something like var text: String, flag1: bool, flag2: bool etc, all in an array. But gdscript has no structs… The second approach then would be to make a 2d array with columns text, flag1, flag2 etc… But gdscript has no 2d arrays…

I’ve looked into custom classes and resources, but as I’m quite new in godot I don’t really understand how to go about it. Can anyone give me a pointer to a relevant tutorial or better yet, give me an idea how to do it? (more detail the better, I’m still a bit hazy on how godot’s node/scene structure works so any detail on that would be most appreciated).

GDScript reference — Godot Engine (stable) documentation in English

I am well aware of the existence of the official godot documentation. Thank you very much.

You even open the link? Because is the direct link for the class explanation and creation

Of course I did, and I did study it before. I know how classes work. The problem is how to implement it into the godot engine, specifically. What goes where in the whole scene tree structure etc. Atm I’m trying the custom class solution, but I’m having problems with initializing the whole damn thing for hundreds of separate lines of text, each of which has to be instantiated from the class into an array that also has to be declared etc… I was wondering if there was a simpler, more elegant and streamlined solution, akin to what structs do.

At the moment, I’m working on first populating an array with all the texts, then instancing the class with the array using a loop… Then doing the same for each flag. Better than manually instancing and initializing every line I guess, but then again way more clunky and time consuming to implement than what I’m used to from out of the box…

Further down in that doc (I permalinked the exact position) you can create structs/classes within a script. You could even extend RefCounted for a custom very basic but still memory managed type. You can create 2D arrays in godot var my_arr: Array[Array] = [[]]

Without some script samples this is about the best we can do outside of guessing. I have written dialogue engines myself, it is always a fun challenge so ask away!