how connect buttons to event-bus singleton?

boruokboruok Posts: 19Member
edited October 2019 in Programming
i've watched godotcon2019 where they talks about event bus, you just put all your signal intro one singleton script.

extends Node

func _ready():
    events.connect('button_pressed', self,'_on_Event_button_pressed')

func _on_Event_button_pressed(name):
    print(name) - singleton

extends Node

signal button_pressed(name) - have multiple buttons in a scene what shares that script

extends TextureButton

func _ready():
    events.connect('button_pressed', self, '_pressed')

func _pressed():
    events.emit_signal('button_pressed', name)

well, method works , but i catch multiple errors everytime when i press:

E 0:00:02:0401   Error calling

  <C Source>     core/object.cpp:1238 @ emit_signal()
  <Stack Trace> @ _pressed()

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file