Comments (7)
in the root of the sandbox I killed the ninja, then the samurai, and then saved. if thats the context you're looking for.
from inkjs.
Thank You! Your comments helped, I came up with a solution to use the saveMode
boolean to call story.state.toJson() after execution is completed.
My problem is fixed, but I would like to offer two suggestions. We are using inkjs in this project and would like it to be a little less fragile.
-
Is there a way to recover from this bad savestate? we don't want end users to get stuck with a broken save state that causes the game to crash. I know we could just wrap it in a try catch block but I also don't want to start the game over if there is a bad save. It would be great if we could have inkjs load what it can and discard what causes errors. (we've already encountered bad saves in our beta which currently dumps state after each choice is made, so things like server crashes or users closing their browser could create corrupt save states.)
-
Also It would be helpful if inkjs would throw an error when attemtping to dump json at the wrong time. If the dumped json will be invalid for restoring the state then I would prefer not to save it in the first place. Would it be possible to throw an error when
story.state.toJson()
is called during execution, or if the resulting json would be corrupt in some other way?
from inkjs.
At what point of the story did you save ?
from inkjs.
Any point, loading a save causes the scenario.
from inkjs.
I can confirm that the included save file does crash, but saving and restoring manually works correctly. The part that seems to cause the crash is this, specifically "idx": 5
(it's 0 in manual saves):
{ "cPath": "start.0.c-13", "idx": 5, "exp": true, "type": 0 }
Path c-13 calls an external function called saveGame
which would be the prime suspect. Can you show the code for that function?
from inkjs.
Saving the state while the callstack is still in execution is probably why it's failing.
Have you considered using a tag instead, that would trigger the save after the continue
has finished executing ?
from inkjs.
heres the contents of the saveGame function:
story.BindExternalFunction("saveGame", (waypointName) => {
localStorage.setItem('quickSave', story.state.toJson());
console.log("SAVE GAME")
saveMode = true;
return 'Returning to Story...';
}, false)
from inkjs.
Related Issues (20)
- How do I properly set up a PosixFileHandler? HOT 4
- Serverless template Uncaught Error: Failed to convert token to runtime object: "#", but working with ink-full.js HOT 4
- Calling EvaluateFunction() on functions with multiple arguments crashes HOT 5
- Choice tags are gone after state reloading HOT 1
- Bug in LIST_RANGE
- Missing commits in the port HOT 1
- Missing API: cannot bind callback to story.onError HOT 1
- export `JsonSerialisation` HOT 1
- Dynamic Tags are generated in reverse order HOT 2
- scrollDown malfunctions if it needs to scroll up instead HOT 1
- What's the correct syntax for Compiler with JSON file handler? HOT 2
- vite CommonJS error HOT 9
- Can't enumerate variables without accessing private attribute `_globalVariables`
- Compiler export is missing on the newest version HOT 5
- Typescript fails on `import { Story } from 'inkjs';` in 2.2.3 / 2.2.4 HOT 4
- Choice tags are not loaded from state HOT 1
- Couldnʻt get 2.2.3 or 2.2.4 working.. HOT 1
- [Help] How to use `PosixFileHandler` in conjunction with Webpack 5 HOT 2
- Compile crash HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inkjs.