MV Auto-updating variables in menus

So a handy feature I've made for my game is automatically updating notifiers for button inputs. But unfortunately, outside of cutscenes and tutorials, the game doesn't update... correctly if these variables are shown via text on a menu.

bob.png


For example, if I try to use variables on this menu (via Modern Algebra's Global Text), they'll often get stuck on the first thing they displayed as instead of what their current value is, even if the player's already changed the input.

I do have a proposal for how to fix it, but I'm not sure if it'll work:

JavaScript:
var oldnumber = $gameVariables.value(992);
if (oldnumber != $gameVariables.value(992)) {
    this.refreshPageUpBob;
}

... with refreshPageUpBob being something that changes the variable to what it should be.

I dunno, I need someone that isn't me to double-check this.
You might have to use something like Triacontane's Parallel Common Event in Menu
All you should have to do is, whenever you select whatever options change the contents of the variables, call the refresh() method of whatever window that is.

Have a link to the plugin in question?
For a true auto-update, you could build the keybind labels as a sprite and cook the label updates into its update method, or call it manually via a redraw method. This would be particularly easy if this text is just sitting at the bottom of the window in a fixed position, e.g. it doesn’t need to scroll.

Otherwise, yeah, just refresh the window as Turan suggests. But just make sure that the latest text for your labels are made available to the drawing methods prior to calling your refresh.
So @Kenen me and Turan worked it out in a private chat and we came to a pretty good answer:

JavaScript:
let keycode = Number(Object.keys(Input.keyMapper).find(key => Input.keyMapper[key] == "pageup"));

$gameVariables.setValue(1992, Object.keys(Window_KeyConfig._refId).find(key => Window_KeyConfig._refId[key] == keycode));

This is put into the exit code of YEP_KeyboardConfig and checks for all the keys that are all being used by the input in question. I tested it and it does in fact change the prompt used when you switch back to the equip menu!

So I'd say that's a rousing success, provided we don't discover any bugs in the future.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/auto-updating-variables-in-menus.171548/