Add Lua API for story chunks

This commit is contained in:
Gnome Ann
2021-12-11 23:44:07 -05:00
parent 8e6a62259e
commit 36209bfe69
2 changed files with 174 additions and 0 deletions

View File

@ -1120,6 +1120,23 @@ def lua_resend_settings():
settingschanged()
refresh_settings()
#==================================================================#
# Set story chunk text and delete the chunk if the new chunk is empty
#==================================================================#
def lua_set_chunk(k, v):
assert type(k) in (int, None) and type(v) is str
assert k >= 0
assert k != 0 or len(v) != 0
if(len(v) == 0):
print(colors.PURPLE + f"[USERPLACEHOLDER] deleted story chunk {k}" + colors.END)
inlinedelete(k)
else:
if(k == 0):
print(colors.PURPLE + f"[USERPLACEHOLDER] edited prompt chunk" + colors.END)
else:
print(colors.PURPLE + f"[USERPLACEHOLDER] edited story chunk {k}" + colors.END)
inlineedit(k, v)
#==================================================================#
#
#==================================================================#
@ -1163,6 +1180,7 @@ bridged = {
"get_setting": lua_get_setting,
"set_setting": lua_set_setting,
"resend_settings": lua_resend_settings,
"set_chunk": lua_set_chunk,
"vars": vars,
}
try: