- Joined
- May 15, 2012
- Messages
- 14,682
- Reaction score
- 3,003
- First Language
- Tagalog
- Primarily Uses
- RMVXA
So, there are people telling us to avoid using evals because they are slow... One suggestion was to use Procs, but I don't like them or well, I can't understand them to a usable level. So I have made this alternative to using evals to run user defined things (which is much abundant to my extension scripts for example).
module ADIK module LANTHANUM_BATTLE module ENEMY_AS def self.action_normal(user) #Do things here end def self.action_mage(user) #Do things here end #add more methods as necessary TAG = /<enemy_as
.*)>/ end endend $dactb[:enemy_as] = ADIK::LANTHANUM_BATTLE::ENEMY_AS class Scene_LanthanumBattle alias set_up_enemy_command_as set_up_enemy_command def set_up_enemy_command(user) sym = $1.to_sym if user.note =~ $dactb[:enemy_as]::TAG return $dactb[:enemy_as].method(sym).call(user) unless sym.nil? return set_up_enemy_command_as(user) end end
So now, you're running methods directly rather than using eval
then on the notebox, you'd just put something like
<enemy_as:action_normal>
instead of putting what action_normal would be doing inside of the notebox then using eval on it.
So, is it better than using eval?
module ADIK module LANTHANUM_BATTLE module ENEMY_AS def self.action_normal(user) #Do things here end def self.action_mage(user) #Do things here end #add more methods as necessary TAG = /<enemy_as
So now, you're running methods directly rather than using eval
then on the notebox, you'd just put something like
<enemy_as:action_normal>
instead of putting what action_normal would be doing inside of the notebox then using eval on it.
So, is it better than using eval?
