Can't call AutoLoad Singleton functions from some nodes?

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

So I have a script that I’m using as a manager for my game, it’s an AutoLoad with Singleton engaged. For some reason, if I use the parent node to call a function in the AutoLoad it works fine, but when I ask one of it’s children’s children’s children (sorry just to be accurate) to call up that same function it doesn’t work and Godot crashes. If I ask it to run a function in the parent node, which THEN runs the AutoLoad function, it also crashes. Any ideas why this is happening and what I can do?
Thank you!

The singleton itself should work fine. When you say Godot crashes, does it really crash, or are you getting an error? If it’s an error, what’s the error? What’s in the Singleton? What does the problematic cod that’s calling it look like?

jgodfrey | 2020-11-14 21:43

Hi jgodfrey!
So it tries, and basically just gives up and shuts down the game, no messages at all, just “Debug process stopped”. The functions are really simple, it’s literally just:

child child child: (function is called by a child that 's a texturebutton being pressed)
func .shop_icall():

parent node (has signal connected to this function, manager is the autoload)
func shop_jcall():“shop_call”)

func shop_call():
do stuff

Breakpoints show it works all the way up to calling the function in Manager, and running the function in the parent node works fine. That’s especially weird as it works in the parent node, but then it works from the child to the parent, but NOT the parent node in that case…

powderblue042 | 2020-11-14 21:48

Ok update, it turns out if I breakpoint the function, the Manager stops when the function is called, by the parent node, or the TextureButton, but after the TextureButton it doesn’t succeed in doing the function (I set it to just print something which it did fine with the parent node).

powderblue042 | 2020-11-14 21:57

First, you should be able to call that Singleton function from other nodes via:


What happens if you replace the body of the Manager.shop_call() with a simple print("shop_call called") or similar? Does it print with each expected call? Do you still get the crash?

jgodfrey | 2020-11-14 21:58

Hi jgodfery,
Yes so the function is currently just a simple print to check it’s working, and it fails like I said above only if I use the child node, or refer from the child node back to the parent.

powderblue042 | 2020-11-14 22:00

Ok, more strangeness. The function doesn’t work if I put in into another node within the scene, same crashing.

powderblue042 | 2020-11-14 22:04

Is the project available somewhere to look at?

jgodfrey | 2020-11-14 22:06

Good point, no not at the moment. It’s a project, and a bit of a secret. I can add some screengrabs?

powderblue042 | 2020-11-14 22:07

Yeah, I think it’ll be tough to provide much assistance without having access to the code…

jgodfrey | 2020-11-14 22:10

Codes are here:

Ignore the if in the Shops node, it’s always true right now.

powderblue042 | 2020-11-14 22:15

Ok, I’ve managed to solve this by putting the script to start the AutoLoad function within the button itself. Happy to keep looking for an answer in case it could be useful to someone who stumbles upon this question, otherwise I’m happy. :slight_smile:
Thanks for your help.

powderblue042 | 2020-11-14 23:27