Don’t think you need the brackets here [as] you have no args. That said, your signal is in response to _on_restart_button_button_down, which the post doesn’t show how this is triggered; assuming it would be connected via the editor, it’d be helpful to show your working.
Perhaps even via a small reproducible test case as this is fairly trivial overall and unlikely to be failing without some minor config. issue.
Can you make something that looks like this with all the appropriate Inspector functions.
Then maybe we can discuss trying this.
Game Manager
extends Node
var score = 0
var difficulty = 1
var is_game_over = false
signal update_score
signal player_died
func increase_score(): # Must be called at some point, like killing an enemy
score += 1
difficulty += 0.03
update_score.emit()
print(score) # This will print the score as it increases
func game_over():
print("GAME OVER") # This is output
print("You obtained " + str(score) + " Points") # This is just the next line of the output
player_died.emit()
# Everything below must happen last because it effects content above
score = 0
difficulty = 1
is_game_over = true
func _unhandled_input(event):
if event is InputEventKey:
if event.pressed and event.keycode == KEY_ESCAPE:
game_over()
User Interact
extends CanvasLayer
func _on_game_manager_update_score():
$ScorePanel/ScoreText.text = str(get_parent().score) # This will simply pillage the village and eventually it will do what it must
func _on_game_manager_player_died():
$DeathPanel.show()
$DeathPanel/DeathTitle.text = "FINAL SCORE " + str(get_parent().score)
func _on_restart_button_pressed():
$DeathPanel.hide()
print("Restarding")
get_parent().is_game_over = false
You can just double click or right click for more option. On signals in the inspector. To bring up the node window. Select whatever you like. Click connect. The code is automatic like that. With #pass
You can also make more functions and variables to fill more signals. As long as they have their uses.
There is a commemorating amount of speculation you can only use 1 Script per code. Not true. If you were to extend a script. The predefined extension is provided. All you can do is use it. Just save it as you progress your scripts.
All of this works. As long as it has an article to extend to. Right now you can get prints.
So you can extend your current and extended code.
Game Manager
extends Node
var score = 0
var difficulty = 1
var is_game_over = false
var play_allowed = false
signal update_score
signal player_died
signal defend
signal damage
func increase_score(): # Must be called at some point, like killing an enemy
score += 1
difficulty += 0.03
update_score.emit()
print(score) # This will print the score as it increases
func game_over():
print("GAME OVER") # This is output
print("You obtained " + str(score) + " Points") # This is just the next line of the output
if play_allowed: # Can be inserted anywhere, with proportional function block
player_died.emit()
play_allowed = false # Will revert to normals
# Everything below must happen last because it effects content above
score = 0
difficulty = 1
is_game_over = true
func _unhandled_input(event):
if event is InputEventKey:
if event.pressed and event.keycode == KEY_ESCAPE:
game_over()
func play():
play_allowed = true
func go_defend():
defend.emit()
func treated_as_enemy():
print("You are getting attacked!")
print("At the minimum " + str(score) + " !")
func take_damage():
damage.emit()
game cleric
extends "res://GameManager.gd"
signal threat
signal factorial
signal deterent
var allowed = false
var shred = true
func _on_player_died(): # This is the active passthrough field
if allowed == true:
play()
func _on_threat():
treated_as_enemy() # This is an extra function to declare attack
func _on_deterent():
print("Marker change.") # This is an extra function to declare defense
func _on_defend():
threat.emit()
deterent.emit()
func _on_damage():
if shred:
print("Do you allow?" )
shred = false
factorial.emit()
func _on_factorial():
shred = true
User Interact
extends CanvasLayer
func _on_game_manager_update_score():
$ScorePanel/ScoreText.text = str(get_parent().score) # This will simply pillage the village and eventually it will do what it must
func _on_game_manager_player_died():
$DeathPanel.show()
$DeathPanel/DeathTitle.text = "FINAL SCORE " + str(get_parent().score)
func _on_restart_button_pressed():
$DeathPanel.hide()
print("Restarding")
get_parent().is_game_over = false