I don't think the closeFn argument of the Dialog.addClickHandler() method is the way to go here. Instead, I'd use recursion (which is when a function calls itself) and the :dialogclose event, with jQuery's one() method; something like:
setup.chainDialog = function (list, i) {
if (i === undefined) {
i = 0;
}
if (i >= list.length) {
// do nothing if we've emptied the list
return;
}
$(document).one(':dialogclose', function () {
// have this function call itself and increase the counter by one
setup.chainDialog(list, ++i);
});
// show the dialog indicated by the counter
Dialog.wiki(Story.get(list[i]).text);
Dialog.open();
};
Usage:
<<run setup.chainDialog(['popup 1', 'popup 2', 'popup 3', 'popup 4'])>>
Just pass the function an array of passage names to show, and it will show them in order, one after another, as they're closed, until it runs out of them.