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.

in Engine by (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.)

by (866 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.