Save story in plain text along the save
Not just saving in .json but also in plain text, should help story writers get their stories out more easily. Especially since they can technically add some markdown into their stories manually in the interface.
This commit is contained in:
parent
9b3e298089
commit
4151fd1b6a
24
aiserver.py
24
aiserver.py
|
@ -5,6 +5,7 @@
|
|||
#==================================================================#
|
||||
|
||||
# External packages
|
||||
import os
|
||||
from os import path, getcwd
|
||||
import re
|
||||
import tkinter as tk
|
||||
|
@ -1884,7 +1885,7 @@ def saveRequest(savpath):
|
|||
|
||||
# Save path for future saves
|
||||
vars.savedir = savpath
|
||||
|
||||
txtpath = os.path.splitext(savpath)[0] + ".txt"
|
||||
# Build json to write
|
||||
js = {}
|
||||
js["gamestarted"] = vars.gamestarted
|
||||
|
@ -1905,6 +1906,21 @@ def saveRequest(savpath):
|
|||
"constant": wi["constant"]
|
||||
})
|
||||
|
||||
ln = len(vars.actions)
|
||||
|
||||
if(ln > 0):
|
||||
chunks = collections.deque()
|
||||
i = 0
|
||||
for key in reversed(vars.actions):
|
||||
chunk = vars.actions[key]
|
||||
chunks.appendleft(chunk)
|
||||
i += 1
|
||||
|
||||
if(ln > 0):
|
||||
txt = vars.prompt + "".join(chunks)
|
||||
elif(ln == 0):
|
||||
txt = vars.prompt
|
||||
|
||||
# Write it
|
||||
file = open(savpath, "w")
|
||||
try:
|
||||
|
@ -1912,6 +1928,12 @@ def saveRequest(savpath):
|
|||
finally:
|
||||
file.close()
|
||||
|
||||
file = open(txtpath, "w")
|
||||
try:
|
||||
file.write(txt)
|
||||
finally:
|
||||
file.close()
|
||||
|
||||
print("{0}Story saved to {1}!{2}".format(colors.GREEN, path.basename(savpath), colors.END))
|
||||
|
||||
#==================================================================#
|
||||
|
|
Loading…
Reference in New Issue