Merge pull request #70 from VE-FORBRYDERNE/patch

Don't throw an error in `update_story_chunk` if you try to edit a nonexistent chunk
This commit is contained in:
henk717 2022-01-22 23:24:34 +01:00 committed by GitHub
commit c9999b6388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -3242,6 +3242,8 @@ def update_story_chunk(idx: Union[int, str]):
else:
# Actions are 0 based, but in chunks 0 is the prompt.
# So the chunk index is one more than the corresponding action index.
if(idx - 1 not in vars.actions):
return
text = vars.actions[idx - 1]
item = html.escape(text)
@ -3373,6 +3375,8 @@ def inlineedit(chunk, data):
else:
if(chunk-1 in vars.actions):
vars.actions[chunk-1] = data
else:
print(f"WARNING: Attempted to edit non-existent chunk {chunk}")
setgamesaved(False)
update_story_chunk(chunk)
@ -3394,6 +3398,8 @@ def inlinedelete(chunk):
else:
if(chunk-1 in vars.actions):
del vars.actions[chunk-1]
else:
print(f"WARNING: Attempted to delete non-existent chunk {chunk}")
setgamesaved(False)
remove_story_chunk(chunk)
emit('from_server', {'cmd': 'editmode', 'data': 'false'}, broadcast=True)