- Edited
Hi all, thank you all for helping me ask around regarding the question I had over at https://godotforums.org/d/36639-wanting-to-add-timer-to-confirm-selection-of-object-rock-paper-scissors which wasn't ideal of what I was asking as I was asking a fair bit there. Learning still to segment down to nitty gritty.. After further looking around I managed to figure out how to add a timer! That's a start..
Anyways my next question is:
I have added code so that when the up or down buttons are pressed the timer starts so that a selection is made before the time runs out. However I can't seem to figure out how to ignore additional starts of the timer as I don't want that. All I want is for the up or down to initiate the timer from 10 seconds down and not reset when I press up or down again.
Snipets of the code related to my question I have so far:
Globals.gd (attached to the main stage scene):
@export var round_time = 10
var timer_node = null
var time_left
func _ready():
time_left = round_time
func start_timer():
timer_node = Timer.new()
timer_node.name = "Round Timer"
timer_node.wait_time = 1
timer_node.timeout.connect(on_round_timer_timeout)
add_child(timer_node)
timer_node.start()
func on_round_timer_timeout():
time_left -= 1
print(time_left)
if time_left < 0:
timer_node.stop()
print("result")
Player.gd:
if Input.is_action_just_pressed("up"):
_scroll(1)
gl.start_timer()
elif Input.is_action_just_pressed("down"):
_scroll(-1)
gl.start_timer()```
Also how do I lock the input once the time runs out?