[XP] Is it possible to use "Script" command to change Textbox Z-axis?

First, I use Ccoa's UMS script.

So, I wanted the Pictures in my project (From "Show Picture" event) to appear IN FRONT of the Textboxes, like so:
1IEao1J.png


So I modified the UMS script a little. There's a part in it that looks like this:
Code:
class Window_Message < Window_Selectable
  def initialize
      .
      .
      self.z = 9998
      .
      .
  end
end
I simply changed the value of self.z to 100, making the Textbox's Z-axis smaller than that of a Picture. It worked, but now I face a different problem...

What do I do if sometimes I want the Pictures to display behind a Textbox? In other words, how do I change self.z back to 9998 temporarily while in the game? Is it even possible? I tried a bunch of things using the "Script" event command, similar to:
Code:
Window_Message.initialize.z = 9998
But nothing worked. No surprise here, since I know pretty much nothing in RGSS lol. I don't even know if my syntax is correct 😛

I'll appreciate any help...
You can set the z value to a variable with reset_window method, the value will be refreshed each time the window is popped up.
Don't forget to change the VARIABLEID.
Code:
class Window_Message < Window_Selectable
  def reset_window
    self.z = $game_variables[VARIABLEID]
    .
  end
end
You can set the z value to a variable with reset_window method, the value will be refreshed each time the window is popped up.
Don't forget to change the VARIABLEID.
Code:
class Window_Message < Window_Selectable
  def reset_window
    self.z = $game_variables[VARIABLEID]
    .
  end
end
Niiiiice, that worked! Thanks a bunch!

EDIT:
Actually, I celebrated too early... I really need to check things thoroughly before saying "it worked" lol. Sorry about that.
@DrDhoom Could you tell me exactly step-by-step what I need to do? I put your code in the Script Editor, defined a variable as a value for the Z, and things just don't seem to work. For starters, the choice window ("Show Choices" event) is invisible, no matter the value. Also, sometimes the textbox is completely invisible no matter the value (Almost seems random). If it matters, I set values into variable 56, so in the script I wrote $game_variables[56].
Maybe it should be $game_variables[0056]? lol
I will repeat and emphasize that I know nothing about RGSS/Ruby, I'm only decent-ish at Javascript :3
So, again, what exactly do I need to do with your code? Put it in the "Script" event, or the Script Editor? Should I make a new separate script for it, or insert it into the UMS script? Etc.
Appreciate it~

Original thread: https://forums.rpgmakerweb.com/threads/xp-is-it-possible-to-use-script-command-to-change-textbox-z-axis.105481/