Refresh a variable value on window

This thread is a follow-up (with a "new question") to this one here https://forums.rpgmakerweb.com/index.php?threads/self-switch-value-not-changing-in-map.119607/.

I need to refresh the value of a variable that is displayed on a window, without the need to change the map. Please review the content of the previous post's link to see all the information I wrote there. Thanks.
I see in the other post that you made a little snippet for your window. So, I think you can just use the update function of the window, right?
Or perhaps, call the map refresh function?
I see in the other post that you made a little snippet for your window. So, I think you can just use the update function of the window, right?
Or perhaps, call the map refresh function?

¿how do I call the map refresh function? I have tried using Scene_Map.prototype.updateScene but I am not sure where to call it correctly or how to call it, and tried many different ways and positions.
try this on the console or in a script call:
$gameMap.refresh()

or

$gameMap.requestRefresh()
try this on the console or in a script call:
$gameMap.refresh()

or

$gameMap.requestRefresh()

Did both on the script call of the sprite that activates the event, and ... nope ... ¿is there a way I can create a function that sorts of "recreates" the window with the new information?
I don't think you need to recreate the window for this.
Take a look at the core files and search for the help window.
You can make a similar copy and use it as your window.
Add it to the scene map, and call the update in the Update function of the scene map.
You can even, not add it in the update function of the map, but call it with a script or plugin command.
Since the help window can show variables value with escape characters, you should be fine using them.
I don't think you need to recreate the window for this.
Take a look at the core files and search for the help window.
You can make a similar copy and use it as your window.
Add it to the scene map, and call the update in the Update function of the scene map.
You can even, not add it in the update function of the map, but call it with a script or plugin command.
Since the help window can show variables value with escape characters, you should be fine using them.

¿And what exactly is a help window? If you noticed, I have been using Window_Base and that's it, have not gone deeper and it's particularly because, to my mindset, if I cannot refresh this simple kind of window, later one it might be painful.
You've said you're using Window_Base, but in your other thread you're using Window_Selectable.

Regardless, a simple refresh function might look something like this:

Code:
Window_Custom.prototype.refresh = function() {
    this.contents.clear();
    this.drawContents();
};

Replace "Window_Custom" with your window's name. Replace "drawContents" with the method you use to draw the window's contents in the first place. I'll leave it to you to call this function at an appropriate time because I don't know what you're trying to achieve.
You've said you're using Window_Base, but in your other thread you're using Window_Selectable.

Regardless, a simple refresh function might look something like this:

Code:
Window_Custom.prototype.refresh = function() {
    this.contents.clear();
    this.drawContents();
};

Replace "Window_Custom" with your window's name. Replace "drawContents" with the method you use to draw the window's contents in the first place. I'll leave it to you to call this function at an appropriate time because I don't know what you're trying to achieve.

I just want that, when I change a Self Switch status, a window shows up or closes. I know that the Self Switch changes value from TRUE to FALSE, but the value (which I show on a screen) is not refreshed. And I have an update function, but inside there is no "this.contents.clear()" or "this.drawAllItems()". Tried to put only this two inside my function and didn't work. It is not refreshing until I change map either.

I am just checking, ¿it is because I am using Scene_Map to show the Window that it doesn't close? ¿Do I have other scene option or scene update method?
¿And what exactly is a help window? If you noticed, I have been using Window_Base and that's it, have not gone deeper and it's particularly because, to my mindset, if I cannot refresh this simple kind of window, later one it might be painful.
Not at all. You can make a simple copy of the Window_Help and change the name. It's a little part of the code, so you can see the function to set the text and the function that update it.

It also can go with the approach of Silva.

Original thread: https://forums.rpgmakerweb.com/threads/refresh-a-variable-value-on-window.119742/