Add an option to specify a custom output filename

This commit is contained in:
Bonta-kun 2019-12-15 17:29:17 +01:00
parent 7e9ab6ce27
commit 5bdc01e48f
2 changed files with 10 additions and 3 deletions

View File

@ -256,6 +256,7 @@ def start():
parser.add_argument('--names', default='')
parser.add_argument('--outputpath')
parser.add_argument('--race', default=False, action='store_true')
parser.add_argument('--outputname')
args = parser.parse_args()
if args.outputpath and os.path.isdir(args.outputpath):

12
Main.py
View File

@ -136,8 +136,14 @@ def main(args, seed=None):
sprite = None
player_names = parse_names_string(args.names)
outfileprefix = 'ER_%s_' % world.seed
outfilesuffix = '%s_%s-%s-%s-%s%s_%s-%s%s%s%s%s' % (world.logic, world.difficulty, world.difficulty_adjustments, world.mode, world.goal, "" if world.timer in ['none', 'display'] else "-" + world.timer, world.shuffle, world.algorithm, mcsb_name, "-retro" if world.retro else "", "-prog_" + world.progressive if world.progressive in ['off', 'random'] else "", "-nohints" if not world.hints else "")
outfileprefix = 'ER_%s' % (args.outputname if args.outputname else world.seed)
outfilesuffix = ('_%s_%s-%s-%s-%s%s_%s-%s%s%s%s%s' % (world.logic, world.difficulty, world.difficulty_adjustments,
world.mode, world.goal,
"" if world.timer in ['none', 'display'] else "-" + world.timer,
world.shuffle, world.algorithm, mcsb_name,
"-retro" if world.retro else "",
"-prog_" + world.progressive if world.progressive in ['off', 'random'] else "",
"-nohints" if not world.hints else "")) if not args.outputname else ''
outfilebase = outfileprefix + outfilesuffix
use_enemizer = args.enemizercli and (args.shufflebosses != 'none' or args.shuffleenemies or args.enemy_health != 'default' or args.enemy_health != 'default' or args.enemy_damage or args.shufflepalette or args.shufflepots)
@ -186,7 +192,7 @@ def main(args, seed=None):
rom.write_bytes(int(addr), values)
apply_rom_settings(rom, args.heartbeep, args.heartcolor, world.quickswap, world.fastmenu, world.disable_music, sprite, player_names)
outfilepname = f'P{player}_' if world.players > 1 else '' + f'{player_names[player]}_' if player in player_names else ''
outfilepname = f"{f'_P{player}' if world.players > 1 else ''}{f'_{player_names[player]}' if player in player_names else ''}"
rom.write_to_file(output_path(f'{outfileprefix}{outfilepname}{outfilesuffix}.sfc'))
with open(output_path('%s_multidata' % outfilebase), 'wb') as f: