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.

[Resolved] Aliasing and defining (short and simple question about rgss p...)

Status
Not open for further replies.
Are there any flaws for defining everything instead of using aliases?

I know aliasing is quicker to do, it's just a general wondering.
 

khmp

Sponsor

You mean what's the difference between:
Code:
class Stuff
  def do
     p 'true'
  end
end
Code:
class Stuff
  alias old_do do
  def do
     old_do
     p 'false'
  end
end
And just redefining a method:
Code:
class Stuff
  def do
    p 'true'
  end
end
Code:
class Stuff
  def do
    p 'false'
  end
end
?
 
No I mean defining not redefining.

With aliases I can can modify an existing script without over writing any of the methods for which I am aliasing, whereas if I wanted to write a script from scratch without aliasing I would need to define everything, for example

Code:
class Game_Map
  alias krypt_gmap update
  
  def update
    krypt_gmap
    if Input.trigger?(Input::R)
      $scene = nil
    end
  end
end
I have edited Game_Map to be able to shutdown upon pressing a key, I used alias as to not overwrite the existing update method in the class, whereas if I want to.. say write a script to add colors I would have to define every new color.

So I want to know the difference between aliasing to write the new feature and writing script from scratch.

From
Code:
class Game_Map
To
Code:
class Shutdown

They both will do the same thing but I was wondering if there are any benefits or flaws to using each way of writing a script (except lenght of time writing it), I hope you understand
 

khmp

Sponsor

If they both do the same thing why change it? Is this some kind of joke?  ;D

Ok I think I understand what you mean.

The benefit would of course be compatibility with other scripts. But if this isn't what you're asking I'm at a lost.

Good luck with it kryptonator! :afro:
 
I know. I just wanted to know if there was a flaw to writng a script in the way the default ones are wrote i.e no aliasing to the way user ones are written i.e aliased.

All of the default scripts don't contain aliased methods but most of the user submitted ones do, I want to create my scripts and write them as if they are default scripts rather than alias to edit an existing class so was just wondering if there would be flaws to my way of scripting.
 
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