Kain Nobel
Member
Good day everybody!
Although I'm somewhat familiar with 'self.method_defined?()', or in other words I've at least seen it used, I was curious whats the proper way to use it, or what are the different ways it can be used? For instance, I always see people checking the alias name of a method instead of the origional name of the method, why is that? Are they checking if an alias from a previous script exists? I've never seen another scripter just checking for the origional method, I always see just an alias name being checked so I'm unsure.
Simply, what I'm trying to do is prevent overwritting SDK::Scene_Base methods in my scenes where, the method isn't by default defined, and its unclear if it would need to be aliased or not.
So, if I was to create 'main_window' for Scene_Gameover (since it, by default, doesn't use any windows it isn't created), how would I be sure that I'm not overwritting some other code somewhere previous to that call? Can I freely alias a superclass method, such as when Scene_Gameover inherits from the SDK::Scene_Base?
How do I work that situation, am I supposed to do something like...?
I'm just asking because, although I've seen it used, I don't know exactly how it works and I'm learning more about superclasses too.
Although I'm somewhat familiar with 'self.method_defined?()', or in other words I've at least seen it used, I was curious whats the proper way to use it, or what are the different ways it can be used? For instance, I always see people checking the alias name of a method instead of the origional name of the method, why is that? Are they checking if an alias from a previous script exists? I've never seen another scripter just checking for the origional method, I always see just an alias name being checked so I'm unsure.
Simply, what I'm trying to do is prevent overwritting SDK::Scene_Base methods in my scenes where, the method isn't by default defined, and its unclear if it would need to be aliased or not.
So, if I was to create 'main_window' for Scene_Gameover (since it, by default, doesn't use any windows it isn't created), how would I be sure that I'm not overwritting some other code somewhere previous to that call? Can I freely alias a superclass method, such as when Scene_Gameover inherits from the SDK::Scene_Base?
How do I work that situation, am I supposed to do something like...?
Code:
class Scene_Gameover < SDK::Scene_Base
 alias_method :exampl_scn_gmover_main_window, :main_window
 def main_window
  if self.method_defined?(:main_window)
   exampl_scn_gmover_main_window
  end
  # ...New code...
 end
end
I'm just asking because, although I've seen it used, I don't know exactly how it works and I'm learning more about superclasses too.