じ☆ve冰风 发表于 2026-7-31 09:19:27

Konami Code Plugin

I have made a working plugin for the Konami Code that you can activate at anytime during gameplay, this to activate a control switch (by default Switch 3, because that's what I needed it for).Use it for whatever, doesn't matter.

It is free for anyone to use, commercial or otherwise. No restrictions.

Up, up, down, down, left, right, left, right, B, A (X, Z on keyboard).

Download it here


                JavaScript:       
/*:
* @plugindesc Triggers a control switch (Switch 3) when the Konami Code is entered at any time.
* @thenbexperience
*
* @help
* This plugin triggers Switch 3 when the Konami Code is entered:
* Up, Up, Down, Down, Left, Right, Left, Right, B, A
*/

(function() {
    const switchId = 3; // Switch ID to be activated

    const konamiCode = [
      38, 38, // Up, Up
      40, 40, // Down, Down
      37, 39, // Left, Right
      37, 39, // Left, Right
      88, 90// B, A (X, Z in RPG Maker MV)
    ];

    let inputSequence = [];

    const checkKonamiCode = () => {
      if (inputSequence.length === konamiCode.length) {
            if (JSON.stringify(inputSequence) === JSON.stringify(konamiCode)) {
                $gameSwitches.setValue(switchId, true);
                console.log('Konami Code entered! Switch ' + switchId + ' is now ON.');
                inputSequence = []; // Reset the input sequence
            }
      }
    };

    const inputHandler = (event) => {
      inputSequence.push(event.keyCode);
      if (inputSequence.length > konamiCode.length) {
            inputSequence.shift(); // Keep only the last N inputs
      }
      checkKonamiCode();
    };

    // Add the event listener for keydown
    document.addEventListener('keydown', inputHandler);
})();




本贴来自国际rpgmaker官方论坛作者:Deleted member 270061处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/konami-code-plugin.172202/
页: [1]
查看完整版本: Konami Code Plugin