RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP] Class Inheritance, Im missing something...

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 70
RMRK Junior
Besides my mind, I lost that a long time ago...

I created a new property for objects created inside class Game_Character, and that seems to be working just fine and dandy, but Im trying to offer a 2nd way to do the same thing by using an events name.  Regular Expression.  That is working just fine as well. 

What I came to the conclusion of is I need to do the same thing I did to Game_Character inside Game_Event < Game_Character.  Game_Event inherits properties and methods defined inside Game_Character, super has already been called.  But I cant seem to figure out why I cant access the property that was defined and inherited from _Character inside the inheriting class?

Yes, I am using attr_accessor :new_property in Game_Character, so how come I cant read that property in Game_Event?
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I think I'm going to have to see the code to be able to help, since I don't see any problem with what you described. Ie. I think you are saying the arrangement is like this:

Code: [Select]
class Game_Character
  attr_accessor :new_property
  alias heretic86_initialz_newpr_2km3 initialize
  def initialize(*args, &block)
    @new_property = 0
    heretic86_initialz_newpr_2km3(*args, &block)
  end
end

class Game_Event
  alias hertic_initiz_5mx6 initialize
  def initialize(*args, &block)
    hertic_initiz_5mx6(*args, &block)
    p new_property # <- That will be defined as 0
  end
end

That is what you have described and that would work fine. The only thing I can think of is that is not what you intended to describe and I misinterpreted, so please show me the code which you are saying does not work.

***
Rep:
Level 70
RMRK Junior
That is exactly what I thought I was doing.  Alias and all.  Only difference I see is class Game_Event and mine is class Game_Event < Game_Character.  Oh wait, crap, I think I just figured it out.  In your example, wouldnt I still access new_property with @new_property with having the @ symbol (as defined above)?

edit:  Dammit!  I changed event.new_property (event was being passed as an arg in initialize) to @new_property and works fine now.  Ok I feel stupid.  Your example actually completely helped!
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!