def main [game_folder: path, version: int] { let game = if $version == 10 { { folder: "mof", version: $version } } else if $version == 11 { { folder: "sa", version: $version } } else { return (error make {msg: "version not supported", label: { text: "expected 10 or 11", span: (metadata $version).span } }) exit 1 } let assets = $"assets/($game.folder)" mkdir $assets let thver = $"th($game.version)" thdat -C $assets -x $version $"($game_folder)/($thver).dat" try { ln -s $"($game_folder)/thbgm.dat" $"($assets)/thbgm.dat" } catch { } let research = $"research/dump/($game.folder)" mkdir $research let replt = {|ext| str replace $ext $"t($ext)"}; let dump = {|ext| ls $assets | get name | where {str ends-with $".($ext)"} | each {path basename} | each {|name| run-external $"tru($ext)" "decompile" "-g" $game.version $"($assets)/($name)" "-m" $"utils/($thver).($ext)m" | save -f $"($research)/($name | do $replt $ext)"} }; do $dump "anm" do $dump "ecl" do $dump "std" }