0 votes
by (2.4k points)

It's- a me again! 
I'm sorry, I will delete all previous versions of this post once my issue is settled once and for all. 
I'm only posting again because I have no way of knowing otherwise if my renewed question will ever be seen. 

Chapel answered me in here, making a new version of his macro <<message>>. 

The issue I have is the fact that it works well with one <<message>> macro displayed, but if I have something like
 

<<message "Statistics">> Statistics <</message>>

<<message "Objects">> Objects <</message>>



Then whenever one is opened, both open on the next passage. Would there be a way for the macro to remember which <<message>> has been opened, and which hasn't ?

Thanks a lot. Sorry for overposting. 

1 Answer

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

Get yourself a clean copy of the macro from my library, and add this code somewhere after it:

(function () {
    
    var state = [];
    
    prehistory['handle-messages'] = function () {
        state = [];
        $('.message-text').each( function () {
            var $self = $(this);
            if ($self.hasClass('open')) {
                state.push($self.attr('id'))
            }
        });
    };
    
    $(document).on(':passageend', function () {
        state.forEach( function (id) {
            $('#' + id + ' a').trigger('click');
        });
    });
    
}());

 

by (2.4k points)
Works perfectly ! Thanks a lot
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...