|Topic was automatically imported from the old Question2Answer platform.
Hi guys. I’ve been racking my brains over why a function I wrote would’t work (I kept getting a single-word red error msg in the Debugger:
Breakpoint. I’d gone through the code like a hundred times and decided it had to be correct. Finally, I clicked the red dot (skip breakpoints) and suddenly all is working as intended. I then re-enabled breakpoints (clicked the red dot again) without changing anything in the code and it kept working correctly as if there never was a ‘breakpoint’. What is the point of those breakpoints? What was Godot trying to tell me?
The other question I have about the Debugger is: why does it show me errors for each signal I connect to a function? I have a bunch of signals scattered around my in various scripts (always inside of
_ready()), all connected to functions. I emit them when I need them to trigger a function they’re connected to. When I start the game I always get a list of all my connected signals in the Debugger with the same error message for each:
W 0:00:00.258 The function 'connect()' returns a value, but this value is never used.
<C++ Error> RETURN_VALUE_DISCARDED
Well of course it’s not used. I’ll use it when the signal is emitted. What’s this error for?
What is the point of those breakpoints?
Breakpoints are for debugging a project and are set by the developer. A breakpoint can be placed at any line of code and whenever that line is executed, the engine will halt the game and give you the chance to inspect e.g. the value of certain variables to determine when things go wrong and why. You probably set one accidentally, by left-clicking the area on the left of the line-numbers. Existing breakpoints are indicated with a tiny red square and can be removed again by clicking on it.
why does it show me errors for each signal I connect
Check the documentation. A call to
connect() is not returning nothing (
void) but an
Error instead. Which is an enum that tells if you everything works according to plan (then its value is 0) or not (then it’s something else). What you get is a warning (not an error!) about the fact that you are not checking that error variable.
The technically correct-way of doing it would be:
var error_code = connect("dummy", self, "_on_dummy")
# or do something else about the error
As it’s only a warning you can also disable it under Project > Project Settings… > Debug > Gdscript > Return Value Discarded, but I wouldn’t recommend that.
Thanks! I read a thread on github where someone suggested wrapping each connect() into an assertion, which I did and indeed, the warnings are gone.
You’re right, they’re not errors per se, just warnings (yellow dots). It does say c++error in the debugger tho.
Macryc | 2020-04-16 15:54