Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading a story state doesn't rollback the error stack #29

Open
paulloz opened this issue Jan 25, 2021 · 2 comments
Open

Loading a story state doesn't rollback the error stack #29

paulloz opened this issue Jan 25, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@paulloz
Copy link

paulloz commented Jan 25, 2021

Hey 馃槃

Let's consider the following code.

var state = self.story.state.to_json()
# any action resulting in an error being stacked for interruption 
self.story.state.load_json(state)
if self.story.can_continue:
    self.story.continue()

The expected behavior would be for everything after the new state is loaded to go on smoothly. But at the moment, story execution will stop when continue() is called and the stacked error will be displayed. The error stack needs to be cleared out and InkRuntime.should_interrupt should be reset.

The tricky part would be to determine if some errors are from before the state was saved or not.
E.g.

var state1 = self.story.state.to_json()
# any action resulting in an error being stacked for interruption 
var state2 = self.story.state.to_json()
# any action resulting in an error being stacked for interruption 
self.story.state.load_json(state1|state2)

Depending on which state (state1 or state2) is loaded on the last line, the rollback should probably not be the same.


Environment:

  • OS: Windows 10 Pro
  • Godot version: v3.2.3
  • inkgd version: 96b743b
@ephread
Copy link
Owner

ephread commented Jan 31, 2021

That's a very good catch, thanks for raising it!

I've made error reporting more explicit in the latest version. Now, in debug, the execution is interrupted immediately when the runtime encounters an error.

The error stack needs to be cleared out and InkRuntime.should_interrupt should be reset.

Good idea, setting the state should clear everything and restore the story. I'll make it happen!

I originally didn't want to allow the story to continue because of the lack of exceptions in GDScript. I'm not certain that my home-cooked logic based on InkRuntime.should_interrupt preserves a workable state when an exception is raised. But restoring a state should provide a clean slate. I'll mention this in Differences with the C# API.

The tricky part would be to determine if some errors are from before the state was saved or not.

I think it would be nearly impossible to do properly in inkgd. Resetting InkRuntime.should_interrupt is probably enough, but I'll monitor this.

@paulloz
Copy link
Author

paulloz commented Jan 31, 2021

I think it would be nearly impossible to do properly in inkgd. Resetting InkRuntime.should_interrupt will probably be enough, but I'll monitor this.

Yes, imho the only right way would be to embed that information into the state itself and use it during restoration.

@ephread ephread added the bug Something isn't working label Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants