Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: fugibo on April 11, 2009, 05:55:50 am

Title: Message to all Scripters using Alias
Post by: fugibo on April 11, 2009, 05:55:50 am
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 ;)
Title: Re: Message to all Scripters using Alias
Post by: Fantasist on April 11, 2009, 07:20:28 am
Nice one WcW :) *powers up*
Title: Re: Message to all Scripters using Alias
Post by: Reno-s--Joker on April 11, 2009, 07:25:40 am
:) This is really handy! Thanks!
*power up*
Title: Re: Message to all Scripters using Alias
Post by: fugibo on April 11, 2009, 07:49:34 am
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
Title: Re: Message to all Scripters using Alias
Post by: Blizzard on April 13, 2009, 03:38:35 pm
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.
Title: Re: Message to all Scripters using Alias
Post by: tSwitch on April 23, 2009, 11:06:44 am
Zeriab did make an F12 fix as well...
Title: Re: Message to all Scripters using Alias
Post by: fugibo on April 24, 2009, 05:31:57 pm
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.
Title: Re: Message to all Scripters using Alias
Post by: Blizzard on April 25, 2009, 05:33:49 am
Loads of things are good practice, but most scripters don't do it. :(
Title: Re: Message to all Scripters using Alias
Post by: fugibo on April 25, 2009, 08:29:35 am
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)