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.

Alias help

Im doing two things:

-Rewrite of entire method: Just write all the code again.
-To add something to a method: Alias the method and then call it before add nothing

Then, when you have to use the alias? is better than a rewrite? why?
 

Ares

Member

In general, you use alias if you want to add something to an already existing method, but don't want to edit the script that
method's in.

I'm not sure what you mean with this:
-To add something to a method: Alias the method and then call it before add nothing
but basicly alias works like this:
[rgss]class Something
 def initialize
  do_something
 end
end
 
 
class Something
 
alias new_initialize initialize
 
 def initialize
  new_initialize
  do_some_more
 end
end
 
[/rgss]

The script will first execute "do_something", and then "do_some_more"

If you'd post what you are trying to do, I could offer better help :)
 
Ares":1haf9l1b said:
In general, you use alias if you want to add something to an already existing method, but don't want to edit the script that
method's in.

I'm not sure what you mean with this:
-To add something to a method: Alias the method and then call it before add nothing
but basicly alias works like this:
[rgss]class Something
 def initialize
  do_something
 end
end
 
 
class Something
 
alias new_initialize initialize
 
 def initialize
  new_initialize
  do_some_more
 end
end
 
[/rgss]

The script will first execute "do_something", and then "do_some_more"

If you'd post what you are trying to do, I could offer better help :)


ok, this is what im talking, ok, then im doing it well, thanks
 

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