Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends Node
- ###============================================================================
- ## === AT THE CURRENT MOMMENT THIS HAS NO EFFECT ON SKY3D ONLY TIME_DISPLAY ===
- @onready var time_of_day: TimeOfDay = $Enviro/Sky3D/TimeOfDay
- @onready var secondhand: Timer = $Body/Neck/Head/eyes/third_person/Time_display/secondhand
- @onready var clock_display = $Player/Time_display
- ##================THIS NEEDS TO BE WORKD ON ===================================
- @export var FOCUS_TIME: float = 1440 #Good guy 1 sec = 1 sec
- @export var REGULAR_TIME: float = 1440 / 10 #Good Guy 1 sec = 10 secs
- @export var PANIC_TIME: float = 1440 / 60 #Good Guy 1 sec = 1 min
- @export var WARPED_TIME: float = 1440 / 2400 # WANK!
- var daylength: float = REGULAR_TIME # default starting speed
- var is_paused: bool = false
- ##=============================================================================
- # Start and end time as in-game values (24-hour clock)
- @export var START_TIME = {"H": 21, "M": 32, "S": 0}
- @export var END_TIME = {"H": 11, "M": 34, "S": 18}
- # Converted to decimal time
- @export var DAY_START = 21.533
- @export var DAY_END = 11.571
- func _ready() -> void:
- update_time_speed(daylength)
- # Set the starting time
- clock_display.H = START_TIME["H"]
- clock_display.M = START_TIME["M"]
- clock_display.S = START_TIME["S"]
- func _input(event):
- if event is InputEventKey and event.pressed:
- match event.keycode:
- KEY_1:
- update_time_speed(FOCUS_TIME)
- KEY_2:
- update_time_speed(REGULAR_TIME)
- KEY_3:
- update_time_speed(PANIC_TIME)
- KEY_4:
- update_time_speed(WARPED_TIME)
- KEY_5:
- toggle_pause()
- func update_time_speed(new_daylength: float) -> void:
- daylength = new_daylength
- time_of_day.total_cycle_in_minutes = 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 = clock_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