From d0a6d405347db30ca189e8488a0e2d2a9dc1b9db Mon Sep 17 00:00:00 2001 From: dazedanon Date: Thu, 18 Dec 2025 22:32:19 -0600 Subject: [PATCH] Refresh text variables --- js/plugins.js | 6 +++ js/plugins/RefreshTextVariables.js | 64 ++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 js/plugins/RefreshTextVariables.js diff --git a/js/plugins.js b/js/plugins.js index 7e9f9ab..8e1b94e 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -2537,4 +2537,10 @@ var $plugins = [ pauseAtBottom: "120", }, }, + { + name: "RefreshTextVariables", + status: true, + description: "Adds F9 keybind to refresh text variables with updated translations", + parameters: {}, + }, ]; diff --git a/js/plugins/RefreshTextVariables.js b/js/plugins/RefreshTextVariables.js new file mode 100644 index 0000000..62e2a2e --- /dev/null +++ b/js/plugins/RefreshTextVariables.js @@ -0,0 +1,64 @@ +//============================================================================= +// RefreshTextVariables.js +//============================================================================= + +/*: + * @target MZ + * @plugindesc Adds F9 keybind to refresh text variables with updated translations + * @author DazedTranslations + * + * @help RefreshTextVariables.js + * + * Press F9 at any time to refresh text variables to use updated translations. + * This is useful after updating translation files with old save data. + * + * The plugin calls Common Event 112 which handles all variable refreshing. + */ + +(() => { + 'use strict'; + + // Function to refresh all text variables by calling Common Event 112 + function refreshTextVariables() { + $gameTemp.reserveCommonEvent(112); + console.log("Text variables refreshed! (Common Event 112 called)"); + } + + // Store the original Scene_Map update method + const _Scene_Map_update = Scene_Map.prototype.update; + + // Override Scene_Map update to check for F9 key press + Scene_Map.prototype.update = function() { + _Scene_Map_update.call(this); + + // Check if F9 is pressed (keyCode 120 = "debug") + if (Input.isTriggered("debug")) { + refreshTextVariables(); + } + }; + + // Also add to Scene_Menu for menu access + const _Scene_Menu_update = Scene_Menu.prototype.update; + + Scene_Menu.prototype.update = function() { + _Scene_Menu_update.call(this); + + // Check if F9 is pressed + if (Input.isTriggered("debug")) { + refreshTextVariables(); + } + }; + + // Also add to Scene_Battle for battle access + const _Scene_Battle_update = Scene_Battle.prototype.update; + + Scene_Battle.prototype.update = function() { + _Scene_Battle_update.call(this); + + // Check if F9 is pressed + if (Input.isTriggered("debug")) { + refreshTextVariables(); + } + }; + +})();