extends Node
## Compile check with the autoloads present (content agent 2026-10-02): run the scene
##   Godot --headless --path game res://scripts/tools/load_check.tscn -- --check=res://a.gd,res://b.gd
## loads each script (parse + compile errors go to the log as usual) and prints "LOADCHECK ok|BAD <path>".


func _ready() -> void:
	var bad := 0
	for a in OS.get_cmdline_user_args():
		if not a.begins_with("--check="):
			continue
		for p in a.substr(8).split(",", false):
			var s = load(p)
			var ok: bool = s is Script and (s as Script).can_instantiate()
			if not ok:
				bad += 1
			print("LOADCHECK %s %s" % ["ok " if ok else "BAD", p])
	print("LOADCHECK done bad=%d" % bad)
	get_tree().quit(1 if bad > 0 else 0)
