Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Rename flags ("inputs" vs "actions"), display inputs somewhat better.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Heinrich Kuttler committed Oct 28, 2021
1 parent 02cc226 commit 8fcddb3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nle/scripts/ttyplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8fcddb3

Please sign in to comment.