I'm not 100% sure how you want your timer to work, but I can suggest a method of setting up a time system.
Create an autoload/singleton that acts as your timer that uses the following code:
#when we create this auoload, we'll call it "timer"
signal time_changed_to(time)
signal day_ended()
var active = true
var curr_time = 0
var day_time = x #total day time (in frames).
func _physics_process(_delta):
if active:
curr_time += 1
if curr_time < day_time:
emit_signal("time_changed_to", curr_time)
elif curr_time >= day_time:
emit_signal("day_ended")
active = false
Then you can connect nodes to the timer signals in their code. Lets say you have a node that has an event initiated that, in 10 seconds, you want to have it print "surprise!". You could do it via a function on that node like:
var queued_funcs = [
]
func _ready():
timer.connect("time_changed_to", self, "time_is_now")
func print_text(text):
print(text)
func queue_func(func_name, func_args, execute_time):
new_queue_func = {
"func_name" : func_name, #This is a string
"func_args" : func_args, #This is an array of arguments
"execute_time" : execute_time, #This is an int
}
queued_funcs.append(new_queue_func)
func time_is_now(time):
for func in queued_funcs:
#If func's stored time has passed
if func["execute_time"] >= time:
#Run the function using any stored arguments,
callv(func["func_name"], func["func_args"])
#Then remove the func from the queue
queued_funcs.erase(func)
func _process(_delta):
if Input.is_action_just_pressed("ui_accept"):
queue_func("print_text", ["surprise!"], timer.curr_time + 600)
Pressing ui_accept
(by default it's the enter key) will run the queue_func
function and make an entry with the specific details of what func to run, any arguments to run it with, and when to run it. A better methodology would probably be to move this whole queue process onto the timer node itself, and have other nodes tell the timer node a ref to themselves along with the details of the func execution. I used _physics_process
fopr the timer because it's going to run at a constant 60 frames per second. There's probably other ways of accomplishing this, but I like this method because it means you have a single, centralized timer to reference. Let me know if I should clarify anything.
You can read more about autoloads here: https://docs.godotengine.org/en/stable/getting_started/step_by_step/singletons_autoload.html
As for the second question, that's what object oriented is for. You can make a scene/class for a customer, then instance it and set up their details after creation. You can read more about instancing nodes through code here: https://docs.godotengine.org/en/latest/getting_started/step_by_step/resources.html?highlight=resources
But a simple summary is: https://godotengine.org/qa/36046/how-can-i-instance-by-code