Save/Load menu on button press
Porting my VXACE script with some additionsYou 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:
//=============================================================================
// Save_menu_on_button_press.js
//=============================================================================
/*:
* @Save_menu_on_button_press
* @plugindesc Open save menu on button press
* @version 1.2
* @author Zero_G
* @filename Save_menu_on_button_press.js
* @help
-------------------------------------------------------------------------------
== Description ==
This plugin opens the save menu on a button press, can be used to call other scripts
== Terms of Use ==
- Free for use in non-commercial projects with credits
- Free for use in commercial projects
- Please provide credits to Zero_G
== Usage ==
Just add the plugin.
-------------------------------------------------------------------------------
@param Save Button
@desc Button to press to call save menu
@default pageup
@param Load Button
@desc Button to press to call save menu
@default e
-------------------------------------------------------------------------------
*/
var Imported = Imported || {};
var ZERO = ZERO || {};
Imported.ZERO_ActionOnButton = 1;
ZERO.ActionOnButton = ZERO.ActionOnButton || {};
(function ($) {
$.params = PluginManager.parameters('Save_menu_on_button_press');
$.button = $.params['Save Button'].trim();
$.button2 = $.params['Load Button'].trim();
// Add key mappings
function addKeyMapping(key){
let buttonCode = key.toUpperCase().charCodeAt(0);
// Prevent from mapping predefined strings (ej: 'pageup', 'left')
for (const of Object.entries(Input.keyMapper)) {
if(key.localeCompare(value) == 0) return key;
}
if (Input.keyMapper === undefined) {
Input.keyMapper = key;
return key;
}else{
// If it was already defined, return the char/string it was defined with
return Input.keyMapper;
}
}
$.button = addKeyMapping($.button);
$.button2 = addKeyMapping($.button2);
//----------------------------------//
// Actions only during normal scene //
//----------------------------------//
// Alias method: update_scene
var ZERO_Scene_Map_prototype_updateScene = Scene_Map.prototype.updateScene;
Scene_Map.prototype.updateScene = function () {
ZERO_Scene_Map_prototype_updateScene.call(this);
// Check for button press for save screen
if (Input.isTriggered($.button) || TouchInput.isCancelled()) {
SceneManager.push(Scene_Save);
}
// More actions can be added (need to add more button params)
/*if (Input.isTriggered($.button) || TouchInput.isCancelled()) {
//add code
//example:
SceneManager.push(Scene_Load);
}*/
};
//----------------------------------//
// Actions only during text //
//----------------------------------//
var ZERO_WindowMessage_updateInput = Window_Message.prototype.updateInput;
Window_Message.prototype.updateInput = function() {
/*if (Input.isTriggered($.button2) || TouchInput.isCancelled()) {
}*/
return ZERO_WindowMessage_updateInput.call(this);
};
//----------------------------------//
// Actions triggered anywhere //
//----------------------------------//
function keyEventListener(event){
// Can set action without registering key in inputs
/*if(event.keyCode == 67){ // C
}*/
// Load screen
if (Input.keyMapper == $.button2) {
SceneManager.push(Scene_Load);
//SceneManager.goto(sceneClass);
}
}
document.addEventListener('keydown', keyEventListener.bind(this))
})(ZERO.ActionOnButton);
本贴来自国际rpgmaker官方论坛作者:Zero_G处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/save-load-menu-on-button-press.127071/
页:
[1]