Message to all Scripters using Alias

Started by fugibo, April 11, 2009, 05:55:50 am

Previous topic - Next topic

fugibo

Note that there is a way to fix the F12/One instance per script bug:

Instead of using

alias bluemage_update_old update
def update
  ...
  bluemage_update_old
end


You should use this (and make your name more specific if you can):

unless method_defined?(:tim_bluemage_update_old_xyz)
  alias tim_bluemage_update_old_xyz update
end

def update
  ...
  tim_bluemage_update_old_xyz
end


This will prevent you from re-aliasing the update code -- which causes it to call itself rather than the old code -- if it has already been aliased.

Just a quick tip ;)

Fantasist

Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews





fugibo

This isn't really all mine. Blizz/Zeriab have used this in a couple scripts before, but I'd thought I'd share with you to spread the knowledge :P

Blizzard

I avoid using it if I can. I only needed it for the shaded text thing. Since in Blizz-ABS there's an outline text thing, I needed to alias the original method only if Tons wasn't already present.
... Oh wait, I checked for Tons there. xD Anyway, I avoid using it. It seems kinda ruggish to me. What if somebody named a method the same, but it doesn't do the same? It's a bit risky and due to the high variety of RMXP scripts I'd rather have somebody report a "Stack level too deep" error, since I know what's going on, than a new random error which I can't figure out without checking out a demo. ._.;
It's sometimes very, very useful, though. Just be careful when you use it.
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

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.

tSwitch



FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: tSwitch.us | Twitter | Tumblr

fugibo

Yes, but this fixes that on its own, without assuming the user already has another script for it.

While it is rather useless, its good practice.

Blizzard

Loads of things are good practice, but most scripters don't do it. :(
Check out our game brands:

Daygames
Game Night Games
Chugnar Games

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.

fugibo

Most scripters only know the basics of programming, which is a sad fact. Heck, I only realized how horribly slow hashes and arrays in Ruby must be, after seeing the implementations from the C side (and ack, Ruby-style arrays are horribly hard in C! C++ has vectors though, so yippee :P)