Error in the code

Godot Version

extends Control

var questions =
var current_question_index = 0

func _ready():
load_questions()
show_question()

func load_questions():
var file = FileAccess.open(“res://medium.txt”, FileAccess.ModeFlags.READ)
if file:
var lines = file.get_as_text().split(“\n”)
file.close()

	# Przetwarzanie pytań
	for i in range(0, len(lines), 6):
		if i + 5 < len(lines):  # Upewnij się, że nie przekraczamy końca pliku
			var question = {}
			question["text"] = lines[i].strip_edges()
			question["answers"] = [
				lines[i+1].strip_edges(),
				lines[i+2].strip_edges(),
				lines[i+3].strip_edges(),
				lines[i+4].strip_edges()
			]
			question["correct"] = lines[i+5].strip_edges()
			questions.append(question)

func show_question():
if current_question_index < len(questions):
var q = questions[current_question_index]
$Label.text = q[“text”]
$GridContainer/A.text = q[“answers”][0]
$GridContainer/B.text = q[“answers”][1]
$GridContainer/C.text = q[“answers”][2]
$GridContainer/D.text = q[“answers”][3]

func _on_a_pressed(A):
print(“button clicked”,A)
print(“A text:”,A.text)

func _on_b_pressed(B):
check_answer($B.text)

func _on_c_pressed():
check_answer($C.text)

func _on_d_pressed():
check_answer($D.text)

func check_answer(answer):
var q = questions[current_question_index]
if answer == q[“correct”]:
$Label.text = “Poprawna odpowiedź!”
else:
$Label.text = "Błędna odpowiedź. Poprawna odpowiedź to: " + q[“correct”]

current_question_index += 1
show_question()

Question

I want to create quiz game and i am new to programming in gdscrip. i always get error when i am trying to test my buttons, something about invalid text is showing up , but i just want to create this code to show question and when you answer it shows if you guessed correctly or not and after that it is going to turn to scene before where you can again choose difficulty level.

Sorry for my english its not my main language

Can you paste the exact error message? and what line is being pointed out?

Make sure to format your pastes correctly

1 Like

Sorry for wasting your time i solved my problem moment ago while analizing my code i realize that i didnt rever to container while refering to the button in the lower part of my code