ronancpl / HeavenMS

An improved server based on MapleSolaxia (v83 MapleStory private server)
GNU Affero General Public License v3.0
1.03k stars 742 forks source link

Repeat question if user has wrong pass count #497

Closed Periwinks closed 5 years ago

Periwinks commented 5 years ago

Background

Info

Additional notes / follow up

I'm new to all of this :sweat_drops:, so if this isn't the best way to do it, let me know and I hope to do it right next time! :grin: (such as adding it in a next window rather than being squishied into the same one) :cake:

ronancpl commented 5 years ago

Okay, solution accepted.

For NPC scripts, to add pieces of information on next windows you use what is called the talk status. Let's assume the NPC Base script, slightly modified like this:

var status;

function start() {
        status = -1;
        action(1, 0, 0);
}

function action(mode, type, selection) {
        if (mode == -1) {
                cm.dispose();
        } else {
                if (mode == 0 && type > 0) {
                        cm.dispose();
                        return;
                }
                if (mode == 1)
                        status++;
                else
                        status--;

                if(status == 0) {
                        cm.sendNext("Sample text.");
                } else if(status == 1) {
                        cm.sendNextPrev("More sample text.");
                } else if(status == 2) {
                        cm.sendYesNo("Understood?");
                } else if(status == 3) {
                        cm.sendOk("Bye~");
                        cm.dispose();
                }
        }
}

From there, a few points can get made:

Hope to have made this clear for you... Thanks for contributing!