Godot Version
Godot 4.7.2
Question
Hello Everyone, this is my first post on this forum, as I am at my wits’ end with this coding issue and genuinely feel insane, as in my head everything should be working exactly as it should be.
For context, I am not an expert in Godot and have been learning how to code my game through YouTube tutorials and blind hope, so there is a very high chance I have done something wrong and am just blind.
For my game, I have a system where, when you are standing in a specific area and type the word talk a text box appears. Now, to tell my text box exactly what text I want to be in that box, I have made it so that when the player is standing at the specific coordinates and types talk, a signal is emitted from the startingArea node to the dialoguePlayer node, and from here it’s connected and then tells the code to use a specific set of dialogue.
However, it just says the signal is non-existent, which it isn’t. I can autofill the signal name in the DialoguePlayer connect, and when I print the path in DialoguePlayer, it comes up as the StartingArea, as it should.
This used to work, and I don’t think I changed anything, so please help me, as this is now causing some unforeseen issues.
# -----------------------------
# What my startingArea Code kinda looks like (just scaled down)
# ------------------------------
@onready var player: CharacterBody2D = $player
signal treeTalkText
func checkForTalk() -> void:
if player.position == Vector2(XXX, XXX):
emit_signal('treeTalkText')
$"./dialogueAreaOne".start()
#print('It does not reply as trees cannot talk')
# -----------------------------
# What my dialoguePlayer Code kinda looks like (just scaled down)
# ------------------------------
@export_file("*.json") var dialogueFile
var treeTalkFile = FileAccess.open("res://scenes/dialogue/treeTalkText.json", FileAccess.READ)
var file
var dialogue = []
var currentDialogueID = 0
var dialogueActive = false
func _ready():
$"..".connect('treeTalkText', checkForTreeText)
func start():
if dialogueActive:
return
dialogueActive = true
$NinePatchRect.visible = true
dialogue = loadDialogue()
currentDialogueID = -1
emit_signal("textRemove") #for a seperate thing not related to this signal issue
nextScript()
func loadDialogue():
var content = JSON.parse_string(file.get_as_text())
return content
func checkForTreeText():
file = treeTalkFile
func _input(event):
if !dialogueActive:
return
if event.is_action_pressed("enter"):
nextScript()
func nextScript():
currentDialogueID += 1
if currentDialogueID >= len(dialogue):
dialogueActive = false
$NinePatchRect.visible = false
emit_signal("dialogueFinished")
return
$NinePatchRect/text.text = dialogue[currentDialogueID]["text"]
