Skip to content

Instantly share code, notes, and snippets.

@belzecue
Forked from GK-GreyGhost/screenshot.gd
Created October 7, 2022 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belzecue/3476e9b153c268de214e828d6131f61b to your computer and use it in GitHub Desktop.
Save belzecue/3476e9b153c268de214e828d6131f61b to your computer and use it in GitHub Desktop.
Create a folder in the format year-month-day and save the screenshot
func screenshot():
var img = get_viewport().get_texture().get_data()
img.flip_y()
var dir:Directory = Directory.new()
var now = OS.get_date()
var folder:String = 'user://screenshots/%s-%s-%s' % [now.year,now.month,now.day]
dir.make_dir_recursive(folder)
img.save_png(folder+'/%d.png' % OS.get_unix_time())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment