xChikyx

Veteran
Veteran
Joined
Aug 7, 2019
Messages
32
Reaction score
10
First Language
English
Primarily Uses
RMXP
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:
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

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:

def windowskin_name

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

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
 
Last edited:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,626
Reaction score
14,372
First Language
English
Primarily Uses
RMVXA

I've moved this thread to RGSSx Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.

 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,755
Reaction score
8,748
First Language
English
Primarily Uses
RMMV

I've moved this thread to Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.

 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
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.
 

xChikyx

Veteran
Veteran
Joined
Aug 7, 2019
Messages
32
Reaction score
10
First Language
English
Primarily Uses
RMXP
Thank you, but I found an easier way to do it using conditionals and the built-in change sking option hahah
 

Andrea87Sky

Just a random musician, eventer and spriter.
Veteran
Joined
Aug 30, 2017
Messages
121
Reaction score
2
First Language
Italian
Primarily Uses
RMXP
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)
 

xChikyx

Veteran
Veteran
Joined
Aug 7, 2019
Messages
32
Reaction score
10
First Language
English
Primarily Uses
RMXP
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
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,160
Reaction score
14,209
First Language
English
Primarily Uses
RMMV
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.
 

Latest Threads

Latest Profile Posts

unnamed_image.jpg
SOMEONE'S SINGLE! HE DOES LIKE ALL GENDERS! SADLY, HE HAS NO NUMBER TO NOTE OF BECAUSE HE HAS NO USE FOR A PHONE, BECUASE SUMMONING WORKS MUCH BETTER AND DOES NOT COME WITH AN ITEMISED BILL.
I just found out that MZ regional price on Steam in my place is much cheaper than MV.
Our water started to work again, now i don't have to fill up our toilet with water again.
Finally able to return to work after months of lockdown. My poor feet are hurting :( I need to get used to working again haha

Forum statistics

Threads
108,884
Messages
1,040,276
Members
141,320
Latest member
Hyo
Top