.w
.s
..x miscellaneous thing
To
>W
>S
>>X MISCELLANEOUS THING
It doesn't seem like much of a time saver but it's nice.
I also use >> for optional commands and > for necessary ones.
Of course I also play through my walkthroughs before submitting them, but I generally let them sit an hour or two before replaying them, so I make sure I'm not making any silly assumptions, or maybe I see there's something I can add.
I couldn't attach a file so I just pasted the text. Anyone who wants, steal and modify as you please. If it helps save someone work, great!
# nor.py: normalize walkthrough commands
import sys
import os
import re
import glob
from shutil import copy
nor_temp = "c:/games/inform/casa/normalize-temp.txt"
print_out = True
no_dotted_commands = True
def modify_command(my_line):
if not re.search("^[>.]", my_line):
return my_line
my_line = re.sub(r'^([.>][.>])+', lambda match: '>' * len(match.group(0)), my_line).upper()
my_line = re.sub("^[.>]", ">", my_line).upper()
return my_line
def parse_through(my_file):
new_to_write = ''
any_change = False
if not os.path.exists(my_file):
print("Can't find", my_file)
with open(my_file) as file:
for (line_count, line) in enumerate(file, 1):
if line.startswith(".") or line.startswith(">"):
new_line = modify_command(line)
if line != new_line:
any_change += 1
line = new_line
if no_dotted_commands and line.startswith(">") and '.' in line:
line = line.replace('.', "\n>")
new_to_write += line
if not any_change:
if print_out:
print("Unchanged", my_file)
return
print("Recopying", my_file, "with", any_change, "change{}".format('s' if any_change > 1 else ''))
f = open(nor_temp, "w")
f.write(new_to_write)
f.close()
copy(nor_temp, my_file)
file_list = []
try:
file_list = [ sys.argv[1] ]
except:
pass
if not file_list:
file_list = glob.glob("walkthrough*")
for f in file_list:
parse_through(f)