lil_sue

Sandman v.4.0

May 15th, 2025 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDScript 3.78 KB | Gaming | 0 0
  1. #### = = = = = = = = = = = = =Custom Variables = = = = = = = = = = = = = = = = = = = = = = = = = = =
  2. @onready var time_display: RichTextLabel = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/time_display"
  3. @onready var secondhand: Timer = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/time_display/secondhand"
  4. @onready var hide_timer: Timer = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/Pace-maker/hide_timer"
  5. @onready var paused: RichTextLabel = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/Pace-maker/paused"
  6. @onready var calender: RichTextLabel = $"../../Player/CharacterBody3D/Body/Neck/Head/eyes/Camera3D/time_display/Calender"
  7. @onready var daylength: = tod.total_cycle_in_minutes
  8.  
  9. ##================THIS NEEDS TO BE WORKD ON ===================================
  10. var FOCUS_TIME: float = 1440 #Good guy 1 sec = 1 sec
  11. var REGULAR_TIME: float = 1440 / 10 #Good Guy 1 sec = 10 secs
  12. var PANIC_TIME: float = 1440 / 60 #Good Guy 1 sec = 1 min
  13. var WARPED_TIME: float = 1440 / 120 # WANK!
  14.  
  15. # Start and end time as in-game values (24-hour clock)
  16. var START_TIME = {"H" : 21.0, "M" : 32.0, "S" : 0.0}
  17. var END_TIME = {"H" : 11.0, "M" : 34.0, "S" : 18.0}
  18. # Converted to decimal time
  19. var DAY_START = 21.533
  20. var DAY_END = 11.571
  21.  
  22. var is_paused: bool = false
  23. var wait_time: float
  24. #### = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  25.  
  26. ## Sandman v.4 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  27. func _ready() -> void:
  28.     await get_tree().process_frame  # Debugging check for secondhand
  29.     if secondhand:
  30.         secondhand.wait_time = wait_time
  31.     else:
  32.         push_error("Secondhand timer not found!")
  33.  
  34.     # Ensure time_display exists before using it
  35.     if time_display:
  36.         print("time_display found:", time_display)
  37.     else:
  38.         push_error("time_display not found!")
  39.  
  40.     # Ensure calendar node exists
  41.     if calender:
  42.         print("calender found:", calender)
  43.     else:
  44.         push_error("calender node not found! Did you mean 'Calendar'?")
  45.  
  46.     # Ensure timers exist before using them
  47.     if hide_timer:
  48.         print("hide_timer initialized.")
  49.     else:
  50.         push_error("hide_timer not found!")
  51.  
  52.     if paused:
  53.         print("paused label found.")
  54.     else:
  55.         push_error("paused label not found!")
  56.  
  57.     # Update time speed after confirming tod exists
  58.     if tod:
  59.         update_time_speed(REGULAR_TIME)
  60.         var time_of_day = tod
  61.     else:
  62.         push_error("Time of day system (tod) not found!")
  63.     update_time_speed(daylength)
  64.     # Set the starting time
  65.     time_display.H = START_TIME["H"]
  66.     time_display.M = START_TIME["M"]
  67.     time_display.S = START_TIME["S"]
  68.    
  69. func _input(event):
  70.     if Input.is_action_just_pressed("focus_time"):
  71.                 update_time_speed(FOCUS_TIME)
  72.     if Input.is_action_just_pressed("regular_time"):
  73.                 update_time_speed(REGULAR_TIME)
  74.     if Input.is_action_just_pressed("panic_time"):
  75.                 update_time_speed(PANIC_TIME)
  76.     if Input.is_action_just_pressed("warped_time"):
  77.                 update_time_speed(WARPED_TIME)
  78.     if Input.is_action_just_pressed("pause_time"):
  79.                 toggle_pause()
  80.  
  81. func update_time_speed(new_daylength: float) -> void:
  82.     daylength = new_daylength
  83.     var seconds_per_game_second = (daylength * 60.0) / 86400.0
  84.     secondhand.wait_time = seconds_per_game_second
  85.  
  86.     if not is_paused:
  87.         secondhand.start()
  88.  
  89. func toggle_pause() -> void:
  90.     is_paused = !is_paused
  91.     if is_paused:
  92.         secondhand.stop()
  93.     else:
  94.         secondhand.start()
  95.  
  96. # Called by the Timer every tick — add this to Time_display.gd script
  97. func check_if_time_reached():
  98.     var clock = time_display
  99.     if clock.H == END_TIME["H"] and clock.M == END_TIME["M"] and clock.S == END_TIME["S"]:
  100.         get_tree().paused = true  # Or your own game-ending logic
  101.         print("End time reached.")
  102.  
  103. ## = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
  104.  
Add Comment
Please, Sign In to add comment