Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Aliasing Update

Status
Not open for further replies.

Mac

Member

Okay well i dont usually do this, but i've ran into a wall and can't find my way around it...but how would you alias an update method, i've tried doing the usual aliasing way of:-

Code:
class name
def update
alias window_whatever_upda update
OLD CODE HERE
whatever_window_upda
NEW CODE
end

But it doesn't seem to work and brings forward a Object error.

Thank you

~Mac
 
Aliases are supposed to be in the class definition not inside the method. And you don't have to rewrite the old code again.

Code:
class name
  alias window_whatever_upda update
  def update
    whatever_window_upda
    NEW CODE
  end
end
 

Mac

Member

Code:
class Window_Message < Window_Selectable
  alias message_window_init initialize
    def initialize
    message_window_init
      @message = Sprite.new
      @message.bitmap = RPG::Cache.picture('Message')
      @message.y = self.y
      @message.x = self.x
      @message.visible = true
    end
  end
  
class Window_Message < Window_Selectable  
  alias message_window_upda update
    def update
       message_window_upda
        @frame.visible = self.visible
      end
     end

Ok it's having problems with visible =, i'm guessing because it needs more code.
 
Aliases aren't a block. There's an extra "end" in your code.
Code:
class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias message_window_init initialize
    def initialize
    message_window_init
      @message = Sprite.new
      @message.bitmap = RPG::Cache.picture('Message')
      @message.y = self.y
      @message.x = self.x
      @message.visible = true
    end
[COLOR=Red]#  end[/COLOR]
  
  alias message_window_upda update
    def update
       message_window_upda
        @frame.visible = self.visible
      end
 

Mac

Member

This topic has been resolved. If Mac or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top