|Topic was automatically imported from the old Question2Answer platform.
I have a scene made by only 20 labels and one generic node called “global”.
Global node will have a script that is autoloaded and also called global and will consist of a function and variables from the 20 labes that will be accesible by all the other scripts I’ll make.
What I want is to make text appear in the node that’s lower on the screen and then as that node’s text is updated, the previous text will appear in the node above it as a kind of history of all the text I printed.
For that I wanted to make the lower label say “Hello world!” when the program starts, using global script. Of course I could use that label (which is called CurrentLine cause the user will be able to write commands), use the _ready function of that label and tell it to print that but what I actually want is to make that script which will imitate the boot log of an OS, and it will push the text from line2 to line3 to line4 whenever a new line of text appears.
But I can never get the reference to any node correctly. With my last program I had the same problem but it was a lot simpler and didn’t really need to reference any node so much.
I first tried (naive me) with
var CurrentLine = get_node("CurrentLine")
and then in the _ready() function
It apparently cannot set_text to null base.
So I changed the “CurrentLine” with “res://Content/Scenes/Main.tscn/CurrentLine” but I had no luck so it didn’t work either.
Then I tried initializing a variable in global called CurrentLine, then create script for the CurrentLine label and in there
global.CurrentLine = get_node()
But that’s not working either. I even changed the () to (self) and (“CurrentLine”) but it doesn’t work either.
And I can’t seem to find anywhere on the internet a page where they tell you explicitly how to reference one node (CurrentLine) from another script (global) that doesn’t extend CurrentLine.
In my last program I could make every LineEdit change a variable in it’s own global script which stored those values to use them in a different scene.
But it wasn’t really referencing those LineEdit’s but the global script itself.
In this case I want the global script to keep track of the text in the CurrentLine (where the player will write commands) and push it to the above label, and the text in that label above, push it to the label about that one and so on and so forth until it reaches label20 where the screen ends and it just gets deleted. And also I want to create some sequences of text lines like the one sequence I said it would imitate boot logs from linux live CDs.
But I can’t do that if I can’t get a reference to each and every label so PLEASE HELLLLPPPPPPP!!!