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()`
asked Apr 23 in Engine by SereneMango (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 _%

answered Apr 23 by SereneMango (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 How to use this Q&A? before posting your first questions.