设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 82|回复: 0

[转载发布] Save/Load menu on button press

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    8003

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    30013
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38910

    灌水之王

    发表于 5 天前 | 显示全部楼层 |阅读模式
    Porting my VXACE script with some additions

    You will find variations for what this script does, but I couldn't find one that only handled save/load functionality.
    Script also lets you add more action to more input presses but you will have to add the params.

                    JavaScript:       
    1. //=============================================================================
    2. // Save_menu_on_button_press.js
    3. //=============================================================================
    4. /*:
    5. * @Save_menu_on_button_press
    6. * @plugindesc Open save menu on button press
    7. * @version 1.2
    8. * @author Zero_G
    9. * @filename Save_menu_on_button_press.js
    10. * @help
    11. -------------------------------------------------------------------------------
    12. == Description ==
    13. This plugin opens the save menu on a button press, can be used to call other scripts
    14. == Terms of Use ==
    15. - Free for use in non-commercial projects with credits
    16. - Free for use in commercial projects
    17. - Please provide credits to Zero_G
    18. == Usage ==
    19. Just add the plugin.
    20. -------------------------------------------------------------------------------
    21. @param Save Button
    22. @desc Button to press to call save menu
    23. @default pageup
    24. @param Load Button
    25. @desc Button to press to call save menu
    26. @default e
    27. -------------------------------------------------------------------------------
    28. */
    29. var Imported = Imported || {};
    30. var ZERO = ZERO || {};
    31. Imported.ZERO_ActionOnButton = 1;
    32. ZERO.ActionOnButton = ZERO.ActionOnButton || {};
    33. (function ($) {
    34.   $.params = PluginManager.parameters('Save_menu_on_button_press');
    35.   $.button = $.params['Save Button'].trim();
    36.   $.button2 = $.params['Load Button'].trim();
    37.   // Add key mappings
    38.   function addKeyMapping(key){
    39.     let buttonCode = key.toUpperCase().charCodeAt(0);
    40.     // Prevent from mapping predefined strings (ej: 'pageup', 'left')
    41.     for (const [key_, value] of Object.entries(Input.keyMapper)) {
    42.       if(key.localeCompare(value) == 0) return key;
    43.     }
    44.     if (Input.keyMapper[buttonCode] === undefined) {
    45.       Input.keyMapper[buttonCode] = key;
    46.       return key;
    47.     }else{
    48.       // If it was already defined, return the char/string it was defined with
    49.       return Input.keyMapper[buttonCode];
    50.     }
    51.   }
    52.   $.button = addKeyMapping($.button);
    53.   $.button2 = addKeyMapping($.button2);
    54.   //----------------------------------//
    55.   // Actions only during normal scene //
    56.   //----------------------------------//
    57.   // Alias method: update_scene
    58.   var ZERO_Scene_Map_prototype_updateScene = Scene_Map.prototype.updateScene;
    59.   Scene_Map.prototype.updateScene = function () {
    60.     ZERO_Scene_Map_prototype_updateScene.call(this);
    61.     // Check for button press for save screen
    62.     if (Input.isTriggered($.button) || TouchInput.isCancelled()) {
    63.       SceneManager.push(Scene_Save);
    64.     }
    65.     // More actions can be added (need to add more button params)
    66.     /*if (Input.isTriggered($.button) || TouchInput.isCancelled()) {
    67.         //add code
    68.         //example:
    69.         SceneManager.push(Scene_Load);
    70.     }*/
    71.   };
    72.   //----------------------------------//
    73.   // Actions only during text         //
    74.   //----------------------------------//
    75.   var ZERO_WindowMessage_updateInput = Window_Message.prototype.updateInput;
    76.   Window_Message.prototype.updateInput = function() {
    77.     /*if (Input.isTriggered($.button2) || TouchInput.isCancelled()) {
    78.          
    79.     }*/
    80.     return ZERO_WindowMessage_updateInput.call(this);
    81.   };
    82.   //----------------------------------//
    83.   // Actions triggered anywhere       //
    84.   //----------------------------------//
    85.   function keyEventListener(event){
    86.       // Can set action without registering key in inputs   
    87.       /*if(event.keyCode == 67){ // C
    88.       }*/
    89.       // Load screen
    90.       if (Input.keyMapper[event.keyCode] == $.button2) {
    91.         SceneManager.push(Scene_Load);
    92.         //SceneManager.goto(sceneClass);
    93.       }
    94.   }
    95.   document.addEventListener('keydown', keyEventListener.bind(this))
    96. })(ZERO.ActionOnButton);
    复制代码




    本贴来自国际rpgmaker官方论坛作者:Zero_G处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/save-load-menu-on-button-press.127071/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 09:32 , Processed in 0.136550 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表