0 votes

I'm using the script below to connect to the value_changed() signal of a HSlider.

func _ready():
    self.connect("value_changed", self, "_on_changed")

func _on_changed():
    print("value changed to " + str(value))

but when play the scene and drag the slide I receive this error in the debugger:

E 0:00:02.824 emitsignal: Error calling method from signal 'valuechanged': 'HSlider(SoundIconSet.gd)::onchanged': Method expected 0 arguments, but called with 1..
<C++ Source> core/object.cpp:1228 @ emit_signal()

please advise.

Godot version 3.2.1
in Engine by (20 points)

1 Answer

0 votes

After a bit of trial and error, and more studying I realized my mistake.
the value_changed signal sends a value which onchanged() function needs to receive.

this fixed the problem:

func _ready():
    self.connect("value_changed", self, "_on_changed")

func _on_changed(v):
    print("value changed to " + str(v))

the argument v is the amount sent by value_changed

by (20 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.
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 webmaster@godotengine.org with your username.