2022-10-21 09:42:42 +00:00
|
|
|
extends Node
|
|
|
|
|
2023-03-06 22:52:14 +00:00
|
|
|
@onready var important_vars = $"/root/MainStartScreen/impvars"
|
2022-10-21 09:42:42 +00:00
|
|
|
|
|
|
|
var time = Time.get_datetime_dict_from_system()
|
|
|
|
var dayofweek = time["weekday"]
|
|
|
|
var day_number = time["day"]
|
|
|
|
var month_number = time["month"]
|
|
|
|
var year_number = time["year"]
|
|
|
|
var dayofweek_word
|
|
|
|
var month_word
|
|
|
|
var clock = Time.get_time_dict_from_system()
|
|
|
|
|
|
|
|
var refresh_timer = 0
|
|
|
|
var waiting_timer = 10000
|
|
|
|
signal timer_beat
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
# warning-ignore:return_value_discarded
|
2023-03-06 22:52:14 +00:00
|
|
|
connect("timer_beat",Callable(self,"on_timer_beat"))
|
2022-10-21 09:42:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Give the day a unique number
|
|
|
|
important_vars.day_uid = str(day_number) + str(month_number) + str(year_number)
|
|
|
|
important_vars.day_uid2 = str(day_number) + str(month_number) + str(year_number)
|
|
|
|
|
|
|
|
# A really long-winded way to convert an array. There is a better way to map it. Will update
|
|
|
|
# once I know.
|
|
|
|
|
|
|
|
if dayofweek == 0:
|
|
|
|
dayofweek_word = "Sunday"
|
|
|
|
|
|
|
|
if dayofweek == 1:
|
|
|
|
dayofweek_word = "Monday"
|
|
|
|
|
|
|
|
if dayofweek == 2:
|
|
|
|
dayofweek_word = "Tuesday"
|
|
|
|
|
|
|
|
if dayofweek == 3:
|
|
|
|
dayofweek_word = "Wednesday"
|
|
|
|
|
|
|
|
if dayofweek == 4:
|
|
|
|
dayofweek_word = "Thursday"
|
|
|
|
|
|
|
|
if dayofweek == 5:
|
|
|
|
dayofweek_word = "Friday"
|
|
|
|
|
|
|
|
if dayofweek == 6:
|
|
|
|
dayofweek_word = "Saturday"
|
|
|
|
|
|
|
|
|
|
|
|
if month_number == 1:
|
|
|
|
month_word = "January"
|
|
|
|
|
|
|
|
if month_number == 2:
|
|
|
|
month_word = "February"
|
|
|
|
|
|
|
|
if month_number == 3:
|
|
|
|
month_word = "March"
|
|
|
|
|
|
|
|
if month_number == 4:
|
|
|
|
month_word = "April"
|
|
|
|
|
|
|
|
if month_number == 5:
|
|
|
|
month_word = "May"
|
|
|
|
|
|
|
|
if month_number == 6:
|
|
|
|
month_word = "June"
|
|
|
|
|
|
|
|
if month_number == 7:
|
|
|
|
month_word = "July"
|
|
|
|
|
|
|
|
if month_number == 8:
|
|
|
|
month_word = "August"
|
|
|
|
|
|
|
|
if month_number == 9:
|
|
|
|
month_word = "September"
|
|
|
|
|
|
|
|
if month_number == 10:
|
|
|
|
month_word = "October"
|
|
|
|
|
|
|
|
if month_number == 11:
|
|
|
|
month_word = "November"
|
|
|
|
|
|
|
|
if month_number == 12:
|
|
|
|
month_word = "December"
|
|
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
func _process(_delta):
|
|
|
|
refresh_timer += 1
|
|
|
|
if refresh_timer > waiting_timer:
|
|
|
|
refresh_timer = 0
|
|
|
|
emit_signal("timer_beat")
|
|
|
|
print("Beat!")
|
|
|
|
|
|
|
|
func on_timer_beat():
|
|
|
|
important_vars.day_uid2 = str(day_number) + str(month_number) + str(year_number)
|
2023-04-21 06:43:54 +00:00
|
|
|
print("Yup! We're changing days if we need to")
|
2022-10-21 09:42:42 +00:00
|
|
|
if important_vars.day_uid != important_vars.day_uid2:
|
|
|
|
get_tree().reload_current_scene()
|