From 8fcddb383a46a06ae1b619c78a4c620b6613d6ec Mon Sep 17 00:00:00 2001 From: Heinrich Kuttler Date: Thu, 28 Oct 2021 18:35:31 +0200 Subject: [PATCH] Rename flags ("inputs" vs "actions"), display inputs somewhat better. For non-NetHack ttyrecs, the "\033[26;0f" doesn't work very well as it can jump "up", not down. But there's no good way to do this for all situations. --- nle/scripts/ttyplay.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nle/scripts/ttyplay.py b/nle/scripts/ttyplay.py index d5b52407b..a25cee56d 100644 --- a/nle/scripts/ttyplay.py +++ b/nle/scripts/ttyplay.py @@ -33,7 +33,7 @@ parser.add_argument( "-s", "--speed", default=1.0, type=float, help="Set playback speed multiplier" ) -parser.add_argument("-a", "--print-actions", action="store_true", help="Print actions") +parser.add_argument("-i", "--print_inputs", action="store_true", help="Print inputs") parser.add_argument( "-p", "--peek", action="store_true", help="Peek mode (like tail -f)" ) @@ -110,7 +110,7 @@ def read_header(f, peek=False, no_input=False): CLRCODE = re.compile(rb"\033\[2?J") # https://stackoverflow.com/a/37778152/1136208 -INPUTS = ["KeyPress %i" % i for i in range(255)] +INPUTS = ["KeyPress %s (%i)" % (repr(chr(i)), i) for i in range(255)] def process(f): @@ -165,7 +165,7 @@ def process(f): if channel == 0: # Output. os.write(1, data) - elif channel == 1 and FLAGS.print_actions: # Input. + elif channel == 1 and FLAGS.print_inputs: # Input. os.write( 1, b"\033[s\033[26;0f\033[37;1mFrame %d+%d:\033[0m " % tuple(frame) ) # Save Cursor & Jump to L26