How do I get the ruby-class of Game_Actor?

If you created a new project and made a script call

p $game_actors[1].classIt will return "Soldier" instead of "Game_Actor"Evidently this is because Game_Actor overwrites `class`...

How do I get the ruby-class name?

Well, beyond doing this

Code:
class Game_Actor < Game_Battler    alias :th_rmxml_class :class  def class    if $XML_EXPORT      return Game_Actor    else      return th_rmxml_class    end  endend
Well, this seems to work

Code:
class Object  alias :klass :classend
Now you can just access `klass` instead and avoid running into issues with Game_Actor.
Code:
$game_actors[1].actor.class
??? I seem to remember having to do something a bit weird like this. Don't have time to test it now though.
$game_actors[1].actor.class??? I seem to remember having to do something a bit weird like this. Don't have time to test it now though.
It will return RPG::Actor
Seems to be the right code then 🙂


Unless you really wanted it to return Game_Actor Hime, and not RPG::Actor?
Yes, I want it to return "Game_Actor" instead of "Soldier", which is the name of the actor's in-game class.
yeah, the best I can come up with is RPG::Actor which is the class of $game_actor[id].actor
A solution that doesn't define a new method:

Object.instance_method🙂class).bind($game_actors[1]).call # => Game_ActorEdit: Simplified a bit.
That's pretty creative: calling something else's class method just to get around the fact that Game_Actor changed it.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-get-the-ruby-class-of-game_actor.32504/