This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

Basically Interactable (the emitter code) is for more than one area (the current scene I'm working with has 3). What I want is, when the KinematicBody (the player) is in a certain Area, that one Area will send its name to the Text Box.

I'm having an issue with signals. I get this error when the KinematicBody enters one Area (and also when the scene is loaded, curiously):

E 0:00:05.732 emit_signal: Error calling method from signal 'body_entered': 'Control(Textbox.gd)::get_dialog': Method expected 1 arguments, but called with 2..
<C++ Source> core/object.cpp:1228 @ emit_signal()

Here are the codes for the emitter and the receiver, respectively:

Interactable

func _ready():
  var textbox = get_node("../textbox")
  self.connect("body_entered", textbox, "get_dialog", [self])

Textbox

func get_dialog(area):
  var speaking = "res://Test/Text/_%D.json" % area
  var file = File.new()
  file.open(speaking, file.READ)
  dialog = parse_json(file.get_as_text())
  load_dialog()`
in Engine by (21 points)

1 Answer

0 votes

Nevermind, I got help from a couple of Discord servers:

A signal may send at least one implicit argument. This case, body_entered, has one: "body". So I'd have to include it on getdialog first (func getdialog(_body, area):)

PS: I noticed a typo on Textbox's 2nd line. Should be %s instead of _%

by (21 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.