Run a function the very first time the user starts the game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Godot_Starter

What I want is to run a function the very first time the user starts the game.

I want to create a folder structure in user:// I can use later when I save the game and I figured out how to but I dont want to do that every time the game starts. What is the cleanest solution to run a function only the very first time?

:bust_in_silhouette: Reply From: Mak

Directory.dir_exists ( String path ) → bool

Returns whether the target directory exists. The argument can be relative to the current directory, or an absolute path.

You can use this function to check whether the folder structure has already been created.

:bust_in_silhouette: Reply From: Help me please

ok! I don’t know exactly how but it can help

func _ready():
	var file = File.new()
	if file.file_exists("user://###"):
		pass
	else:
		#create your file or folder here