Why wont my game show the text i gave it
Asked Answered
S

10

0

Im making a text adventure game and have some code taht makes it show a message when the game starts but the message it shows isnt what i gave it and the message it shows doesnt even exist in my code. The code should work fine but doesnt how do i fix this?
code:



signal  respone_generated(response_text)

var current_room = null

func initialize(starting_room):
	change_room(starting_room)

func proscess_cmd(input: String) -> String:
	var words = input.split(" ", false)
	if words.size() == 0:
		return "Error no words parsed"
	var first_word = words[0].to_lower()
	var second_word = " "
	if words.size() > 1:
		second_word = words[1].to_lower()
	match first_word:
		"go":
			return go(second_word)
		"help":
			return help()
		_:
			return "unrecognized command"

func go(second_word: String):
	if second_word == " ":
		return "Go where? "
	return "You go to %s" % second_word

func help() -> String:
	return "Usable commands: go[location], help"
	

func change_room(new_room: Start_room):
	current_room = new_room
	emit_signal("respone_generated", "you go to " + new_room.room_name)
	emit_signal("respone_generated", new_room.room_description)`~~~
[upl-image-preview url=https://godotforums.org/assets/files/2024-03-16/1710548492-600521-screenshot-2024-03-15-180625.png]
Shapeless answered 16/3 at 0:21 Comment(0)
F
0

Place ~~~ on lines before and after the code to display it properly.

Firewarden answered 16/3 at 0:50 Comment(0)
S
0

Firewarden just did sry i didnt know

Shapeless answered 16/3 at 1:11 Comment(0)
B
0

Is your editor in english? Godot does this annoying thing of translating random works to whatever language the editor is set to, like yes, no, debug, etc.
If it's not that, post the text you are getting and what you expected to get, that will help us find the problem in you code.

Bohman answered 16/3 at 6:30 Comment(0)
C
0

I don't think Godot will insert the word bustling into your text by itself. 😬 Would be interesting though.
Maybe wrong room as starting room? Maybe some old test room you forgot about?

The only thing I noticed in your code is that you misspelled response in your signals name.
respone_generated(response_text) which shouldn't be a problem as you misspelled it in your emit_signal too.

Cia answered 16/3 at 6:51 Comment(0)
B
0

Shapeless oh, the image wasn't showing I thought it was part of the code.
The first part process_cdm gives a correct result I think. The second part is in the start_room variable.
So then you are running change_room which prints the result.
In that case the problem is in the Start_room class, not the code you posted. Or where you run change_room.

Bohman answered 16/3 at 7:20 Comment(0)
S
0

Bohman well heres all the code thats associated with the start_room class

class_name Start_room
@export var room_name: String = " "
@export var room_description: String = " "~~~

and here is the code for that calls the initialize function which calls the change_room function:
func _ready() -> void:
	command_proscessor.respone_generated.connect(handle_response_generated)
	
	scrollbar.changed.connect(handle_scrollbar_changed)
	handle_response_generated("Welcome to the grand city of Baghdad! You have arrived here with your partner Benjamin of Tudela. You will be staying in the city for some time and should explore and see what it has to offer! Type help to view available commands")
	command_proscessor.initialize(manager.get_child(0))
Shapeless answered 16/3 at 11:48 Comment(0)
S
0

Cia the thing is theres only one room just this room. That dtext did exist in the past like i wrote them down as the name and description variables but i changed them.
Also ye ik i screwed up the response variable name lol whenever i try to change it back it just like...doesnt work for some reason even though all the names are changed. im fine with it tho.

Shapeless answered 16/3 at 11:54 Comment(0)
S
0

Bohman yes it is in english and here is the image:

Shapeless answered 16/3 at 12:4 Comment(0)
B
0

Shapeless interesting. I guess start_room is a node? In that case, you have to know that exports are shared between instances of the scene, it is better to get text from dictionaries or text files and put them in the object through code.
It's probably nothing, you just didn't input the string correctly, if you type the text again it might fix itself.

Bohman answered 16/3 at 13:44 Comment(0)
S
0

Bohman oh its finally working now that you so much 🙂

Shapeless answered 16/3 at 17:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.