[REQUEST] Script to change windowskin via a in-game variable

As the title says, i need a script that can change the windowsking based on an ingame variable. I tried doing it myself (modifying the game scripts), but i always get the same error of nil:NilClass when calling for the in-game variable $game_variables[15]
can someone help me at least telling em how to address the variable properly?

I think i could change it in here in Window Base:
Spoiler: Original
def update
super
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_system.windowskin_name
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
end

Spoiler: My Version
def update
super
if $game_system.windowskin_name != @windowskin_name
@windowskin_name = $game_variables[15]
self.windowskin = RPG::Cache.windowskin(@windowskin_name)
end
end

and here in Game System:

Spoiler: Original
def windowskin_name

if @windowskin_name == nil
return $data_system.windowskin_name
else
return @windowskin_name
end
end

Spoiler: My version
def windowskin_name

if @windowskin_name == nil
return $game_variables[15]
else
return @windowskin_name
end
end

But, of course that's not working...
Is there a way to make it? can someone help me please?

The Windowskin Files are called 1, 2,3 and 4. That's how i plan to call them with the variable

I've moved this thread to RGSSx Script Requests. Thank you.

I've moved this thread to Script Requests. Thank you.

DIFFERENT approach.

How about altering Game_Variables???

Code:
  #--------------------------------------------------------------------------
  # * Set Variable
  #     variable_id : variable ID
  #     value       : the variable's value
  #--------------------------------------------------------------------------
  def []=(variable_id, value)
    if variable_id <= 5000
      @data[variable_id] = value
    end
    if variable_id == 15
      $game_system.windowskin_name = value.to_s
    end
    $game_map.need_refresh = true
  end

Yeah, I added the need refresh line too. Just changing a variable (or a switch) does nothing to the map UNLESS the map refreshes.

And the filename for the windowskin needed to be a string.
Thank you, but I found an easier way to do it using conditionals and the built-in change sking option hahah
I think you can actually do it without any scripts, with simply doing a event/common event with parallel process that do an action when a game variable is on a number etc. with a conditional branch, like changing the windowskin. (sorry if i'm wrong)
I think you can actually do it without any scripts, with simply doing a event/common event with parallel process that do an action when a game variable is on a number etc. with a conditional branch, like changing the windowskin. (sorry if i'm wrong)
no, yeah, you're actually right.
It's even easier that way tbh
no, yeah, you're actually right.
It's even easier that way tbh
np btw xd
The reason you got the error message in your first post is that $game_variables is not created until you select New Game or Continue from the title screen. But the title screen uses the windowskin. So you are trying to access something that hasn't been created yet.

Also, I don't see why you need to have a parallel process common event. If the windowskin only changes when a variable changes, then you know exactly when the windowskin needs to be changed, so you don't need a parallel process (setting up too many of these, or even one, if not well designed, will cause your game to lag). Just have one common event that sets the windowskin based on the variable, which is not set to autorun or parallel process. Then whenever you have an event that changes that variable, follow it with a Common Event command, to call your common event.

If your query is resolved, report your first post and let the mods know, so they can close the thread.

Original thread: https://forums.rpgmakerweb.com/threads/request-script-to-change-windowskin-via-a-in-game-variable.111874/