-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprintout.py
40 lines (29 loc) · 1.05 KB
/
printout.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import modules
import modules.init
def stringifyAction(a):
if hasattr(a, 'text') and hasattr(a, 'npc'):
suffix = ""
a_class = a.__class__.__name__.lower()
if a_class != "say":
suffix += f" #{a_class}"
if a_class == "ask":
suffix += f" [ {' | '.join([o[0]+' -> '+o[1] for o in a.options])} ]"
suffix += f" {a.var}"
return f"{a.npc.name}: {a.text}" + suffix
else:
return "//" + repr(a)
def stringifyModule(name):
story = getattr(modules, name).content
out_glides = list()
for glide, actions in story.glides.items():
out_actions = '\n'.join(map(stringifyAction, actions))
out_glides.append("@" + glide + "\n" + out_actions)
return "\n\n".join(out_glides)
import os.path
def exportModules(dest=""):
for name in modules.init.modules_deps.keys():
out = stringifyModule(name)
fp = os.path.join(dest, f"{name}.txt")
with open(fp, 'w') as out_f:
out_f.write(out)
print(f"`{fp}` write succesfully")