I have an autoload global singleton that holds my player health and save point. The hud has a button that will emit signal save_pressed when pressed. I cannot connect this to my globals script. Any idea why?
(Button signal to hud is not in yet)
1 messages · Page 1 of 1 (latest)
I have an autoload global singleton that holds my player health and save point. The hud has a button that will emit signal save_pressed when pressed. I cannot connect this to my globals script. Any idea why?
(Button signal to hud is not in yet)
game crashes on lauch btw
$hud just looks at the autoload’s immediate children for a node named hud, on top of that you’re trying to connect the signal to the handler every frame, which will produce an error once you solve the node reference bug
You should probably connect the signal in your hud script’s _ready
Your scenes should reference the autoload, the autoload shouldn’t reference the scenes
Also final note, don’t do connect(“save_pressed”, save), instead do save_pressed.connect(save)
the error now is: save_pressed not declared in current scope
also the hud script was for some reason (most likey not saving) not connected to the hud node
Because it’s defined in the hud script, not in the autoload
yes, but when declared in the autoload, the same thing happens but in the hud script
Wdym? Put the signal in the hud, then in the hud’s _ready do save_pressed.connect(Globals.save)
I declare the signal in the global script, and the hud script should emit that when a button is pressed, but it the signal's not declared at that scope, even though it's a global script.
Because it declared on the autoload rather than the local scope, just like the error says
If you want it declared on the autoload like that then do all the connecting in the autoload
This happens when the button's pressed
otherwise no problems (button doesn't work still)
I just noticed you’re emitting the Callable in this screen shot for some reason
That’s why you’re seeing that error
You’re trying to pass a parameter to a signal that has no parameters
Should just be Globals.save_pressed.emit()