0 votes
asked by (2.4k points)

Hey there, 

I still haven't found an answer for my last question.

I don't want to spam or anything, but it's been some days already, and I'm affraid I've been forgotten :(

Thanks a lot !

1 Answer

0 votes
answered by (57.1k points)
edited by

Here's an updated version that saves its own state:

//intialize namespace
setup.messageMacro = {};

// default text option:
setup.messageMacro.default = 'Help';
setup.messageMacro.state = false;

// <<message>> macro
Macro.add('message', {
    tags    : null,
    handler : function () {
        var message  = this.payload[0].contents;
        var $wrapper = $(document.createElement('span'));
        var $link    = $(document.createElement(this.args.includes('btn') ? 'button' : 'a'));
        var $content = $(document.createElement('span'));

            .wiki(this.args.length > 0 && this.args[0] !== 'btn' ? this.args[0] : setup.messageMacro.default)
            .ariaClick(function () {
                if ($wrapper.hasClass('open')) {
                        .css('display', 'none')
                    setup.messageMacro.state = false;
                else {
                        .css('display', 'block')
                    setup.messageMacro.state = true;

            .attr('id', 'macro-' + this.name + '-' + this.args.join('').replace(/[^A-Za-z0-9]/g, ''))
            if (setup.messageMacro.state) {


commented by (2.4k points)
Thanks !
It works well with one <<message>> 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 it to remember which <<message>> has been opened, and which hasn't ?

Thanks again Chapel !
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.