I'm trying to follow along with an Udemy Godot video and I've become lost. Making a simple word game that asks the player for a name, a noun, an adverb and an adjective. I'm using arrays in dictionaries, the previous lesson each variable was separate but now we've combined them into one using a Dictionary. My game ran fine until I did this and I'm getting the above error. The debugger isn't really telling me anything (that I can understand). Here's my script:


extends Control

var player_words = []

var current_story = {
		"prompts" : ["A name", "A noun", "An adverb", "An adjective"],
		"story" : "Once upon a time someone called %s ate a %s flavored sandwich made him feel all %s inside  It was a &s day"
		}


onready var PlayerText = $VBoxContainer/HBoxContainer/PlayerText
onready var DisplayText =$VBoxContainer/DisplayText

func _ready():
	DisplayText.text = "Hello and welcome to a word game.  "
	check_player_words_length()
	PlayerText.grab_focus()


func _on_PlayerText_text_entered(new_text):
	add_to_player_words()


func _on_TextureButton_pressed():
	if is_story_done():
		get_tree().reload_current_scene()
	else:
		add_to_player_words()


func add_to_player_words():
	player_words.append(PlayerText.text)
	DisplayText.text = ""
	PlayerText.clear()
	check_player_words_length()


func is_story_done():
	return player_words.size() == current_story.prompts.size()


func check_player_words_length():
	if is_story_done():
		end_game()
	else:
		prompt_player()


func tell_story():
	DisplayText.text = current_story.story % player_words 


func prompt_player():
	DisplayText.text += "May I have " + current_story.prompts[player_words.size()] + " please?"


func end_game():
	PlayerText.queue_free()
	$VBoxContainer/HBoxContainer/Label.text = "Again!"
	tell_story()

It goes through all the prompts then crashes after my input for the adjective. It ran fine until I changed the variables into one. Everything looks identical to what the author has, the only thing I can think of is that I'm on a later version of the engine, 3.2. I think the author is on 3.1. Is that the issue?

Which line in the code is the debugger reporting the issue at?

Edit: Also, can you post the error the debugger is showing? That may help with figuring out what is going on.

You can tell Godot to manually convert a variable to a string by using String(variable_name_here). I think that should fix the issue. Looking at the code, try changing line 32 to the following: player_words.append(String(PlayerText.text))

That should, hopefully, fix the issue. Also, welcome to the forums!

Hi, I've tried attaching a cropped screen shot of the debugger but it won't take pngs or jpgs(or I might be doing it wrong?). The debugger just shows 4 stack frames at line 50, 60, 44, 35, and 21.

There are 2 errors on the next tab with the yellow caution symbol. But the author has these on his as well and said they would be addressed later.

I just tried your suggestion for line 32 and it does the same thing. It goes through all the prompts and crashes on the last one giving me the operator error.

@User67 said: Hi, I've tried attaching a cropped screen shot of the debugger but it won't take pngs or jpgs(or I might be doing it wrong?).

You should be able to attach image files, including .png and .jpg, by drag and dropping, through the browse button in the insert image on top of the post editor, or through the "Add images" button. I double checked the category permissions and it should allow anyone to upload files. If you still have problems uploading images, please let me know so we can look into it further.

... The debugger just shows 4 stack frames at line 50, 60, 44, 35, and 21. There are 2 errors on the next tab with the yellow caution symbol. But the author has these on his as well and said they would be addressed later.

I just tried your suggestion for line 32 and it does the same thing. It goes through all the prompts and crashes on the last one giving me the operator error.

Hmm, I'm not sure. I have not really use the %s keyword in GDScript, so I have to rely on Python experience.

Looking at the text on line 5, I noticed at the end there is &s rather than %s. Maybe that is causing the issue? Unless you need it, I would replace it with %s and see if that fixes the issue.

Outside of that, the only thing I can think of is perhaps there is not enough strings in the array, and so it crashes because of that. Though I think if that happens, the %s keyword just becomes null instead of crashing.

I dunno, I would have to experiment and see. I do not have the time right now, but I'll try later to do some experiments and see if I can deduce what is going on and hopefully a possible solution.

Twisted, you're awesome. I can't tell you how many times I looked at that '&' thinking it was right because I knew that's where the hangup was. Wow. I was convinced I had the spelling right but nope.

As far as the screen shots yeah. I tried dragging and dropping them into this box, tried clicking on the icon above and both said file 'format is not allowed.' Which is why I changed it to png thinking that was it. I even cropped the screenshots just to the debugger window but it stell says 'File format is not allowed'

Thanks again. Finally I can finish this course and get into the fun stuff.

Edit: I guess I can't edit the original post? But this is solved. Thanks again, Twisted!

Awesome! I'm glad the solution was something easy, rather than an engine bug or something else difficult to peg down.

I'm thinking something with the settings for the programming category, or the settings for users, needs adjusting. I do not have the time right now, but I'll take a look once I can and see if I can figure out what is wrong. Thank you for letting us know about the issue!

Also, I changed this topic to a question and selected my post as the answer, so others with the same issue can hopefully find this topic easier.

Thanks again, just a heads up as to maybe why the image uploader wasn't working with me. I use the Brave Browser. I know it doesn't work with certain things, so that might be it.

@User67 said:

As far as the screen shots yeah. I tried dragging and dropping them into this box, tried clicking on the icon above and both said file 'format is not allowed.' Which is why I changed it to png thinking that was it. I even cropped the screenshots just to the debugger window but it stell says 'File format is not allowed'

Thanks again. Finally I can finish this course and get into the fun stuff.

You wouldn't be using brave as a browser, would you? It's a known issue with brave and anything that requires cookies, IIRC.

edit: ah the post above already covers it.

3 years later