hiding temporarily the currency window

Hi, i'm new to javascript and i tried to create a script where i toggle the visibility of the currency window.

Code:
var alias_Scene_Menu_prototype_createGoldWindow = Scene_Menu.prototype.createGoldWindow;

Scene_Menu.prototype.createGoldWindow = function() {
alias_Scene_Menu_prototype_createGoldWindow.call(this);
this._goldWindow.visible = false;
};

with this code the visibility of the currency window is off, how can i turn it on after?

sry for my bad english, i hope you will understand what i need.
Simply, program it depending on a game switch. If the switch is on or off, the window will be visible/invisible.
Simply, program it depending on a game switch. If the switch is on or off, the window will be visible/invisible.
oh... i have no idea how to program it depending on a game switch, can you please make me an exaple?😐
if ($gameSwitches.value(1) == true){
}else{
}
if ($gameSwitches.value(1) == true){
}else{
}
I have tried this:
Code:
var alias_Scene_Menu_prototype_createGoldWindow = Scene_Menu.prototype.createGoldWindow;

Scene_Menu.prototype.createGoldWindow = function() {
    alias_Scene_Menu_prototype_createGoldWindow.call(this);

    if ($gameSwitches.value(4) == true){
        this._goldWindow.visible = true;
    }else{
        this._goldWindow.visible = false;
    };

but it doesn't work when i switch it off/on, is my code bad?
Works for me without trouble.
I don't see a typo in your code. The only reasons that come to my mind are
1. aliasing
2. the switch isn't on properly
For example, are you sure you are turning on the 4th switch? Isn't there any plugin that keeps it off, like overlay plugins?
i disabled all the other plugins but it doesn't work anyway

i have created 2 events:
1 where i turn on the game switch ->
nOyzUxn.png



and 1 where i toggle the visibility of the window ->
GQo1I4T.png


and i think the aliasing is good, because it worked with this code:
Code:
var alias_Scene_Menu_prototype_createGoldWindow = Scene_Menu.prototype.createGoldWindow;

Scene_Menu.prototype.createGoldWindow = function() {
alias_Scene_Menu_prototype_createGoldWindow.call(this);
this._goldWindow.visible = false;
};
You can always check with f9 if the switch is on,. F9 is a debug overview of your switches and variables.
Thank you mate, it works now, i didn't add the "(function() {" at the start like a idiot
now it works like a charm.😍

Original thread: https://forums.rpgmakerweb.com/threads/hiding-temporarily-the-currency-window.81857/