Possible to get get current knot name?
I want to get the current knot name.
I tried Story.state.currentPathString but this is always empty. I also tried Choice.sourcePath but this one return something like 0.13.8 which seems to be a JSON state format of a knot name.
Isn't there a way to get the real current knot name?
I hacked the ink.js for this reason and stored it to my app (in /js/index.js) ~ line 6312
key: 'ChoosePath',
value: function ChoosePath(p) {
// save path to my App
app.inkpath = p;
this.state.SetChosenPath(p);
// Take a note of newly visited containers for read counts etc
this.VisitChangedContainersDueToDivert();
}
Now I can get the knot name from the path:
function continueStory(firstTime) {
...
if (app.inkpath) {
var knot = JSON.stringify(app.inkpath._components[0]['_name'])
knot = knot.substring(1,knot.length-1)
if (knot == 'global decl') knot = 'start'
}
}
currentPathString should not be empty. Sounds like a bug. Is it on inkjs only?
Sorry in advance for cross-posting.
At least in inkjs, story.state.currentPathString works, as far as the story can continue, ie. canContinue() is true. I created a testcase to dispel any doubts: https://github.com/y-lohse/inkjs/pull/450/files
Hello, are there any updates on this topic or available workarounds? Unfortunately, this issue still exists as @manuq describes in both ink and inkjs. As far as I observed, making a choice assigns the currentPath again to not be null, but continuing the story afterward (doesn't matter if ContinueMaximally or Continue) will set it again to null when expecting a new knot currentPath value.
// setup story
// start of story
story.state.currentPathString // -> 0
story.ContinueMaximally()
story.state.currentPathString // -> Null
story.ChooseChoiceIndex(0)
story.state.currentPathString // -> start.0.c-0.0
story.ContinueMaximally()
story.state.currentPathString // -> Null
story.ChooseChoiceIndex(0)
story.state.currentPathString // -> newknot.0.c-0.0
Edit: So I found here a workaround where one can read out the current knot's name from the Choice class's sourcePath property via story.currentChoices.
We ran in the exact same issue. Any news about this?
Is there any update on this? We encountered the same issue.
+1 an update here would be great