Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### = = = = = = = = = = = = =Custom Variables = = = = = = = = = = = = = = = = = = = = = = = = = = =
- @onready var time_display: RichTextLabel = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/time_display"
- @onready var secondhand: Timer = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/time_display/secondhand"
- @onready var hide_timer: Timer = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/Pace-maker/hide_timer"
- @onready var paused: RichTextLabel = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/Pace-maker/paused"
- @onready var calender: RichTextLabel = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/time_display/Calender"
- @onready var daylength: = tod.total_cycle_in_minutes
- ##================THIS NEEDS TO BE WORKD ON ===================================
- var FOCUS_TIME: float = 1440 #Good guy 1 sec = 1 sec
- var REGULAR_TIME: float = 1440 / 10 #Good Guy 1 sec = 10 secs
- var PANIC_TIME: float = 1440 / 60 #Good Guy 1 sec = 1 min
- var WARPED_TIME: float = 1440 / 120 # WANK!
- # Start and end time as in-game values (24-hour clock)
- var START_TIME = {"H" : 21.0, "M" : 32.0, "S" : 0.0}
- var END_TIME = {"H" : 11.0, "M" : 34.0, "S" : 18.0}
- # Converted to decimal time
- var DAY_START = 21.533
- var DAY_END = 11.571
- var is_paused: bool = false
- var wait_time: float
- #### = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- ## Sandman v.4 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
- func _ready() -> void:
- await get_tree().process_frame # Debugging check for secondhand
- if secondhand:
- secondhand.wait_time = wait_time
- else:
- push_error("Secondhand timer not found!")
- # Ensure time_display exists before using it
- if time_display:
- print("time_display found:", time_display)
- else:
- push_error("time_display not found!")
- # Ensure calendar node exists
- if calender:
- print("calender found:", calender)
- else:
- push_error("calender node not found! Did you mean 'Calendar'?")
- # Ensure timers exist before using them
- if hide_timer:
- print("hide_timer initialized.")
- else:
- push_error("hide_timer not found!")
- if paused:
- print("paused label found.")
- else:
- push_error("paused label not found!")
- # Update time speed after confirming tod exists
- if tod:
- update_time_speed(REGULAR_TIME)
- var time_of_day = tod
- else:
- push_error("Time of day system (tod) not found!")
- update_time_speed(daylength)
- # Set the starting time
- time_display.H = START_TIME["H"]
- time_display.M = START_TIME["M"]
- time_display.S = START_TIME["S"]
- func _input(event):
- if Input.is_action_just_pressed("focus_time"):
- update_time_speed(FOCUS_TIME)
- if Input.is_action_just_pressed("regular_time"):
- update_time_speed(REGULAR_TIME)
- if Input.is_action_just_pressed("panic_time"):
- update_time_speed(PANIC_TIME)
- if Input.is_action_just_pressed("warped_time"):
- update_time_speed(WARPED_TIME)
- if Input.is_action_just_pressed("pause_time"):
- toggle_pause()
- func update_time_speed(new_daylength: float) -> void:
- daylength = new_daylength
- var seconds_per_game_second = (daylength * 60.0) / 86400.0
- secondhand.wait_time = seconds_per_game_second
- if not is_paused:
- secondhand.start()
- func toggle_pause() -> void:
- is_paused = !is_paused
- if is_paused:
- secondhand.stop()
- else:
- secondhand.start()
- # Called by the Timer every tick — add this to Time_display.gd script
- func check_if_time_reached():
- var clock = time_display
- if clock.H == END_TIME["H"] and clock.M == END_TIME["M"] and clock.S == END_TIME["S"]:
- get_tree().paused = true # Or your own game-ending logic
- print("End time reached.")
- ## = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Add Comment
Please, Sign In to add comment