Closed selden closed 4 years ago
$('tw-storydata').attr('ifid')
should get you the IFID
I must be overlooking something and don't how that construct should be used.
I assumed that $ indicates a global variable and naively thought that putting the text you provided into a passage should cause it to display the IFID.
Unfortunately, when I include that string in a passage, all it does is echo the text of that string itself and does not display the IFID.
What don't I understand?
Update: the EDID [i]is[/i] shown if I enclose the EDID query string in the print macro.
I dunno if it should be considered a bug that the "Naked Variable" construct doesn't work.
The StoryData
compiler special passage is not compiled into the data chunk of Twine 2 style story formats. That said, its data is available within the data chuck in various elements. The information you likely want out of it can be found on the <tw-storydata>
element's content attributes.
Console example:
console.log('Story Name:', $('tw-storydata').attr('name'));
console.log('Story IFID:', $('tw-storydata').attr('ifid'));
console.log('Story Format:', $('tw-storydata').attr('format') + " v" + $('tw-storydata').attr('format-version'));
console.log('Compiler:', $('tw-storydata').attr('creator') + " v" + $('tw-storydata').attr('creator-version'));
<<print>>
example:
''Story Name:'' <<= $('tw-storydata').attr('name')>>
''Story IFID:'' <<= $('tw-storydata').attr('ifid')>>
''Story Format:'' <<= $('tw-storydata').attr('format') + " v" + $('tw-storydata').attr('format-version')>>
''Compiler:'' <<= $('tw-storydata').attr('creator') + " v" + $('tw-storydata').attr('creator-version')>>
PS: $(…)
is an alias for jQuery
, not a story variable, so the function call happening there not working with the naked variable markup is not a bug.
It'd be helpful if the StoryData passage could be displayed within a story by using an include macro. Currently such an inclusion fails. See the attached screengrab. I'm also including a zip of the .tw used to display this problem.
includes.zip
Background: I'd like to be able to provide the story's IFID to the reader without having to manually copy the information contained in the StoryData passage. Such a manual inclusion might not be updated to show the correct information if the IFID has to be changed for some reason.