Iterate over passages to filter them
setup.getPassageNames = function() { const excludedNames = ['StoryInit', 'Main']; const excludedTags = ['widget', 'nonono']; const passageNames = []; $('tw-passagedata').each(function() { const name = $(this).attr('name'); const tags = $(this).attr('tags'); let safeTags = true; if (excludedNames.indexOf(name) === -1) { for (let i = 0; i < excludedTags.length; i++) { if (tags.includes(excludedTags[i])) { safeTags = false; break; } } if (safeTags) { passageNames.push(name); } } }); return passageNames; };
<<set _possiblePlaces = setup.getPassageNames()>>
<<set _randomPassage = _possiblePlaces.random()>>
→