Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Snowman: some code for retrieving the current passage's tags

Here's a line of code for getting the current passage's tags metadata in Snowman. I ended up pulling it out of the the story xml as I didn't see it in the passage object. Tags are retrieved as a space delimited string.
<% var tags = $(story.el[0]).find('tw-passagedata[name=\"' + window.passage.name + '\"]').attr('tags'); %>

Comments

  • Hi everyone. This is my first post to the forum. I am working on my first ever Twine 2 game (specifically Twine 2.0.3, Snowman format, using the in-browser game editor hosted at twinery.org). I'm pretty inexperienced but thought I'd share what I've learned so far.

    The above code did not seem to work for me. Perhaps the Snowman source has changed since the original post? After some experimenting, I came up with this slight change, which seems to work. But please let me know if there's some side effects or downside that I should be aware of! or if there's an even slighter change that will also work.
    <%
    window.getTags = function() {
    return $("tw-passagedata[pid=" + window.passage.id + "]").attr("tags").split(' ');
    }
    %>
    This produces an array. Leave out the ".split(' ')" if you want a string.
Sign In or Register to comment.