0 votes
by (150 points)
I'm trying to use story.show. I'm pretty sure it was working, but now in the story I'm mainly working on, it gives me this error:
Uncaught TypeError: Cannot read property 'length' of undefined (chrome-extension://jbeclgngiacjdjjokiegbkjcpibcdcic/index.html#!/stories/becd00a4-2a59-4420-a4c5-42b8a96b8775/test/3d1dec10-6ca2-4d3a-bafb-cc9f21570a19: 171)

The error seems to be only from story.show, not anything else (I've used trial and error to establish this). If I use a plain link to go to the other passage, it's fine; if I use story.show, I get the error.

I created a dummy story to test, and there it isn't working either. The whole story is two passages, one contains
and the other just says "moved to other". If I add a print statement to the start passage it shows the printed message, but it doesn't show "other" passage or give any error.

Apologies if I made some dumb mistake, but I'm completely stumped.

1 Answer

0 votes
by (159k points)
selected by
Best answer

Your example shows the story.show() call but not how/when you're using that call.

From the little testing I have done with the Snowman v1.3.0 story format I have determined that you can't call that function directly within the body of a Passage.
eg. the following won't work.

Some text

<% story.show("Other"); %>

note: Unfortunately the old Snowman (v1.3.0) project repository has been replaced with the newer Snowman v1.4 project repository, so there is no longer an un-minimised copy of the v1.3.0 source code available to look at.

It appears that you can't directly change which Passage is being shown while the content of the current Passage is being processed, but you can delay that change to sometime after that processing.
eg. the following does work because the story.show() function is executed after the processing of the current Passage.

Some text

}, 50);


by (150 points)
Thanks! Using setTimeout fixed the Uncaught Type Error. I was calling story.show after a call to a function from story javascript, so maybe sometimes that function call took long enough to let story.show work?