0 votes

Hey im making an eductaional game that asks questions and am trying to change the question to the next question based on the text that is inside the RichTextLabel. Im using this rn but it doesn't do anything???

var question1 = "What are the objectives of Financial Management?"
var question2 = "Placeholder"

func questionupdater():
if getnode("Question").text == question1:
getnode("Question").text = (str(question_2))

This is attached to a signal when a line edit node has text entered into it, but it just stays as the 1st question.

asked Jun 21 in Engine by retsi3602 (21 points)

Your variable is called question2 (without an underscore), but when setting the text you're using question_2 (with an underscore). That should result in an error though! Have you made sure the initial text of your "Question"-node is exactly (even a trailing whitespace will result in a difference) identical to the value of question1? Have you ensured that questionupdater is properly called (either by printing some text at the beginning or setting a breakpoint in the editor)? Otherwise it looks fine.

1 Answer

0 votes

Generally speaking, you want to create an identifier that is not your question text to handle the logic. For example, a string like question001 or an integer.

Then you can iterate through the list of strings or add one to your integer and look up the contents of the next question. The current approach that you've described sounds quite fragile. (To insert a new question into the middle of the list you'd likely need to update your data and your code.)

answered Jun 21 by JimArtificer (699 points)
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.