Created
August 13, 2023 14:52
-
-
Save Gnumaru/dfa8c76ada8da2a4983ef4beeae2827d to your computer and use it in GitHub Desktop.
"Test" scripts by loading them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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