23 lines
683 B
GDScript
23 lines
683 B
GDScript
extends Timer
|
|
|
|
var base_path = "user://screenshots/"
|
|
var session_path = ""
|
|
var count = 0
|
|
|
|
func _ready():
|
|
# Generate a timestamp
|
|
var datetime = Time.get_datetime_dict_from_system()
|
|
var timestamp = "%d-%02d-%02d_%02d-%02d-%02d" % [datetime.year, datetime.month, datetime.day, datetime.hour, datetime.minute, datetime.second]
|
|
|
|
# Create a session-specific subdirectory
|
|
session_path = base_path + timestamp + "/"
|
|
if not DirAccess.dir_exists_absolute(session_path):
|
|
DirAccess.make_dir_recursive_absolute(session_path)
|
|
|
|
_on_timeout()
|
|
|
|
func _on_timeout():
|
|
var image = get_viewport().get_texture().get_image()
|
|
image.save_png(session_path + ("%010d"%count) + ".png")
|
|
count += 1
|