Randoloot/tests/economy_audit.gd
2026-10-20 19:53:03 +02:00

19 lines
797 B
GDScript

@tool
extends Node
func inspect_costs() -> Dictionary:
var result := {}
_scan("res://scripts", result)
return result
func _scan(path: String, result: Dictionary) -> void:
for file in DirAccess.get_files_at(path):
if not file.ends_with(".gd"): continue
var matches: Array[String] = []
var lines := FileAccess.get_file_as_string(path+"/"+file).split("\n")
for index in lines.size():
var line := lines[index]
if ("cost" in line.to_lower() or "deuter" in line.to_lower() or "upkeep" in line.to_lower() or "salary" in line.to_lower()) and not line.strip_edges().begins_with("#"):
matches.append("%d: %s" % [index+1,line.strip_edges()])
if not matches.is_empty(): result[path+"/"+file] = matches
for folder in DirAccess.get_directories_at(path):
_scan(path+"/"+folder,result)