Attempt to connect to nonexistent signal in code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By n0manarmy

I’m developing in mono and am trying to connect various buttons from other scenes to another scene to disable/enable movement buttons. I’ve been beating my head against a wall and have yet to figure out why this is happening.=

The project is here: https://github.com/n0manarmy/dwarf_jonesing/tree/dev_01.06.2021/src

I have my parent TravelPath _Ready connects the different scenes to the enable/disable location buttons based on signals.

The InfoScene/Scene01-13 fails to connect to DisableLocationButtons and StartValuesScene fails to connect to DisableLocationButtons.

WalkingPath/Scene01-13 does however connect to DisableLocationButtons and I cannot determine why?!

The error message I get when I start either the project, or TravelPath is below:

ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene01DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene02DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene03DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene04DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene05DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene06DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene07DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene09DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene10DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene11DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene12DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'Scene13DoneClicked' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
ERROR: In Object of type 'Node2D': Attempt to connect nonexistent signal 'GoalsValueDone' to method 'Node2D.DisableLocationsButtons'.
At: core/object.cpp:1503
:bust_in_silhouette: Reply From: miivers

I find runtime checks based on string hard to work with. You cant get help from the compiler and if a name changes then you need to remember to update all your strings.

If your project is entirely written in c# then I would consider using events. The compiler will help you with errors if you use it wrong or if the event name changes.

using Godot;
using System;
using System.Collections.Generic;


class MyFirstClass
{
    public delegate void SomeSignalWithIntArgument(int someInt);
    public event SomeSignalWithIntArgument OnSomeSignal;

    void Foo()
    {
        OnSomeSignal?.Invoke(123);
    }
}


class MySecondClass
{
    MySecondClass(MyFirstClass myFirstclass)
    {
        myFirstclass.OnSomeSignal += MyFirstclass_OnSomeSignal;
    }

    private void MyFirstclass_OnSomeSignal(int someInt)
    {
        throw new NotImplementedException();
    }
}
:bust_in_silhouette: Reply From: n0manarmy

Ugh, I figured it out…It was operator error

My signals were not instantiated within the class. My structures were like below. So of course they couldn’t find the signals, they weren’t associated with the class.

[Signal]
public delegate void MySignal();

class myClass: Node2D {
    def blah;
}