Topic was automatically imported from the old Question2Answer platform.
Asked By
ZeralldGames
How can I make it so that somewhere on the screen (in the game, not in the console) a new random text appears every time that I ask? I want to do something like a splash system like in minecraft. Thank you very much if you write me options!
RUS:
Как я могу сделать так,что бы где нибудь на экране (в игре,не в консоли) появлялася каждый раз новый рандомный текст который я задам? Я хочу сделать что то вроде системы сплешов как в майнкрафт. Спасибо большое если вы мне напишите варианты!
This should do the trick.
The variable text_variant holds all the messages you may want to show the player.
The first function applies one of the strings onto a label.
The second function returns one of the strings which you can then use however you like.
Hope this helped!
Sorry, but this is throwing an error in your code. I have to ask:
Should the function be bound to the “Label” element?
Do I need to bind any nodes to the script?
ZeralldGames | 2021-05-27 12:16
Right! Indeed, if you add this script to a label element then instead of "$Label.text = " you just write “text =”
You’ve got a lot of options of how to go about this overall. If you add this script to a label node then you don’t need to add any other nodes. Otherwise you would want to add a label node as a child to the node holding this script for instance. But it depends on the architecture of your project! Have fun.
lentsius-bark | 2021-05-27 13:24
This function still does not work for me. I attached a script to the “Label” element in my 2D scene and replaced “$ Label.text =” with the usual “text =”. I don’t know what this is connected with.