0 votes

Hello,

I have a CanvasLayer/Control/Texture Button, where on pressed button I emit_signal. and print returns that the signal was emitted once.

Then in the ready function of the scenes listening I connect the signal.

get_node("GUI/Abilities").connect("emitted_signal", self, "OnConnect")

func OnConnect():
print(connected) 

The problem is that print(connected) prints out twice. Any ides why that would be ? Was looking into pressed/released related issues but I have other texture buttons under the GUI that work just OK with seemingly the same setup. Also I am pretty sure this was working when I set it up so I am mostly looking into what would cause this to happen. Any help appreciated.

Godot version 3.2.3.stable
in Engine by (44 points)

I would recommend to use breakpoint and print_stack() to debug this.

Thank you .
Frame 0 - res://Scenes/Enemies/Knight.gd:60 in function 'ready'
Frame 1 - res://GameRoot.gd:120 in function 'show
map'
Frame 2 - res://GameRoot.gd:39 in function '_ready'

So if I can read this correctly the GameRoot class which handles loading of the maps somehow triggers the function to run for the second time.

I need the code to say more

GameRoot code:

Frame2:

elif DataImport.load_slot == "Slot2" and (DataImport.save_data2["GameRoot"]["Map"]) == str("Map") and map_check.file_exists("user://savegame2.json") and DataImport.load_saved_game == true:
    show_map("Map")

Frame1:

func show_map(map_name):
    if self.current_map != null:
        get_child(2).queue_free()
    self.current_map = load(maps[map_name]).instance()
    if map == "Map":
        self.current_map.name = "Map"
    self.add_child(self.current_map,true)

Frame 0 code is above.

1 Answer

0 votes

I had an issue with PopupMenu sending two id_pressed() signals on a single click.
I wasn't been able to find the source of the problem, but mitigated it registering the start of handling method with OS.get_ticks_msec(). Ignored the next signal if it is received in less than 100ms (could be 1ms as well).

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