Add dice_selected signal

This commit is contained in:
CactiChameleon9 2022-07-17 14:32:42 +01:00
parent e2db1fef29
commit 929fc6291e

View File

@ -1,5 +1,7 @@
extends Control
signal dice_selected (dice_value)
const dice = preload("res://UI/Dice.tscn")
var selected : bool = false
@ -42,6 +44,14 @@ func _physics_process(delta):
# enable the selected shader
current_dice[selected_dice].selected = true
#if the enter key is pressed, remove the selected dice and emit the signal
if Input.is_action_just_pressed("ui_accept"):
emit_signal("dice_selected", current_dice[selected_dice].dice_value)
current_dice[selected_dice].queue_free()
current_dice.remove(selected_dice)
selected_dice = null
func roll_dice(specific_value : int = 0):
# make a new dice instance and add it to the grid container