Changing Windowcolor based on variable

I have a variable that handles the actor's reputation, so I was searching for a simple script, that dynamicly(gradually) changes the window color, based on a ingame variable.

For example the actor is bad guy and his reputation/the variable gets lower and lower, the window color becomes darker and darker.

Is there a script that could do such a thing? I guess, it's very simple to write such a script but I'm to dumb for that 😀
There is an event command "Change Window Color", that probably does what you want.

You can either look for the script equivalent to that command or make a parallel process common event checking the variable and calling the command after that.

For gradual changes, the script equivalent would probably be better because you would need an extreme mass of conditional branches in a parallel process event...
Yeah I know, actually I'm using a paralles process common event wich changes the windowcolor in 3 steps.

Blue for good, red for bad and black for neutral. It basicly checks if the variable is +125 or -75 (100=neutral). As you said, I could just put a mass of conditional branches into it. But yeah.. that's what I'm trying to avoid 😉

I was already messing around with the script editor, but couldn't figure it out. >.>
Do you REALLY want to change the WINDOW color (as in WINDOWS like the menu, text boxes, etc)? Or are you talking about applying a tone/tint to the game map itself? One will be visible only in the menus, and one will be visible only when you're on the map. Two different things.
Yes, I really want to change the window color. 😉  

Just to visualize the pc's morality.

It's not that big of a deal. Because as stated before, you can do it with a common event. As an parallel process, though.

I thought it might be a neat thing when the window color changes gradually.

Without any steps and without a parallel process running in the background all the time.
okay 🙂 Just had to ask 😉

Can you provide the values for the variable at which you want to change the window colour, and the tone to set it to for each (tone needs to be red, green, blue, grey values).

You'll need to be careful to make sure the text can be clearly seen on each one. Text will be in the colours of the grid in the lower right of the windowskin image.

If you want to continue working on it yourself, I think Window_Base.update_tone would be the method to change - instead of getting the tone from $game_system.window_tone, use if/else, case, or an array to determine what the tone should be (or a calculation).

Something like this works:

Code:
class Window_Base < Window  #--------------------------------------------------------------------------  # * Update Tone  #--------------------------------------------------------------------------  def update_tone    tone = Tone.new(0, 0, 0, 0)    rep = $game_variables[15].between?(75, 125) ? $game_variables[15] : 100    tone.red = (100 - rep) * 5 if rep < 100    tone.blue = (rep - 100) * 5 if rep > 100    self.tone.set(tone)  endend
Will make the window red for a low rep (75), black for neutral (100) and blue for good (125). I don't think the title window is quite right (seems a little more red than it should). That's based on a range of 75-125 for rep (you put -75 in an earlier post, but that would not make 'neutral' 100, so I figured it was a typo), and either red or blue will be 125 at the extremes. You'd have to adjust the formulae for tone.red and tone.blue if you wanted the colours slightly different. And of course, use the appropriate variable number instead of 15.
Wow thanks...

These are the values at which the actor switches his title 0, 15, 45, 70, 90, 110, 140, 170, 190

At  <=15 he is basically doomned.... neutral from 90-110 and 190=> he get's hollowed. The -75 was a typo, yeah. I meant <=75.

These are the color codes that I'm using right now:

>=190 = (-255,120,120)
<=189 = (-255,0,120)

<=125 = (-255,0,0)

<=75 = (0,-120,-120)

<=15 = (-255,-255,-255)

I'm not quite happy with them, but it can be tweaked later on, I guess.
I'm not really sure how to interpret that. Should the window change based on titles (0, 15, 45, 70, 90, 110, 140, 170, 190) or just based on the colours you're using now? Can it go below 0?

A better structure for you than what I have above might be something more along these lines:

Code:
def update_tone  case $game_variables[15]  when 0 .. 15    self.tone.set(Tone.new(...))  when 16 .. 45    self.tone.set(Tone.new(...))  when 46 .. 70    self.tone.set(Tone.new(...))  when 71 .. 90    self.tone.set(Tone.new(...))  ...  endend
No it was just trying to explain my situation 😀

I changed your first one, which was exactly what I was searching for. Thanks for that!

But the range should be from 0-200

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Update Tone
  #--------------------------------------------------------------------------
  def update_tone
    tone = Tone.new(0, 0, 0, 0)
    rep = $game_variables[10].between?(0, 200) ? $game_variables[10] : 100
    tone.red = (100 - rep) * 2 if rep < 100   #otherwise it gets too saturated
    tone.blue = (rep - 100) * 2 if rep > 100  #same here
    self.tone.set(tone)
  end
end

the only problem that I have now, It get's back to 0,0,0,0 when the value goes below 0 or above 200. Can I prevent that in some way?
Sure. Use this line instead, to allow the variable to go outside of that range but min/max rep at 0/200:

rep = [[0, $game_variables[10]].max, 200].minI think.
The * 5 in the original was based on a difference of 50 between minimum and maximum (when I assumed the variable would be between 75 and 125). With a difference of 200, that would be too much. Glad you figured out a more appropriate multiplier 🙂
Yes!!!

Works like a charm! Thank you! You really made my day!
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/changing-windowcolor-based-on-variable.19101/