extends SceneTree ## Writes .tres copies of everything in [Content] into res://resources/, so the ## numbers can be tuned in the editor inspector. ## ## godot --headless --path . --script tools/export_content.gd ## ## These files are an export, not the source of truth: [Content] is. Re-running ## this overwrites them. If you tune a value in the inspector and want to keep ## it, port it back into src/content/content.gd -- otherwise the next export ## silently reverts your change. const OUT_ENEMIES := "res://resources/enemies" const OUT_BOSSES := "res://resources/bosses" func _init() -> void: DirAccess.make_dir_recursive_absolute(OUT_ENEMIES) DirAccess.make_dir_recursive_absolute(OUT_BOSSES) var written := 0 for id in Content.ALL_ENEMIES: written += _save(Content.enemy(id), "%s/%s.tres" % [OUT_ENEMIES, id]) for id in Content.ALL_BOSSES: written += _save(Content.boss(id), "%s/%s.tres" % [OUT_BOSSES, id]) print("exported %d resources" % written) quit(0) func _save(res: Resource, path: String) -> int: # Sub-resources (the emitters) are inlined so one file is one whole enemy. var err := ResourceSaver.save(res, path) if err != OK: printerr("failed to write %s (error %d)" % [path, err]) return 0 print(" ", path) return 1