General Scripting Question...

Started by Heretic86, April 20, 2012, 03:52:25 am

Previous topic - Next topic

Heretic86

I wrote a script that I found I needed to fully redefine the entire method.  What I did works for the specific purposes I was aiming for, however, as a budding scripter, I'd like to make sure my scripts are as compatible with other scripts as possible.  It doest really matter what my script is, but what I'd like to know, in general, is doing a full redefinition of one of the default scripts a "bad" way to do smaller simpler scripts, or do you have any recommendations, like dont alias, or always alias, or never do full def rewrites, anything to that effect?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Blizzard

You should alias whenever possible to ensure maximum compatibility. If you need additional parameters in a function, you should then add default values so that other scripts using the previous definition of the method can still function normally when called without your additional parameters.

Sometimes methods need to be rewritten completely because their core functionality was changed. This is a situation where aliasing doesn't make not much sense since the previous code needs to be overwritten completely.

Basically you use aliasing when you want to "extend" the original code. If you have to rewrite it completely, alias doesn't help you.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Heretic86

WHen I get a chance this weekend, I wanna post an updated Screen_Z method that I wrote, which allows large sprites to render as Flat on the Ground.  Added some other stuff into it too, but just wanna see if you think it is worth while.  Have to do this weekend as I have to extract the code from another larger script im working on.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Calintz

i understand what an alias' does and how they're extremely useful, but i guess i'm having trouble knowing exactly what needs to be aliased. do you apply the alias to the class itself so that all methods of the class remain as is without changes, or do you alias the particular method from inside the class? i guess i'm asking because def initalize is used in EVERY window, so how do you alias an initialize method for a window that is a subclass without changing the original script?

Ryex

April 20, 2012, 05:48:21 am #4 Last Edit: April 20, 2012, 05:51:28 am by Ryex
you really should never alias an init method, if you need to then your probably better off making a subclass and using the super method. But, like every rule there are exceptions in thous cases alias still works like normal no special treatment needed. an alias only applies to the current scope or only the class in which it is used/all subclasses.
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

Calintz


Blizzard

I disagree. I've aliased the initialize method many, many times because that's what I needed. e.g. When I had to add a new parameter for actors, I added it in Game_Actor#initialize.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

I've done it various times as well, especially to Game_System or Game_Party when I'm adding new variables. Its not bad to alias the initialize method.

Heretic86

Wouldnt aliasing initialize make them More compatible with other scripts?  For example, you add a new property, but aliased init so another script that also aliases init to add a different new property allow for both additional scripts to have both of their new properties?  Not that much experience here so feel free to fill me in, but maybe I should ask why I shouldnt alias an initialize?  Maybe an example would help?
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

Blizzard

No, you're right about that. That's what G_G and me basically said. I think Ryex probably just confused it with another method. xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz