Skip to content

Instantly share code, notes, and snippets.

@Gnumaru
Created August 13, 2023 14:52
Show Gist options
  • Save Gnumaru/dfa8c76ada8da2a4983ef4beeae2827d to your computer and use it in GitHub Desktop.
Save Gnumaru/dfa8c76ada8da2a4983ef4beeae2827d to your computer and use it in GitHub Desktop.
"Test" scripts by loading them
# ScriptTester.tscn
# ScriptTester.gd
@tool
extends Node
@export var mtool_do_test_scripts:bool:
get: return false
set(p):
mtool_do_test_scripts = false
if p: tool_do_test_scripts()
func _ready():
tool_do_test_scripts()
func tool_do_test_scripts():
var vscripts:Array = get_scripts_recursive('res://')
for i in vscripts:
if i.ends_with('IfSomeScriptCrashesGodotThenSkipItHere.gd'): continue
print(i)
load(i)
func get_scripts_recursive(ppath:String, presult:Array=[])->Array:
var vfiles:Array = DirAccess.get_files_at(ppath)
for ifile in DirAccess.get_files_at(ppath):
if ifile.ends_with('.gd'): presult.push_back(ppath+ifile)
var vdirs:Array = DirAccess.get_directories_at(ppath)
for idir in vdirs: get_scripts_recursive(ppath+idir+'/', presult)
return presult
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment