Script Compability

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
I'd like to have my scripts to be compatible with any other scripts. The alias and super have been helpful, but I'm wondering where I should throw in the 'begin rescue' conditional check. Any suggestions? Thanks!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
begin rescue doesn't really make a script compatible, and leaving it out doesn't necessarily make it incompatible. But for good coding practice, if there's somewhere your script could fail, whether on its own or in conjunction with others, you should probably cater for it. I've just recently learned these myself and should start using them more (and go back through old scripts and add them).
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Ah, I'm overloading the basic terminate and update modules on the default classes like Scenes, so I'm thinking of

begin

    mod = self.const_get "terminate"

    alias a_terminate terminate

    def terminate

      a_terminate

      @asd.dispose

    end

  rescue NameError

    def terminate

      super

      @asd.dispose

    end

  end
 

Raizen

Veteran
Veteran
Joined
Oct 24, 2012
Messages
381
Reaction score
660
First Language
Portuguese
Primarily Uses
RMMV
I'd like to have my scripts to be compatible with any other scripts. The alias and super have been helpful, but I'm wondering where I should throw in the 'begin rescue' conditional check. Any suggestions? Thanks!
A lot of scripters use $imported as a Hash to insert a variable value to it. Check that, it can help a lot to make your script compatible with other scripts that contain the variable $imported.

There are a lot of ways to make it more compatible with other scripts, but most of them can maker your code bigger and unclean, maybe the best is sticking to alias and the basic for compatibility and adding just what is best for your script, if someone needs a lot compatible scripts, I think he can search one of the scripters and ask for that, which usually is an easy work to do.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
A lot of scripters use $imported as a Hash to insert a variable value to it. Check that, it can help a lot to make your script compatible with other scripts that contain the variable $imported.

There are a lot of ways to make it more compatible with other scripts, but most of them can maker your code bigger and unclean, maybe the best is sticking to alias and the basic for compatibility and adding just what is best for your script, if someone needs a lot compatible scripts, I think he can search one of the scripters and ask for that, which usually is an easy work to do.
Thanks for the input. What I found about that global variable trend seems to be leaning to branch scripting. And yes, I agree, just create a duplicate script that tweaked a bit based on the user need.
 

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
I'm a little late here, but I'd like to point out that the code block posted would be pretty much useless. If you are getting NameErrors while simply defining your methods, it is usually something you screwed up and not an incompatibility with some other script since very few scripts go about removing methods. Using it like this would only serve to mask the actual error you made. The example you posted would have the first part of the block fail every time due to attempting to get a constant beginning with a lowercase letter.


In general, for completed scripts, you should only use these rescue blocks in an area where you expect a crash due to user input, but the input was not important enough that you can't continue running. An example of this is the default scripts, where having a syntax or name error in a custom damage formula will be rescued and spit out a 0. (even this is borderline for me, ideally it should be accompanied by some sort of error message so it is obvious that the user made a mistake) If you need to use rescue before a point where there is some outside input or variable you can't control correctly, then you should probably reconsider how your script is written.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Thanks for the input. I figured that implementing this to all classes would do better.

Code:
if (String(self.class) == 'Scene_Base')  alias class_Scene_Base_update update  def update    class_Scene_Base_update    #add new stuffs  endend
 
Joined
Aug 12, 2012
Messages
164
Reaction score
78
First Language
English
Primarily Uses
If you want to modify Scene_Base why not just modify Scene_Base?

What is that code going to achieve that

class Scene_Base  alias class_Scene_Base_update update  def update    class_Scene_Base_update  endend
will not?

You're over-thinking this. Just alias methods and use unique variable names and you'll be mostly fine. :)

The only incompatibilities I've ever had were from people using my scripts with a custom battle system (ie. GTBS & Yami's Battle System) and in those cases it didn't take long for me to find an entry point to create a compatibility patch.

You can't prevent incompatibilities; so just deal with them when the time comes.

As far as the rescue keyword goes; Like Mithran said, it's best to use it for user input only. You WANT to know if your script is breaking anywhere besides wherever the user is inputting data.

The user is not a scripter, any problems arising from their input can be brushed off as lack of knowledge (so long as you're absolutely sure that data is bad).

Anywhere else where something goes wrong, then that's on you and you should not be using rescue to save yourself. Chances are you'd probably cause more problems that way than you'd prevent (a good example is undefined behaviour).
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Oh, I meant all Scenes, so that they would update themselves after starting.

Edit:But yea, seems like I'm over-thinking myself. Alright, thanks for the input, folks. Thread can be closed unless someone would like to add.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Well, what you're doing wouldn't apply to "all scenes", but would only apply to scenes that are called Scene_Base, and any scenes that inherit from Scene_Base, which by default is all scenes in the default project, but I have seen scripters defining their own scenes completely for reasons unknown to me (maybe they didn't like relying on the default scene and instead decided to duplicate all the code?)


Also, all scenes call the superclass' update method.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Basically, I'm be doing something like:

class Scene_Base alias class_Scene_Base_start start  alias class_Scene_Base_update update  def start class_Scene_Base_start    self.update if (String(self.class) == "Scene_Base")  end def update class_Scene_Base_update if (String(self.class) == "Scene_Base") #do the following end endendclass Scene_A < Scene_Base alias class_Scene_A_start start  alias class_Scene_A_update update  def start class_scene_A_start    self.update if (String(self.class) == "Scene_A")  end def update class_scene_A_update if (String(self.class) == 'Scene_A') #do the following end endendclass Scene_B < Scene_Base alias class_scene_B_start start  alias class_Scene_B_update update  def start class_scene_B_start    self.update if (String(self.class) == "Scene_B")  end def update class_scene_B_update if (String(self.class) == 'Scene_B') #do the following end endendTherefore each scene would do their own updates during start.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
What exactly are you doing in those "do the following" blocks?

I can think of times where you do NOT want Scene A to be running code defined in its superclass, but unfortunately the default code calls super and you're kind of stuck deciding how to go about doing it.

eg, a questionable example where B objects should not be saying they are A's (this is purely for illustration):

Code:
class A  def test    p "I'm A" if self.is_a?(A)  endendclass B < A  def test    super # this was given to you for some reason    p "I'm B"  endend
But I personally have never had to do things like that.
 
Last edited by a moderator:

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
String(self.class)Will return the name of the object, therefore I could clarify what object it is.

I don't have IDE that runs ruby.

Edit: for some reason, I'm not allowed to write anything after the BB code 'code' (is that even a BB code?). Anyway, The child always inherit the parent's properties, therefore, if you want where B objects should not be saying they are A', then you gotta separate them, or you could do the following:

Code:
class A  def test    p "I'm A" if String(self.class) == 'A'  endendclass B < A  def test    super # this was given to you for some reason    p "I'm B"  endend
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Yes, but the question is, why would you want to do that? It is making your code complex. Without seeing what you are trying to do, it just looks like a questionable idea, especially if you're doing it to every scene.
 
Last edited by a moderator:

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
You wouldn't even need a string comparison there. You could just use instance_of? to check if an object is a certain class and not one of its superclasses. Also, I can't think of any reason why calling a scene's update method within the same scene's start method would be a good idea. Things are made to run in a certain order, if you look at Scene_Base#main, that is the execution path any scene will take when it becomes the active scene in SceneManager, unless you don't subclass from Scene_Base or completely redefine main for a custom scene.

def main start post_start update until scene_changing? pre_terminate terminate endTo break it down, it is start, start, then post_start, then update runs in a loop until the next scene is called, then pre_terminate and terminate, at which point the next scene begins with start again. The process continues as long as the game is running. By forcing an update in and immediately after start, you are altering the path to start > update > post_start > update (looped) > pre_terminate > terminate. You are running the first update to the scene before the transition is even performed. There may even be data missing that was needed from post_start that could break the thing entirely.If you are creating your own subclass for something and you need to overwrite methods in the superclass to get it to work, you should reconsider how your script is laid out. This is more likely to make your script less compatible than more compatible.

Tsukihime wrote some good guidelines for writing broad compatibility scripts here:

http://forums.rpgmakerweb.com/index.php?/topic/20988-techniques-for-writing-compatible-scripts/

Those are all good guidelines, but none of them really work on scripts that aren't written to follow similar guidelines. In other words, some scripts will always have a basic incompatibility that you will need to deal with on a case by case basis; the more complicated the two scripts are and the more methods they share, the higher this likelihood is they will not be compatible. You could be more overzealous than this to ensure a greater chance that they are compatible, but you will never be able to account for everything.

An example of this type of over-planning would be using (*args, &block) as the arguments for every single method being redefined after you alias it, to prevent any potential argumenterror. The simple fact is, if a method has changed enough from the defaults that it now takes a block where it didn't before, you are likely going to run into another issue other than "I should have transparently passed that block I didn't have any reason to know or expect would be there". And the argument list has changed and you need to access any of those arguments, your script would be getting data other than what was expected anyway.

So basically what we are trying to say is:

rescue generally wont help you here

unless you are writing something from scratch try to maintain the program flow from the previous versions (as well as be familiar to what the methods you are modifying/overwriting were accomplishing before)

try to maintain method arguments and return values from previous versions (or transparently pass them)

don't write overcomplicated code as a perceived 'preemptive strike' against compatibility errors, this reduces clarity and can lead to other errors

Addendum:

From your recent script submission, I have a bit better idea of what you are trying to accomplish by checking the specific class of the current object and then performing some action based on that class. However, you can do this same thing by simply having a method perform this action in the highest up class that you are modifying, then simply redefine the method you created in each of the sub-classes to do whatever different thing you need to do (you are not obligated to call super on these). If you would like to show your code here I will provide a more direct example.
 
Last edited by a moderator:

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Thanks Mithran for the throughout reply. I realized about the post_start last night and fixed it, I also increased the readability of my code. Here you go, the latest update:

I made this in a few days of free time, but the bug was so much that I had to keep fixing it whenever I found them, though it works fine so far.

And yes, I was also thinking about putting the check on the class Window itself, but that would be like 40++ addition checks for every update.

#==============================================================================## Michael Windows Changer# Last Updated: 2014.01.06# Requirement: RPG Maker VX Ace# -Knowledge of 'how to use scripts'# -Knowledge of Window Designation (basically know which window is# which)##==============================================================================#==============================================================================#Compability: - Script should be compatible with any other script(s).# - If the picture you use doesn't have the right size as the# window's size, then use window_show_all to show picture in full size,# then move it using window_show_all_move.# - Bitmap cannot convert .gif file yet.##==============================================================================#==============================================================================# Biography lol#==============================================================================# 2013.01.06 --Increaseeeeeeeeeeeeddddddd readibility. .______________________.# 2013.01.05 --File is trimmed down# 2013.01.03 --window_show_all and window_move_origin and their counter-parts# are introduced# --Reforming the arrays# --Increased readibility :/# 2013.01.02 --Naming convention is improved# --Some methods are simplified# --File is trimmed down# --@temp1 & @temp2 variables are removed# --Replacing switch on the windows itself instead of scenes# 2013.01.01 --window_opacity(i, opacity) is introduced# 2013.12.30 --Trimmed down the file size# 2013.12.27 --Fixed window_default(i)# --window_depth(i, depth) is introduced & implemented# --Fixed window_default(i) and window_center(i) is introduced# --Fixed Scene_File# 2013.12.26 --Fixed Scene_Title - Sprite is now in correlation with the window# --Raising Compatibility# --window_move(i, x, y, width, height) is introduced# --window_default(i) is introduced# --All Scenes are overloaded with the new switch# 2013.12.25 --Fixed bugs on local @temp1 and @temp2 disposal# --Scene_MenuBase is added# --Fixed bugs for 'name'# --Fixed bugs on various Scenes# 2013.12.24 --Script is uploaded# 2013.12.23 --Window_Message is completed# 2013.12.22 --Scene_Equip is completed# --Scene_Skill is completed# --Scene_Item is completed# --Scene_ItemBase is completed# --Scene_Menu is completed# --Scene_Map is completed# --Scene_Title is completed# --Scene_Menu is completed# --All Scenes that need to be overloaded have been overloaded# --Updating array to store image name# 2013.12.21 --Installing Game_Interpreter# --Scene_Battle is completed# --Scene_Debug is completed# --Scene_Name is completed# --Scene_Shop is completed# --Scene_End is completed# --Scene_Save and Scene_Load skipped -- No Window yield# --Scene_File is completed# --Scene_Status is completed# 2013.12.20 --Scene_Battle is completed# 2013.12.19 --Works for Windows_BattleStatus# 2013.12.18 --Script is initialized -- Getting know Ruby + RGSS Libraries#==============================================================================# Description#==============================================================================# This script is used to stick image(s) to windows with your desired image(s)# by overloading all windows. You can also edit it's location.##==============================================================================# Installation#==============================================================================# - This script will OVERLOAD all DEFAULT windows.# - Place this script to be below other overloading windows script. If you are# not sure where, place it to be the lowest of the material section.# - If you have a bust script, put the bust script anywhere below this script.# - Place the window Images (by default) in that folder# <your project>/Graphics/Windows/(type of windows)/##==============================================================================# How to Use:# - window_on(window #, 'file_name.extention_name')# For Example:# window_on(6, 'ex.jpg') -> activate window #6 background(window_gold_changer)# with ex.jpg as the content# -> Btw, window #6 is Window_Gold# -> If you want to change the picture, just do the same# thing, but use different file_name.## - window_off(window #)# For Example:# window_off(5) -> deactivate window #5 background and its content# -> deactivating will hide the background and return the# window rectangle back to the boring blue color with its# redundant white padding.## - window_show_all(i) -> JUST USE THIS COMMAND and window_on if you're confused with# coordination. Basically window_show_all will display# your picture from the center of the window.# -> Do I have to use this for every picture that's oversized?# -> No, just do window_on(6, 'ex.jpg', 'show_all') <<< see the 'show_all'?# (don't forget the quotation mark)# - window_show_all_move(i, x, y) -> To move the fixed position## - window_center(i)# For Example:# window_center(6) -> Move the window #6 background content to center position# Default position is at the center (272,208) of the graphic and# occupy the size of the graphic (if your picture has size# larger than the graphic (544 x 416), it will fill the graphic)# -> Make sure that switch is 'on' or else nothing would happen.## - window_move_full(i, x, y, width, height)# For Example:# window_move_full(6, 24, -24, 400, 400)# -> TIPS: If you are not sure how to adjust, the coordinate, starts with# window_move first.# -> move the window #6 background content to (24,-24) position. Remember that# center coordinate is (0,0) and to move up, y needs to be negative, to move# down, y needs to be positive, to move left, x needs to be negative, to move# right, x needs to be positive.# -> width and height are there as a border to make sure that your picture doesn't# go beyond the given size (400 x 400).# -> TIPS: If you don't want to have border, simply set the border to be the# Graphics' height and width.# To set Graphics' height and width:# window_move(5, 24, -24, Graphics.width, Graphics.height)## - window_default(i)# For Example:# window_default(6) -> Turn off movement switch for window #6 background# -> This will return window #6 to the original position## - window_depth(i, depth)# For Example:# window_depth(6, -1) -> Increases the depthness of window #6 background content# by -1, which means, if there's other window background# in the graphic beside window #6 background, that window# background will appear to be above window #6 background.# -> Make sure that switch is 'on' or else nothing would happen.## - window_opacity(i, opacity)# For Example:# window_opacity(6, 0) -> Set window #6 background opacity to 0 (100% transparent).# -> Opacity value is from 0 (fully see-through) to 255 (solid).# -> Make sure that switch is 'on' or else nothing would happen.# -> Default opacity is 255 when window background is on.## Have Fun!##==============================================================================module Windows_Changer #============================================================================ # Windows Changer = USE Game_Interpret for activation (scroll all the way # down for the key words (window_on and window_off)) # Use the element # list below for 'window #'. # # Default Switch = off (switch only available for activate windows) # This is for Original Windows - Scroll Down for Windows from other scripts # the array stores these values: # [file_name, # file_directory, # sprite.z, # sprite.opacity, # sprite.type_of_movement_change, # sprite.x, # sprite.y, # sprite.src_rect.x, # sprite.src_rect.y, # sprite.src_rect.width, # sprite.src_rect.height] #============================================================================ Michael_Windows_Background_ftw_101_Array = [ Window_Changer = ["Element #0","Graphics\\Windows",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_Base_Changer = ["Element #1","Graphics\\Windows\\Window_Base",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_Selectable_Changer = ["Element #2","Graphics\\Windows\\Window_Selectable",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_Command_Changer = ["Element #3","Graphics\\Windows\\Window_Command",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_HorzCommand_Changer = ["Element #4","Graphics\\Windows\\Window_HorzCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_Help_Changer = ["Element #5","Graphics\\Windows\\Window_Help",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_Gold_Changer = ["Element #6","Graphics\\Windows\\Window_Gold",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_MenuCommand_Changer = ["Element #7","Graphics\\Windows\\Window_MenuCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_MenuStatus_Changer = ["Element #8","Graphics\\Windows\\Window_MenuStatus",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_MenuActor_Changer = ["Element #9","Graphics\\Windows\\Window_MenuActor",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ItemCategory_Changer = ["Element #10","Graphics\\Windows\\Window_ItemCategory",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ItemList_Changer = ["Element #11","Graphics\\Windows\\Window_ItemList",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_SkillCommand_Changer = ["Element #12","Graphics\\Windows\\Window_SkillCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_SkillStatus_Changer = ["Element #13","Graphics\\Windows\\Window_SkillStatus",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_SkillList_Changer = ["Element #14","Graphics\\Windows\\Window_SkillList",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_EquipStatus_Changer = ["Element #15","Graphics\\Windows\\Window_EquipStatus",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_EquipCommand_Changer = ["Element #16","Graphics\\Windows\\Window_EquipCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_EquipSlot_Changer = ["Element #17","Graphics\\Windows\\Window_EquipSlot",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_EquipItem_Changer = ["Element #18","Graphics\\Windows\\Window_EquipItem",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_Status_Changer = ["Element #19","Graphics\\Windows\\Window_Status",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_SaveFile_Changer = ["Element #20","Graphics\\Windows\\Window_SaveFile",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ShopCommand_Changer = ["Element #21","Graphics\\Windows\\Window_ShopCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ShopBuy_Changer = ["Element #22","Graphics\\Windows\\Window_ShopBuy",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ShopSell_Changer = ["Element #23","Graphics\\Windows\\Window_ShopSell",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ShopNumber_Changer = ["Element #24","Graphics\\Windows\\Window_ShopNumber",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ShopStatus_Changer = ["Element #25","Graphics\\Windows\\Window_ShopStatus",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_NameEdit_Changer = ["Element #26","Graphics\\Windows\\Window_NameEdit",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_NameInput_Changer = ["Element #27","Graphics\\Windows\\Window_NameInput",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ChoiceList_Changer = ["Element #28","Graphics\\Windows\\Window_ChoiceList",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_NumberInput_Changer = ["Element #29","Graphics\\Windows\\Window_NumberInput",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_KeyItem_Changer = ["Element #30","Graphics\\Windows\\Window_KeyItem",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_Message_Changer = ["Element #31","Graphics\\Windows\\Window_Message",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ScrollText_Changer = ["Element #32","Graphics\\Windows\\Window_ScrollText",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_MapName_Changer = ["Element #33","Graphics\\Windows\\Window_MapName",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_BattleLog_Changer = ["Element #34","Graphics\\Windows\\Window_BattleLog",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_PartyCommand_Changer = ["Element #35","Graphics\\Windows\\Window_PartyCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_ActorCommand_Changer = ["Element #36","Graphics\\Windows\\Window_ActorCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_BattleStatus_Changer = ["Element #37","Graphics\\Windows\\Window_BattleStatus",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_BattleActor_Changer = ["Element #38","Graphics\\Windows\\Window_BattleActor",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_BattleEnemy_Changer = ["Element #39","Graphics\\Windows\\Window_BattleEnemy",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_BattleSkill_Changer = ["Element #40","Graphics\\Windows\\Window_BattleSkill",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_BattleItem_Changer = ["Element #41","Graphics\\Windows\\Window_BattleItem",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_TitleCommand_Changer = ["Element #42","Graphics\\Windows\\Window_TitleCommand",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_GameEnd_Changer = ["Element #43","Graphics\\Windows\\Window_GameEnd",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_DebugLeft_Changer = ["Element #44","Graphics\\Windows\\Window_DebugLeft",nil,nil,'false',nil,nil,nil,nil,nil,nil], window_DebugRight_Changer = ["Element #45","Graphics\\Windows\\Window_DebugRight",nil,nil,'false',nil,nil,nil,nil,nil,nil], ] #Add more elements here Number_Of_Element = 46 #Modify this number as more elements are added Starting_Switch_Point = 500 #Modify this number if script clash with other script(s)end#==============================================================================# Cache#==============================================================================module Cache def self.cache_extended(folder, filename) load_bitmap("#{folder}/", "#{filename}") endend#==============================================================================# Window#==============================================================================class Window attr_accessor :oh_I_got_changed attr_accessor :michael_background_viewport_101 alias michael_Window_initialize initialize def initialize(x, y, width, height) #Gotta love hidden script! michael_Window_initialize(x, y, width, height) self.oh_I_got_changed = false create_michael_background_viewport_101_102_103_104 create_michael_background_sprite_101 end def create_michael_background_viewport_101_102_103_104 #Naming convention ftw @michael_background_viewport_101 = Viewport.new #The only locations where new member functions are created @michael_background_viewport_101.z = self.z - 1 #are class Window, class Sprite, module Cacheend #and class Game_Interpreter. Everything else is aliased. def create_michael_background_sprite_101 @michael_self_background_ftw_101 = Sprite.new end alias michael_Window_dispose dispose #Everything is disposed here def dispose #Basically every window made, michael_Window_dispose #1 viewport and 1 sprite are also made @michael_background_viewport_101.dispose @michael_self_background_ftw_101.dispose end def did_I_get_changed? return self.oh_I_got_changed end def change_me_by_michael self.oh_I_got_changed = true endend#==============================================================================# Window_Base#==============================================================================class Window_Base < Window alias michael_Window_Base_initialize initialize alias michael_Window_Base_update update alias michael_Window_Base_show show alias michael_Window_Base_hide hide def show michael_Window_Base_show @michael_self_background_ftw_101.visible = true self end def hide michael_Window_Base_hide @michael_self_background_ftw_101.visible = false self end def initialize(x, y, width, height) michael_Window_Base_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 1) if String(self.class) == 'Window_Base' end def update michael_Window_Base_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 1) if String(self.class) == 'Window_Base' endend#==============================================================================# Window_Selectable#==============================================================================class Window_Selectable < Window_Base alias michael_Window_Selectable_initialize initialize alias michael_Window_Selectable_update update def initialize(x, y, width, height) michael_Window_Selectable_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 2) if String(self.class) == 'Window_Selectable' end def update michael_Window_Selectable_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 2) if String(self.class) == 'Window_Selectable' endend#==============================================================================# Window_Command#==============================================================================class Window_Command < Window_Selectable alias michael_Window_Command_initialize initialize alias michael_Window_Command_update update def initialize(x, y) michael_Window_Command_initialize(x, y) @michael_self_background_ftw_101.michael_window_background_sprite(self, 3) if String(self.class) == 'Window_Command' end def update michael_Window_Command_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 3) if String(self.class) == 'Window_Command' endend#==============================================================================# Window_HorzCommand#==============================================================================class Window_HorzCommand < Window_Commandend #No initialize, so no need to overload#==============================================================================# Window_Help#==============================================================================class Window_Help < Window_Base alias michael_Window_Help_initialize initialize alias michael_Window_Help_update update def initialize(line_number = 2) michael_Window_Help_initialize(line_number = 2) @michael_self_background_ftw_101.michael_window_background_sprite(self, 5) if String(self.class) == 'Window_Help' end def update michael_Window_Help_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 5) if String(self.class) == 'Window_Help' endend#==============================================================================# Window_Gold#==============================================================================class Window_Gold < Window_Base alias michael_Window_Gold_initialize initialize alias michael_Window_Gold_update update def initialize michael_Window_Gold_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 6) if String(self.class) == 'Window_Gold' end def update michael_Window_Gold_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 6) if String(self.class) == 'Window_Gold' endend#==============================================================================# Window_MenuCommand#==============================================================================class Window_MenuCommand < Window_Command alias michael_Window_MenuCommand_initialize initialize alias michael_Window_MenuCommand_update update def initialize michael_Window_MenuCommand_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 7) if String(self.class) == 'Window_MenuCommand' end def update michael_Window_MenuCommand_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 7) if String(self.class) == 'Window_MenuCommand' endend#==============================================================================# Window_MenuStatus#==============================================================================class Window_MenuStatus < Window_Selectable alias michael_Window_MenuStatus_initialize initialize alias michael_Window_MenuStatus_update update def initialize(x, y) michael_Window_MenuStatus_initialize(x, y) @michael_self_background_ftw_101.michael_window_background_sprite(self, 8) if String(self.class) == 'Window_MenuStatus' end alias michael_Window_MenuStatus_update update def update michael_Window_MenuStatus_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 8) if String(self.class) == 'Window_MenuStatus' endend#==============================================================================# Window_MenuActor#==============================================================================class Window_MenuActor < Window_MenuStatus alias michael_Window_MenuActor_initialize initialize alias michael_Window_MenuActor_update update def initialize michael_Window_MenuActor_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 9) if String(self.class) == 'Window_MenuActor' end def update michael_Window_MenuActor_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 9) if String(self.class) == 'Window_MenuActor' endend#==============================================================================# Window_ItemCategory#==============================================================================class Window_ItemCategory < Window_HorzCommand alias michael_Window_ItemCategory_initialize initialize alias michael_Window_ItemCategory_update update def initialize michael_Window_ItemCategory_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 10) if String(self.class) == 'Window_ItemCategory' end def update michael_Window_ItemCategory_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 10) if String(self.class) == 'Window_ItemCategory' endend#==============================================================================# Window_ItemList#==============================================================================class Window_ItemList < Window_Selectable alias michael_Window_ItemList_initialize initialize alias michael_Window_ItemList_update update def initialize(x, y, width, height) michael_Window_ItemList_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 11) if String(self.class) == 'Window_ItemList' end def update michael_Window_ItemList_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 11) if String(self.class) == 'Window_ItemList' endend#==============================================================================# Window_SkillCommand#==============================================================================class Window_SkillCommand < Window_Command alias michael_Window_SkillCommand_initialize initialize alias michael_Window_SkillCommand_update update def initialize(x, y) michael_Window_SkillCommand_initialize(x, y) @michael_self_background_ftw_101.michael_window_background_sprite(self, 12) if String(self.class) == 'Window_SkillCommand' end def update michael_Window_SkillCommand_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 12) if String(self.class) == 'Window_SkillCommand' endend#==============================================================================# Window_SkillStatus#==============================================================================class Window_SkillStatus < Window_Base alias michael_Window_SkillStatus_initialize initialize alias michael_Window_SkillStatus_update update def initialize(x, y) michael_Window_SkillStatus_initialize(x, y) @michael_self_background_ftw_101.michael_window_background_sprite(self, 13) if String(self.class) == 'Window_SkillStatus' end def update michael_Window_SkillStatus_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 13) if String(self.class) == 'Window_SkillStatus' endend#==============================================================================# Window_SkillList#==============================================================================class Window_SkillList < Window_Selectable alias michael_Window_SkillList_initialize initialize alias michael_Window_SkillList_update update def initialize(x, y, width, height) michael_Window_SkillList_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 14) if String(self.class) == 'Window_SkillList' end def update michael_Window_SkillList_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 14) if String(self.class) == 'Window_SkillList' endend#==============================================================================# Window_EquipStatus#==============================================================================class Window_EquipStatus < Window_Base alias michael_Window_EquipStatus_initialize initialize alias michael_Window_EquipStatus_update update def initialize(x, y) michael_Window_EquipStatus_initialize(x, y) @michael_self_background_ftw_101.michael_window_background_sprite(self, 15) if String(self.class) == 'Window_EquipStatus' end def update michael_Window_EquipStatus_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 15) if String(self.class) == 'Window_EquipStatus' endend#==============================================================================# Window_EquipCommand#==============================================================================class Window_EquipCommand < Window_HorzCommand alias michael_Window_EquipCommand_initialize initialize alias michael_Window_EquipCommand_update update def initialize(x, y, width) michael_Window_EquipCommand_initialize(x, y, width) @michael_self_background_ftw_101.michael_window_background_sprite(self, 16) if String(self.class) == 'Window_EquipCommand' end def update michael_Window_EquipCommand_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 16) if String(self.class) == 'Window_EquipCommand' endend#==============================================================================# Window_EquipSlot#==============================================================================class Window_EquipSlot < Window_Selectable alias michael_Window_EquipSlot_initialize initialize alias michael_Window_EquipSlot_update update def initialize(x, y, width) michael_Window_EquipSlot_initialize(x, y, width) @michael_self_background_ftw_101.michael_window_background_sprite(self, 17) if String(self.class) == 'Window_EquipSlot' end def update michael_Window_EquipSlot_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 17) if String(self.class) == 'Window_EquipSlot' endend#==============================================================================# Window_EquipItem#==============================================================================class Window_EquipItem < Window_ItemList alias michael_Window_EquipItem_initialize initialize alias michael_Window_EquipItem_update update def initialize(x, y, width, height) michael_Window_EquipItem_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 18) if String(self.class) == 'Window_EquipItem' end def update michael_Window_EquipItem_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 18) if String(self.class) == 'Window_EquipItem' endend#==============================================================================# Window_Status#==============================================================================class Window_Status < Window_Selectable alias michael_Window_Status_initialize initialize alias michael_Window_Status_update update def initialize(actor) michael_Window_Status_initialize(actor) @michael_self_background_ftw_101.michael_window_background_sprite(self, 19) if String(self.class) == 'Window_Status' end def update michael_Window_Status_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 19) if String(self.class) == 'Window_Status' endend#==============================================================================# Window_SaveFile#==============================================================================class Window_SaveFile < Window_Base alias michael_Window_SaveFile_initialize initialize alias michael_Window_SaveFile_update update def initialize(height, index) michael_Window_SaveFile_initialize(height, index) @michael_self_background_ftw_101.michael_window_background_sprite(self, 20) if String(self.class) == 'Window_SaveFile' end def update michael_Window_SaveFile_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 20) if String(self.class) == 'Window_SaveFile' endend#==============================================================================# Window_ShopCommand#==============================================================================class Window_ShopCommand < Window_HorzCommand alias michael_Window_ShopCommand_initialize initialize alias michael_Window_ShopCommand_update update def initialize(window_width, purchase_only) michael_Window_ShopCommand_initialize(window_width, purchase_only) @michael_self_background_ftw_101.michael_window_background_sprite(self, 21) if String(self.class) == 'Window_ShopCommand' end def update michael_Window_ShopCommand_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 21) if String(self.class) == 'Window_ShopCommand' endend#==============================================================================# Window_ShopBuy#==============================================================================class Window_ShopBuy < Window_Selectable alias michael_Window_ShopBuy_initialize initialize alias michael_Window_ShopBuy_update update def initialize(x, y, height, shop_goods) michael_Window_ShopBuy_initialize(x, y, height, shop_goods) @michael_self_background_ftw_101.michael_window_background_sprite(self, 22) if String(self.class) == 'Window_ShopBuy' end def update michael_Window_ShopBuy_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 22) if String(self.class) == 'Window_ShopBuy' endend#==============================================================================# Window_ShopSell#==============================================================================class Window_ShopSell < Window_ItemList alias michael_Window_ShopSell_initialize initialize alias michael_Window_ShopSell_update update def initialize(x, y, width, height) michael_Window_ShopSell_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 23) if String(self.class) == 'Window_ShopSell' end def update michael_Window_ShopSell_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 23) if String(self.class) == 'Window_ShopSell' endend#==============================================================================# Window_ShopNumber#==============================================================================class Window_ShopNumber < Window_Selectable alias michael_Window_ShopNumber_initialize initialize alias michael_Window_ShopNumber_update update def initialize(x, y, height) michael_Window_ShopNumber_initialize(x, y, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 24) if String(self.class) == 'Window_ShopNumber' end def update michael_Window_ShopNumber_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 24) if String(self.class) == 'Window_ShopNumber' endend#==============================================================================# Window_ShopStatus#==============================================================================class Window_ShopStatus < Window_Base alias michael_Window_ShopStatus_initialize initialize alias michael_Window_ShopStatus_update update def initialize(x, y, width, height) michael_Window_ShopStatus_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 25) if String(self.class) == 'Window_ShopStatus' end def update michael_Window_ShopStatus_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 25) if String(self.class) == 'Window_ShopStatus' endend#==============================================================================# Window_NameEdit#==============================================================================class Window_NameEdit < Window_Base alias michael_Window_NameEdit_initialize initialize alias michael_Window_NameEdit_update update def initialize(actor, max_char) michael_Window_NameEdit_initialize(actor, max_char) @michael_self_background_ftw_101.michael_window_background_sprite(self, 26) if String(self.class) == 'Window_NameEdit' end def update michael_Window_NameEdit_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 26) if String(self.class) == 'Window_NameEdit' endend#==============================================================================# Window_NameInput#==============================================================================class Window_NameInput < Window_Selectable alias michael_Window_NameInput_initialize initialize alias michael_Window_NameInput_update update def initialize(edit_window) michael_Window_NameInput_initialize(edit_window) @michael_self_background_ftw_101.michael_window_background_sprite(self, 27) if String(self.class) == 'Window_NameInput' end def update michael_Window_NameInput_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 27) if String(self.class) == 'Window_NameInput' endend#==============================================================================# Window_ChoiceList#==============================================================================class Window_ChoiceList < Window_Command alias michael_Window_ChoiceList_initialize initialize alias michael_Window_ChoiceList_update update def initialize(message_window) michael_Window_ChoiceList_initialize(message_window) @michael_self_background_ftw_101.michael_window_background_sprite(self, 28) if String(self.class) == 'Window_ChoiceList' end def update michael_Window_ChoiceList_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 28) if String(self.class) == 'Window_ChoiceList' endend#==============================================================================# Window_NumberInput#==============================================================================class Window_NumberInput < Window_Base alias michael_Window_NumberInput_initialize initialize alias michael_Window_NumberInput_update update def initialize(message_window) michael_Window_NumberInput_initialize(message_window) @michael_self_background_ftw_101.michael_window_background_sprite(self, 29) if String(self.class) == 'Window_NumberInput' end def update michael_Window_NumberInput_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 29) if String(self.class) == 'Window_NumberInput' endend#==============================================================================# Window_KeyItem#==============================================================================class Window_KeyItem < Window_ItemList alias michael_Window_KeyItem_initialize initialize alias michael_Window_KeyItem_update update def initialize(message_window) michael_Window_KeyItem_initialize(message_window) @michael_self_background_ftw_101.michael_window_background_sprite(self, 30) if String(self.class) == 'Window_KeyItem' end def update michael_Window_KeyItem_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 30) if String(self.class) == 'Window_KeyItem' endend#==============================================================================# Window_Message#==============================================================================class Window_Message < Window_Base alias michael_Window_Message_initialize initialize alias michael_Window_Message_update update def initialize michael_Window_Message_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 31) if String(self.class) == 'Window_Message' @gold_window.update #I'm thinking of self.update if String(self.class) == 'Window_Message' for this, but that would be doing much more function calls. So yea! end def update michael_Window_Message_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 31) if String(self.class) == 'Window_Message' endend#==============================================================================# Window_ScrollText#==============================================================================class Window_ScrollText < Window_Base alias michael_Window_ScrollText_initialize initialize alias michael_Window_ScrollText_update update def initialize michael_Window_ScrollText_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 32) if String(self.class) == 'Window_ScrollText' end def update michael_Window_ScrollText_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 32) if String(self.class) == 'Window_ScrollText' endend#==============================================================================# Window_MapName#==============================================================================class Window_MapName < Window_Base alias michael_Window_MapName_initialize initialize alias michael_Window_MapName_update update def initialize michael_Window_MapName_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 33) if String(self.class) == 'Window_MapName' end def update michael_Window_MapName_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 33) if String(self.class) == 'Window_MapName' endend#==============================================================================# Window_BattleLog#==============================================================================class Window_BattleLog < Window_Selectable alias michael_Window_BattleLog_initialize initialize alias michael_Window_BattleLog_update update def initialize michael_Window_BattleLog_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 34) if String(self.class) == 'Window_BattleLog' end def update michael_Window_BattleLog_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 34) if String(self.class) == 'Window_BattleLog' endend#==============================================================================# Window_PartyCommand#=========================-====================================================class Window_PartyCommand < Window_Command alias michael_Window_PartyCommand_initialize initialize alias michael_Window_PartyCommand_update update def initialize michael_Window_PartyCommand_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 35) if String(self.class) == 'Window_PartyCommand' end def update michael_Window_PartyCommand_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 35) if String(self.class) == 'Window_PartyCommand' endend#==============================================================================# Window_ActorCommand#==============================================================================class Window_ActorCommand < Window_Command alias michael_Window_ActorCommand_initialize initialize alias michael_Window_ActorCommand_update update def initialize michael_Window_ActorCommand_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 36) if String(self.class) == 'Window_ActorCommand' end def update michael_Window_ActorCommand_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 36) if String(self.class) == 'Window_ActorCommand' endend#==============================================================================# Window_BattleStatus#==============================================================================class Window_BattleStatus < Window_Selectable alias michael_Window_BattleStatus_initialize initialize alias michael_Window_BattleStatus_update update def initialize michael_Window_BattleStatus_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 37) if String(self.class) == 'Window_BattleStatus' end def update michael_Window_BattleStatus_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 37) if String(self.class) == 'Window_BattleStatus' endend#==============================================================================# Window_BattleActor#==============================================================================class Window_BattleActor < Window_BattleStatus alias michael_Window_BattleActor_initialize initialize alias michael_Window_BattleActor_update update def initialize(info_viewport) michael_Window_BattleActor_initialize(info_viewport) @michael_self_background_ftw_101.michael_window_background_sprite(self, 38) if String(self.class) == 'Window_BattleActor' end def update michael_Window_BattleActor_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 38) if String(self.class) == 'Window_BattleActor' endend#==============================================================================# Window_BattleEnemy#==============================================================================class Window_BattleEnemy < Window_Selectable alias michael_Window_BattleEnemy_update update alias michael_Window_BattleEnemy_initialize initialize def initialize(info_viewport) michael_Window_BattleEnemy_initialize(info_viewport) @michael_self_background_ftw_101.michael_window_background_sprite(self, 39) if String(self.class) == 'Window_BattleEnemy' end def update michael_Window_BattleEnemy_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 39) if String(self.class) == 'Window_BattleEnemy' endend#==============================================================================# Window_BattleSkill#==============================================================================class Window_BattleSkill < Window_SkillList alias michael_Window_BattleSkill_initialize initialize alias michael_Window_BattleSkill_update update def initialize(help_window, info_viewport) michael_Window_BattleSkill_initialize(help_window, info_viewport) @michael_self_background_ftw_101.michael_window_background_sprite(self, 40) if String(self.class) == 'Window_BattleSkill' end def update michael_Window_BattleSkill_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 40) if String(self.class) == 'Window_BattleSkill' endend#==============================================================================# Window_BattleItem#==============================================================================class Window_BattleItem < Window_ItemList alias michael_Window_BattleItem_initialize initialize alias michael_Window_BattleItem_update update def initialize(help_window, info_viewport) michael_Window_BattleItem_initialize(help_window, info_viewport) @michael_self_background_ftw_101.michael_window_background_sprite(self, 41) if String(self.class) == 'Window_BattleItem' end def update michael_Window_BattleItem_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 41) if String(self.class) == 'Window_BattleItem' endend#==============================================================================# Window_TitleCommand#==============================================================================class Window_TitleCommand < Window_Command alias michael_Window_TitleCommand_initialize initialize alias michael_Window_TitleCommand_update update def initialize michael_Window_TitleCommand_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 42) if String(self.class) == 'Window_TitleCommand' end def update michael_Window_TitleCommand_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 42) if String(self.class) == 'Window_TitleCommand' endend#==============================================================================# Window_GameEnd#==============================================================================class Window_GameEnd < Window_Command alias michael_Window_GameEnd_initialize initialize alias michael_Window_GameEnd_update update def initialize michael_Window_GameEnd_initialize @michael_self_background_ftw_101.michael_window_background_sprite(self, 43) if String(self.class) == 'Window_GameEnd' end def update michael_Window_GameEnd_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 43) if String(self.class) == 'Window_GameEnd' endend#==============================================================================# Window_DebugLeft#==============================================================================class Window_DebugLeft < Window_Selectable alias michael_Window_DebugLeft_initialize initialize alias michael_Window_DebugLeft_update update def initialize(x, y) michael_Window_DebugLeft_initialize(x, y) @michael_self_background_ftw_101.michael_window_background_sprite(self, 44) if String(self.class) == 'Window_DebugLeft' end def update michael_Window_DebugLeft_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 44) if String(self.class) == 'Window_DebugLeft' endend#==============================================================================# Window_DebugRight#==============================================================================class Window_DebugRight < Window_Selectable alias michael_Window_DebugRight_initialize initialize alias michael_Window_DebugRight_update update def initialize(x, y, width) michael_Window_DebugRight_initialize(x, y, width) @michael_self_background_ftw_101.michael_window_background_sprite(self, 45) if String(self.class) == 'Window_DebugRight' end def update michael_Window_DebugRight_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 45) if String(self.class) == 'Window_DebugRight' endend#==============================================================================# Sprite#==============================================================================class Sprite #Another hidden script ftw! def michael_window_background_sprite(window, i) if __method__[0...7] == 48998564589.to_s(36) if $game_switches[Windows_Changer::Starting_Switch_Point + i] self.viewport = (window.viewport) ? window.viewport : window.michael_background_viewport_101 unless window.did_I_get_changed? @just_for_naming_convention_sake_saving_window_back_opacity = window.back_opacity unless window.back_opacity.nil? @just_for_naming_convention_sake_saving_window_opacity = window.opacity unless window.opacity.nil? end window.back_opacity = 0 unless window.back_opacity.nil? window.opacity = 0 unless window.opacity.nil? window.change_me_by_michael self.x = window.x self.y = window.y self.src_rect.width = window.width self.src_rect.height = window.height self.visible = ((window.openness == 255) && (window.visible)) #This is where picture is loaded name = $game_message.michael_windows_background_ftw_101[0] folder = $game_message.michael_windows_background_ftw_101[1] self.bitmap = Cache.cache_extended(folder, name) self.z += $game_message.michael_windows_background_ftw_101[2] unless $game_message.michael_windows_background_ftw_101[2].nil? self.opacity = $game_message.michael_windows_background_ftw_101[3] if (self.visible) && !($game_message.michael_windows_background_ftw_101[3].nil?) #This is where the sprite_movement comes into play case String($game_message.michael_windows_background_ftw_101[4]) when 'false' #do nothing when 'show_all' self.x -= ((self.bitmap.width - window.width) / 2) self.src_rect.x = 0 if self.x < 0 #Muahahaha figured it out. Freakin' coordination won't show up if value is under 0. self.y -= ((self.bitmap.height - window.height) / 2) self.src_rect.y = 0 if self.y < 0 self.src_rect.width = Graphics.width self.src_rect.height = Graphics.height when 'move' self.x += ($game_message.michael_windows_background_ftw_101[5] - ((self.bitmap.width - window.width) / 2)) self.src_rect.x = 0 if self.x < 0 self.y += ($game_message.michael_windows_background_ftw_101[6] - ((self.bitmap.height - window.height) / 2)) self.src_rect.y = 0 if self.y < 0 self.src_rect.width = Graphics.width self.src_rect.height = Graphics.height when 'move_origin' self.x += $game_message.michael_windows_background_ftw_101[5] self.src_rect.x = 0 if self.x < 0 self.y += $game_message.michael_windows_background_ftw_101[6] self.src_rect.y = 0 if self.y < 0 when 'center', 'move_all' self.x = $game_message.michael_windows_background_ftw_101[5] self.y = $game_message.michael_windows_background_ftw_101[6] self.src_rect.x = $game_message.michael_windows_background_ftw_101[7] self.src_rect.y = $game_message.michael_windows_background_ftw_101[8] self.src_rect.width = $game_message.michael_windows_background_ftw_101[9] self.src_rect.height = $game_message.michael_windows_background_ftw_101[10] end else #This will return window to default opacity after window_off self.visible = false if ((window.openness == 255) && window.visible) unless @just_for_naming_convention_sake_saving_window_back_opacity.nil? window.back_opacity = @just_for_naming_convention_sake_saving_window_back_opacity end unless @just_for_naming_convention_sake_saving_window_opacity.nil? window.opacity = @just_for_naming_convention_sake_saving_window_opacity end window.oh_I_got_changed = false end end end endend=begin #Scene_Base, Scene_Save, and Scene_File are left out for unnecessary process#==============================================================================# Scene_Base#==============================================================================class Scene_Base alias michael_Scene_Base_start start def start michael_Scene_Base_start update_all_windows endend=end#==============================================================================# Scene_Title#==============================================================================class Scene_Title < Scene_Base alias michael_Scene_Title_start start def start michael_Scene_Title_start update_all_windows endend#==============================================================================# Scene_Map#==============================================================================class Scene_Map < Scene_Base alias michael_Scene_Map_start start def start michael_Scene_Map_start update_all_windows endend#==============================================================================# Scene_MenuBase#==============================================================================class Scene_MenuBase < Scene_Base alias michael_Scene_MenuBase_start start def start michael_Scene_MenuBase_start update_all_windows endend#==============================================================================# Scene_Menu#==============================================================================class Scene_Menu < Scene_MenuBase alias michael_Scene_Menu_start start def start michael_Scene_Menu_start update_all_windows endend#==============================================================================# Scene_ItemBase#==============================================================================class Scene_ItemBase < Scene_MenuBase alias michael_Scene_ItemBase_start start def start michael_Scene_ItemBase_start update_all_windows endend#==============================================================================# Scene_Item#==============================================================================class Scene_Item < Scene_ItemBase alias michael_Scene_Item_start start def start michael_Scene_Item_start update_all_windows endend#==============================================================================# Scene_Skill#==============================================================================class Scene_Skill < Scene_ItemBase alias michael_Scene_Skill_start start def start michael_Scene_Skill_start update_all_windows endend#==============================================================================# Scene_Equip#==============================================================================class Scene_Equip < Scene_MenuBase alias michael_Scene_Equip_start start def start michael_Scene_Equip_start update_all_windows endend#==============================================================================# Scene_Status#==============================================================================class Scene_Status < Scene_MenuBase alias michael_Scene_Status_start start def start michael_Scene_Status_start update_all_windows endend#==============================================================================# Scene_File#==============================================================================class Scene_File < Scene_MenuBase alias michael_Scene_File_start start def start michael_Scene_File_start update_all_windows endend#==============================================================================# Scene_End#==============================================================================class Scene_End < Scene_MenuBase alias michael_Scene_End_start start def start michael_Scene_End_start update_all_windows endend#==============================================================================# Scene_Shop#==============================================================================class Scene_Shop < Scene_MenuBase alias michael_Scene_Shop_start start def start michael_Scene_Shop_start update_all_windows endend#==============================================================================# Scene_Name#==============================================================================class Scene_Name < Scene_MenuBase alias michael_Scene_Name_start start def start michael_Scene_Name_start update_all_windows endend#==============================================================================# Scene_Debug#==============================================================================class Scene_Debug < Scene_MenuBase alias michael_Scene_Debug_start start def start michael_Scene_Debug_start update_all_windows endend#==============================================================================# Scene_Battle#==============================================================================class Scene_Battle < Scene_Base alias michael_Scene_Battle_start start def start michael_Scene_Battle_start update_all_windows endend#==============================================================================# Game_Message#==============================================================================class Game_Message attr_accessor :michael_windows_background_ftw_101 alias michael_initialize initialize def initialize michael_initialize @michael_windows_background_ftw_101 = Windows_Changer::Michael_Windows_Background_ftw_101_Array endend#==============================================================================# Creating Directory#==============================================================================module DataManager class << self alias michael_data_manager_101_init init end def self.init michael_data_manager_101_init create_Windows_Changer_directory end def self.create_Windows_Changer_directory Array.new(Windows_Changer::Number_Of_Element) do |i| Dir.mkdir($game_message.michael_windows_background_ftw_101[1]) if !File.exists?($game_message.michael_windows_background_ftw_101[1]) end endend#===============================================================================# DataManager#===============================================================================module DataManager class << self alias michael_Scene_Battle_create_game_objects create_game_objects end def self.create_game_objects michael_Scene_Battle_create_game_objects #Default setting = false $game_switches[Windows_Changer::Starting_Switch_Point...Windows_Changer::Starting_Switch_Point + Windows_Changer::Number_Of_Element] = false endend#===============================================================================# Game Interpreter#===============================================================================class Game_Interpreter def window_off(i) $game_switches[i + Windows_Changer::Starting_Switch_Point] = false end def window_on(i, name, type_movement = 'false') $game_switches[i + Windows_Changer::Starting_Switch_Point] = true $game_message.michael_windows_background_ftw_101[0] = "#{name}" $game_message.michael_windows_background_ftw_101[4] = String(type_movement) if String(type_movement) == 'false' || 'show_all' || 'center' end def window_depth(i, depth) $game_message.michael_windows_background_ftw_101[2] = depth end def window_opacity(i, opacity) $game_message.michael_windows_background_ftw_101[3] = opacity end def window_default(i) $game_message.michael_windows_background_ftw_101[2] = nil $game_message.michael_windows_background_ftw_101[3] = nil $game_message.michael_windows_background_ftw_101[4] = 'false' end def window_show_all(i) $game_message.michael_windows_background_ftw_101[4] = 'show_all' end def window_show_all_move(i, x, y) $game_message.michael_windows_background_ftw_101[4] = 'move' $game_message.michael_windows_background_ftw_101[5] = x $game_message.michael_windows_background_ftw_101[6] = y end def window_move_origin(i,x,y) $game_message.michael_windows_background_ftw_101[4] = 'move_origin' $game_message.michael_windows_background_ftw_101[5] = x $game_message.michael_windows_background_ftw_101[6] = y end def window_center(i) $game_message.michael_windows_background_ftw_101[4] = 'center' $game_message.michael_windows_background_ftw_101[5] = 272 $game_message.michael_windows_background_ftw_101[6] = 208 $game_message.michael_windows_background_ftw_101[9] = Graphics.width $game_message.michael_windows_background_ftw_101[10] = Graphics.height end def window_move_all(i, x, y, rect_x, rect_y, rect_width, rect_height) #Feeling pro, sir? $game_message.michael_windows_background_ftw_101[4] = 'move_all' $game_message.michael_windows_background_ftw_101[5] = x $game_message.michael_windows_background_ftw_101[6] = y $game_message.michael_windows_background_ftw_101[7] = rect_x $game_message.michael_windows_background_ftw_101[8] = rect_y $game_message.michael_windows_background_ftw_101[9] = rect_width $game_message.michael_windows_background_ftw_101[10] = rect_height endend

Edit:

 instance_of?Wish I found that public method sooner. .-.
 
Last edited by a moderator:

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
What I was speaking of is specifically related to these bits here:

#==============================================================================# Window_Selectable#==============================================================================class Window_Selectable < Window_Base alias michael_Window_Selectable_initialize initialize alias michael_Window_Selectable_update update def initialize(x, y, width, height) michael_Window_Selectable_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 2) if String(self.class) == 'Window_Selectable' end def update michael_Window_Selectable_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 2) if String(self.class) == 'Window_Selectable' endend#==============================================================================# Window_Command#==============================================================================class Window_Command < Window_Selectable alias michael_Window_Command_initialize initialize alias michael_Window_Command_update update def initialize(x, y) michael_Window_Command_initialize(x, y) @michael_self_background_ftw_101.michael_window_background_sprite(self, 3) if String(self.class) == 'Window_Command' end def update michael_Window_Command_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 3) if String(self.class) == 'Window_Command' endend
And all 40+ of the similar ones. All of these michael_window_background_sprite calls can be handled within a single class, Window, since all other Windows subclass from it. The only reason I can see that they are even separate is for the sake of passing a single different integer for each window that is used to check the switch offset. These values could have easily been associated with a method within each of the subclasses you are repeating the same code for (or better yet, just used a hash).

For example, instead of:

class Window_Base < Window alias michael_Window_Base_initialize initialize alias michael_Window_Base_update update def initialize(x, y, width, height) michael_Window_Base_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 1) if String(self.class) == 'Window_Base' end def update michael_Window_Base_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 1) if String(self.class) == 'Window_Base' endend#==============================================================================# Window_Selectable#==============================================================================class Window_Selectable < Window_Base alias michael_Window_Selectable_initialize initialize alias michael_Window_Selectable_update update def initialize(x, y, width, height) michael_Window_Selectable_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, 2) if String(self.class) == 'Window_Selectable' end def update michael_Window_Selectable_update @michael_self_background_ftw_101.michael_window_background_sprite(self, 2) if String(self.class) == 'Window_Selectable' endend
and so on,

You could have done:

class Window_Base < Window alias michael_Window_Base_initialize initialize alias michael_Window_Base_update update def initialize(x, y, width, height) michael_Window_Base_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, int_michael_window_var_offset) end def update michael_Window_Base_update @michael_self_background_ftw_101.michael_window_background_sprite(self, int_michael_window_var_offset) end def int_michael_window_var_offset 1 endendclass Window_Selectable < Window_Base def int_michael_window_var_offset; 2; endendclass Window_Command < Window_Selectable def int_michael_window_var_offset; 3; endend
Even more concise would be:

MICHAEL_WINDOW_VAR_OFFSETS = {Window_Base => 1,Window_Selectable => 2,Window_Command => 3,# .. and so on}class Window_Base < Window alias michael_Window_Base_initialize initialize alias michael_Window_Base_update update def initialize(x, y, width, height) michael_Window_Base_initialize(x, y, width, height) @michael_self_background_ftw_101.michael_window_background_sprite(self, int_michael_window_var_offset) end def update michael_Window_Base_update @michael_self_background_ftw_101.michael_window_background_sprite(self, int_michael_window_var_offset) end def int_michael_window_var_offset MICHAEL_WINDOW_VAR_OFFSETS[self.class] endend
NOTE: excuse typos in the above, but the general point stands

Similarly, all of the separate scene update aliases where you force the window updates should be unnecessary because all Scenes subclass from Scene_Base and call super (either explicitly or implicitly, by not having a start method defined). You shouldn't even need one in Scene_Base, really, since the only reason I can see you would need to do that is to force the associated sprite to update, which is handled on creation anyway.

In general, if you are repeating the same code over, and over, and over, there is probably a better way to do it.

You should consider subclassing Sprite for your custom background sprite and adding methods to that rather than modifying sprite directly. That would give you your own namespace to work in. That single huge method you have defined in Sprite there could also stand to be broken into smaller chunks. Also, if you are going for readability, try not to nest that many statements (you have 5 'end's in a row just to get out of the method).

The script does not make a distinction between two windows of the same class. I guess this is a way to solve the problem of directing user input to a specific window?

You are creating a ton of extra folders. Do these elements really all need to be separate?

And I know I touched on your naming conventions in another thread, but it is also bad to have them extend across the entire line. It also reduces clarity for things to have to either extend beyond the page or wrap to the next line. Since it is usually a pain to change naming conventions mid script though, I recommend that for future scripts.

I'd also bring up that the local variable assignments when you are creating your array constant don't actually do anything, but it looks good for organization purposes and there's no real harm there, so that's fine.

There might be a couple other things that can be cleaned up as well, but those are the main things I could think of. This current version (without all the unnecessary rescue blocks) is honestly passable as long as it works, the rest is just clean up.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Ah, thanks for the recommendations. Greatly appreciate them. : D

And all 40+ of the similar ones. All of these michael_window_background_sprite calls can be handled within a single class, Window, since all other Windows subclass from it. The only reason I can see that they are even separate is for the sake of passing a single different integer for each window that is used to check the switch offset. These values could have easily been associated with a method within each of the subclasses you are repeating the same code for (or better yet, just used a hash).
True, I was thinking of hashing them, but the idea seems to be overkill to me.

Similarly, all of the separate scene update aliases where you force the window updates should be unnecessary because all Scenes subclass from Scene_Base and call super (either explicitly or implicitly, by not having a start method defined). You shouldn't even need one in Scene_Base, really, since the only reason I can see you would need to do that is to force the associated sprite to update, which is handled on creation anyway.
During initialization, some of the scenes changed the window visibility directly instead of using a method.

For ex:

class Scene_Battle < Scene_Base def create_help_window @help_window = Window_Help.new @help_window.visible = false endendThe help_window's sprite would pop up before being updated, that's why I have all the scenes to update all the windows after initialization, therefore, the sprite wouldn't need to 'flicker' during the beginning of Scene_Battle. I do the same for all other Scenes to avoid any 'flicker' from happening.

You should consider subclassing Sprite for your custom background sprite and adding methods to that rather than modifying sprite directly. That would give you your own namespace to work in. That single huge method you have defined in Sprite there could also stand to be broken into smaller chunks. Also, if you are going for readability, try not to nest that many statements (you have 5 'end's in a row just to get out of the method).
Haha, yea, I was thinking about creating sub-class, but I believe it's just a personal's philosophy on parent-child relation. Though I'll break it apart on the next version.

The script does not make a distinction between two windows of the same class. I guess this is a way to solve the problem of directing user input to a specific window?
That's correct.

You are creating a ton of extra folders. Do these elements really all need to be separate?
The user can change the file directory if they wish to. I just keep them organized that way.



And I know I touched on your naming conventions in another thread, but it is also bad to have them extend across the entire line. It also reduces clarity for things to have to either extend beyond the page or wrap to the next line. Since it is usually a pain to change naming conventions mid script though, I recommend that for future scripts.I run code::block IDE to write my code. I installed a customized replace script, which would help alot in case something like that would happen . :3

I'll post my update tomorrow. Got some scripts to be done also.
 

Mithran

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
404
Reaction score
217
First Language
English
Primarily Uses
True, I was thinking of hashing them, but the idea seems to be overkill to me.
Well it was the 40+ duplicate methods that seemed like overkill to me. I can see now that there were other reasons for you to do this now, though, namely that the superclass methods for windows run at the beginning of the subclasses' methods, while the subclasses' methods may then alter some properties and you want to pass the most recent data set before running your method. However, having separate methods in each of the subclasses is only really necessary in situations where you know this is the case (see below).
During initialization, some of the scenes changed the window visibility directly instead of using a method.

For ex:

class Scene_Battle < Scene_Base def create_help_window @help_window = Window_Help.new @help_window.visible = false endend
You could consider aliasing Window#visible= so you have it automatically make the associated sprite's visibility match. The same thing could be done with #open, #close, #openness=, #x=, #y=, etc. However, since your script is not really laid out like that now, you could do the below instead, to avoid mixing methodologies or having to do a full rewrite, this is just another way to do it. Another reason I suggested breaking up the method in sprite is so you can separate out the functions that do specific things like this, so you can simply update the sprite's visibility without having to run that whole update thing.
The help_window's sprite would pop up before being updated, that's why I have all the scenes to update all the windows after initialization, therefore, the sprite wouldn't need to 'flicker' during the beginning of Scene_Battle. I do the same for all other Scenes to avoid any 'flicker' from happening.
Forcing the update in Scene_Base only is still enough. Since create_help_window doesn't happen until after the superclass start method, instead of forcing it after Scene_Base#start, you'd want to do it in an alised method before Scene_Base#post_start (which is right after all sublcasses have finished their start methods, but before the transition).This doesn't really solve initialize calling 'super' at the beginning, though, if the subclasses are the one setting the visibility in their respective initialize methods after 'super' is called. (There is another entry point you could use to make sure they are synced before the window is fully created, but I recommend not using it for the aforementioned reasons.) You don't need to do this in every window, though, just the ones you know alter initial visibility in initialize (about 5 of them), and that is only if you don't want to control it directly by monitoring #visible=, and only if you expect them to be created mid scene (which is fair, I do see this happening even if the default scripts don't).

You could be okay with only aliasing 'update' for the Window_Base superclass, though, since visibility and position are generally updated externally and not within the subclasses' update methods.

If you wanted to blanket aliases for every window class, you also could have just used metacode to generating it rather than retyping it or copy/pasting 40 times. The structure you used looks very much like expanded metacode, anyway, so maybe you already generated it using an external script.

Again, just suggestions. Nothing I see at this point that I can see is really detrimental to the script's function, and that is ultimately what matters.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Well it was the 40+ duplicate methods that seemed like overkill to me. I can see now that there were other reasons for you to do this now, though, namely that the superclass methods for windows run at the beginning of the subclasses' methods, while the subclasses' methods may then alter some properties and you want to pass the most recent data set before running your method. However, having separate methods in each of the subclasses is only really necessary in situations where you know this is the case (see below).
Well, here we go. I gave hashing a shot. : D

module Wndw_Cgr #Window Changer #============================================================================ # Windows Changer = USE Game_Interpret for activation (scroll all the way # down for the key words (window_on and window_off)) # Use the element # list below for 'window #'. # # Default Switch = off (switch only available for activate windows) # This is for Original Windows - Scroll Down for Windows from other scripts # the array stores these values: # [window number, # file_name, # file_directory, # sprite.z, # sprite.opacity, # sprite.type_of_movement_change, # sprite.x, # sprite.y, # sprite.src_rect.x, # sprite.src_rect.y, # sprite.src_rect.width, # sprite.src_rect.height] #============================================================================ Michael_Wndw_Bg_Ary = { #Window Background Array Window => [0,"Element #0","Graphics\\Windows",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Base => [1,"Element #1","Graphics\\Windows\\Window_Base",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Selectable => [2,"Element #2","Graphics\\Windows\\Window_Selectable",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Command => [3,"Element #3","Graphics\\Windows\\Window_Command",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_HorzCommand => [4,"Element #4","Graphics\\Windows\\Window_HorzCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Help => [5,"Element #5","Graphics\\Windows\\Window_Help",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Gold => [6,"Element #6","Graphics\\Windows\\Window_Gold",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MenuCommand => [7,"Element #7","Graphics\\Windows\\Window_MenuCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MenuStatus => [8,"Element #8","Graphics\\Windows\\Window_MenuStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MenuActor => [9,"Element #9","Graphics\\Windows\\Window_MenuActor",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ItemCategory => [10,"Element #10","Graphics\\Windows\\Window_ItemCategory",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ItemList => [11,"Element #11","Graphics\\Windows\\Window_ItemList",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SkillCommand => [12,"Element #12","Graphics\\Windows\\Window_SkillCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SkillStatus => [13,"Element #13","Graphics\\Windows\\Window_SkillStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SkillList => [14,"Element #14","Graphics\\Windows\\Window_SkillList",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipStatus => [15,"Element #15","Graphics\\Windows\\Window_EquipStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipCommand => [16,"Element #16","Graphics\\Windows\\Window_EquipCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipSlot => [17,"Element #17","Graphics\\Windows\\Window_EquipSlot",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_EquipItem => [18,"Element #18","Graphics\\Windows\\Window_EquipItem",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Status => [19,"Element #19","Graphics\\Windows\\Window_Status",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_SaveFile => [20,"Element #20","Graphics\\Windows\\Window_SaveFile",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopCommand => [21,"Element #21","Graphics\\Windows\\Window_ShopCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopBuy => [22,"Element #22","Graphics\\Windows\\Window_ShopBuy",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopSell => [23,"Element #23","Graphics\\Windows\\Window_ShopSell",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopNumber => [24,"Element #24","Graphics\\Windows\\Window_ShopNumber",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ShopStatus => [25,"Element #25","Graphics\\Windows\\Window_ShopStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_NameEdit => [26,"Element #26","Graphics\\Windows\\Window_NameEdit",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_NameInput => [27,"Element #27","Graphics\\Windows\\Window_NameInput",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ChoiceList => [28,"Element #28","Graphics\\Windows\\Window_ChoiceList",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_NumberInput => [29,"Element #29","Graphics\\Windows\\Window_NumberInput",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_KeyItem => [30,"Element #30","Graphics\\Windows\\Window_KeyItem",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_Message => [31,"Element #31","Graphics\\Windows\\Window_Message",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ScrollText => [32,"Element #32","Graphics\\Windows\\Window_ScrollText",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_MapName => [33,"Element #33","Graphics\\Windows\\Window_MapName",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleLog => [34,"Element #34","Graphics\\Windows\\Window_BattleLog",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_PartyCommand => [35,"Element #35","Graphics\\Windows\\Window_PartyCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_ActorCommand => [36,"Element #36","Graphics\\Windows\\Window_ActorCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleStatus => [37,"Element #37","Graphics\\Windows\\Window_BattleStatus",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleActor => [38,"Element #38","Graphics\\Windows\\Window_BattleActor",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleEnemy => [39,"Element #39","Graphics\\Windows\\Window_BattleEnemy",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleSkill => [40,"Element #40","Graphics\\Windows\\Window_BattleSkill",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_BattleItem => [41,"Element #41","Graphics\\Windows\\Window_BattleItem",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_TitleCommand => [42,"Element #42","Graphics\\Windows\\Window_TitleCommand",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_GameEnd => [43,"Element #43","Graphics\\Windows\\Window_GameEnd",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_DebugLeft => [44,"Element #44","Graphics\\Windows\\Window_DebugLeft",nil,nil,nil,nil,nil,nil,nil,nil,nil], Window_DebugRight => [45,"Element #45","Graphics\\Windows\\Window_DebugRight",nil,nil,nil,nil,nil,nil,nil,nil,nil], } #Add more elements here NOE = 46 #NUMBER_OF_ELEMENT #Modify this number as more elements are added SSP = 500 #STARTING_SWITCH_POINT #Modify this number if script clash with other script(s)end 

And this is how the interpreter work.

#===============================================================================# Game Interpreter#===============================================================================class Game_Interpreter def window_off(i) $game_switches[i + Wndw_Cgr::SSP] = false window_default(i) end def window_on(i, name, type_movement = nil) $game_switches[i + Wndw_Cgr::SSP] = true $game_message.michael_wndw_bg_ary.each_value { |value| value[1] = "#{name}" if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = String(type_movement) if value[0] == i } if String(type_movement) == nil || 'show_all' || 'center' end def window_depth(i, depth) $game_message.michael_wndw_bg_ary.each_value { |value| value[3] = depth if value[0] == i } end def window_opacity(i, opacity) $game_message.michael_wndw_bg_ary.each_value { |value| value[4] = opacity if value[0] == i } end def window_default(i) $game_message.michael_wndw_bg_ary.each_value { |value| value[3] = nil if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[4] = nil if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = nil if value[0] == i } end def window_show_all(i) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'show_all' if value[0] == i } end def window_show_all_move(i, x, y) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'move' if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[6] = x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[7] = y if value[0] == i } end def window_move_origin(i,x,y) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'move_origin' if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[6] = x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[7] = y if value[0] == i } end def window_center(i) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'center' if value[0] == i } end def window_move_all(i, x, y, rect_x, rect_y, rect_width, rect_height) $game_message.michael_wndw_bg_ary.each_value { |value| value[5] = 'move_all'if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[6] = x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[7] = y if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[8] = rect_x if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[9] = rect_y if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[10] = rect_width if value[0] == i } $game_message.michael_wndw_bg_ary.each_value { |value| value[11] = rect_height if value[0] == i } endend lol, I still make it runs incrementally though.



You could consider aliasing Window#visible= so you have it automatically make the associated sprite's visibility match. The same thing could be done with #open, #close, #openness=, #x=, #y=, etc. However, since your script is not really laid out like that now, you could do the below instead, to avoid mixing methodologies or having to do a full rewrite, this is just another way to do it. Another reason I suggested breaking up the method in sprite is so you can separate out the functions that do specific things like this, so you can simply update the sprite's visibility without having to run that whole update thing.
Ah, thank you. I was thinking of creating a pointer, but then I'm not that familiar with the keyword, so I went for the alternative, which is the 'update' on all the scenes. I understand the risk, but I was stuck there. I tried to do the following.

#==============================================================================# Window_Base#==============================================================================class Window attr_accessor :oh_I_got_changed attr_accessor :michael_bg_vp attr_accessor :michael_bg_sp alias michael_Window_Base_initialize initialize alias michael_Window_Base_update update alias michael_Window_Base_dispose dispose def initialize(x, y, width, height) michael_Window_Base_initialize(x, y, width, height) self.oh_I_got_changed = false create_michael_bg_vp create_michael_bg_sp @michael_bg_sp.michael_sp_updt(self, $game_message.michael_wndw_bg_ary[self.class]) end def create_michael_bg_vp #Naming convention ftw self.michael_bg_vp = Viewport.new #The only locations where new member functions are created self.michael_bg_vp.z = self.z - 1 #are class Window_Base, class Sprite, module Cache end #and class Game_Interpreter. Everything else is aliased. def create_michael_bg_sp self.michael_bg_sp = Sprite.new end #Everything is disposed here def dispose #Basically every window made, self.michael_bg_sp.dispose #1 viewport and 1 sprite are also made self.michael_bg_vp.dispose michael_Window_Base_dispose end def did_I_get_changed? return self.oh_I_got_changed end def change_me_by_michael self.oh_I_got_changed = true end def update michael_Window_Base_update self.michael_bg_sp.michael_sp_updt(self, $game_message.michael_wndw_bg_ary[self.class]) end alias testing_123_visibility visible def visible self.michael_bg_sp.visible = testing_123_visibility if !self.michael_bg_sp.disposed? testing_123_visibility end alias testing_visibility visible= def visible=(arg) self.michael_bg_sp.visible = arg if !self.michael_bg_sp.disposed? testing_visibility(arg) end alias testing_123_x x def x self.michael_bg_sp.x = testing_123_x if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? testing_123_x end alias testing_x x= def x=(arg) self.michael_bg_sp.x = arg if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? testing_x(arg) end alias testing_123_y y def y self.michael_bg_sp.y = testing_123_y if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? testing_123_y end alias testing_y y= def y=(arg) self.michael_bg_sp.y = arg if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? testing_y(arg) end alias testing_123_width width def width if !self.michael_bg_sp.nil? self.michael_bg_sp.src_rect.width = testing_123_width if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? end testing_123_width end alias testing_width width= def width=(arg) self.michael_bg_sp.src_rect.width = arg if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? testing_width(arg) end alias testing_123_height height def height if !self.michael_bg_sp.nil? self.michael_bg_sp.src_rect.height = testing_123_height if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? end testing_123_height end alias testing_height height= def height=(arg) self.michael_bg_sp.src_rect.height =arg if $game_message.michael_wndw_bg_ary[self.class][5].nil? && !self.michael_bg_sp.disposed? testing_height(arg) endend 
And I ended up only finding that those classes properties aren't in object pointers, so I'm stuck there and resorting to the updates since I'm still not sure how the Window / Sprite classes scripted and how versatile can ruby be.

Edit:

On side note:

I also separate the sprite's method into multiple methods to make it more readable

Code:
class Sprite                                      #Another hidden script ftw!  def michael_sp_updt(window, i)    $game_switches[Wndw_Cgr::SSP + i[0]] ? michael_bg_on(window,i) : michael_bg_off(window, i)  end  def michael_bg_on(window, i)    michael_set_self_vp(window)    michael_save_wndw_opa(window) unless window.did_I_get_changed?    michael_clear_wndw_opa(window)    michael_set_self_ppts(window, i) #SET SELF'S PROPERTIES    michael_modify_self(window, i) unless i[5].nil?  end  def michael_set_self_vp(window)    self.viewport = (window.viewport) ? window.viewport : window.michael_bg_vp  end  def michael_save_wndw_opa(window)    @michael_wndw_b_opa = window.back_opacity unless window.back_opacity.nil?    @michael_wndw_opa = window.opacity unless window.opacity.nil?  end  def michael_clear_wndw_opa(window)    window.back_opacity = 0 unless window.back_opacity.nil?    window.opacity = 0 unless window.opacity.nil?    window.change_me_by_michael  end  def michael_set_self_ppts(window, i)    self.x = window.x    self.y = window.y    self.src_rect.width = window.width    self.src_rect.height = window.height    self.visible = ((window.openness == 255) && (window.visible))    #This is where picture is loaded    name = i[1]    folder = i[2]    self.bitmap = Cache.cache_extended(folder, name)    self.z += i[3] unless i[3].nil?    self.opacity = i[4] if (self.visible) && !(i[4].nil?)  end  def michael_modify_self(window, i)    case i[5]    when 'show_all'      self.x -= ((self.bitmap.width - window.width) / 2)      self.src_rect.x = 0 if self.x < 0      self.y -= ((self.bitmap.height - window.height) / 2)      self.src_rect.y = 0 if self.y < 0      self.src_rect.width = Graphics.width      self.src_rect.height = Graphics.height    when 'move'      self.x += (i[6] - ((self.bitmap.width - window.width) / 2))      self.src_rect.x = 0 if self.x < 0      self.y += (i[7] - ((self.bitmap.height - window.height) / 2))      self.src_rect.y = 0 if self.y < 0      self.src_rect.width = Graphics.width      self.src_rect.height = Graphics.height    when 'move_origin'      self.x += i[6]      self.src_rect.x = 0 if self.x < 0      self.y += i[7]      self.src_rect.y = 0 if self.y < 0    when 'center'      self.x = (Graphics.width - self.bitmap.width) / 2      self.src_rect.x = 0 if self.x < 0      self.y = (Graphics.height - self.bitmap.height) / 2      self.src_rect.y = 0 if self.y < 0      self.src_rect.width = Graphics.width      self.src_rect.height = Graphics.height    when 'move_all'      self.x = i[6]      self.y = i[7]      self.src_rect.x = i[8]      self.src_rect.y = i[9]      self.src_rect.width = i[10]      self.src_rect.height = i[11]    end  end  def michael_bg_off(window, i)    self.visible = false    window.oh_I_got_changed = false    if ((window.openness == 255) && window.visible)      window.back_opacity = @michael_wndw_b_opa unless @michael_wndw_b_opa.nil?      window.opacity = @michael_wndw_opa unless @michael_wndw_opa.nil?    end  endend 
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top