How do I get the ruby-class of Game_Actor?

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
$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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Seems to be the right code then :)


Unless you really wanted it to return Game_Actor Hime, and not RPG::Actor?
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Yes, I want it to return "Game_Actor" instead of "Soldier", which is the name of the actor's in-game class.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
yeah, the best I can come up with is RPG::Actor which is the class of $game_actor[id].actor
 

cremnophobia

Veteran
Veteran
Joined
Dec 10, 2013
Messages
216
Reaction score
97
Primarily Uses
A solution that doesn't define a new method:

Object.instance_method:)class).bind($game_actors[1]).call # => Game_ActorEdit: Simplified a bit.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
That's pretty creative: calling something else's class method just to get around the fact that Game_Actor changed it.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,865
Messages
1,017,059
Members
137,574
Latest member
nikisknight
Top