ink icon indicating copy to clipboard operation
ink copied to clipboard

Possible to get get current knot name?

Open reneaye opened this issue 6 years ago • 7 comments

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?

reneaye avatar Sep 05 '19 08:09 reneaye

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'
    }
}

titusvk avatar Nov 13 '19 16:11 titusvk

currentPathString should not be empty. Sounds like a bug. Is it on inkjs only?

clembu avatar Nov 14 '19 08:11 clembu

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

manuq avatar Feb 13 '20 02:02 manuq

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.

GeorgesAlkhouri avatar Jul 27 '24 09:07 GeorgesAlkhouri

We ran in the exact same issue. Any news about this?

ibirothe avatar Jul 27 '24 10:07 ibirothe

Is there any update on this? We encountered the same issue.

Lorecommander avatar Jul 27 '24 13:07 Lorecommander

+1 an update here would be great

selop avatar Jul 29 '24 07:07 selop