HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Class extension question  (Read 1136 times)

Alderdale

  • World Owners
  • ****
  • Posts: 12
    • View Profile
[Resolved] Class extension question
« on: May 25, 12, 12:31:03 PM »

I inserted the following code in the HE_PostCharacterActivated method in the E_Account class script:

$CHAT.ChatArea("game", "You have entered the game world")

When logging in it was printed to the Chat window and screen as expected

As a test I then made a "data" archetype server side class whos parent is E_Account

I then inserted the follow code in its script

method HE_PostCharacterActivated( theAccount as NodeRef )
 
$CHAT.ChatArea("game", "ME FIRST  ME FIRST")
.

My understanding is that this would be a way to overide what happens in the E_Account class HE_PostCharacterActivated method unless you were also executing:

parentClass::HE_PostCharacterActivated(theAccount)

then it would just be more like in addition too.

My question is when simply logging into the game what would prompt HeroMachine to use my method over the one that exists in E_Account other than removing E_Account from the SYSTEM ACCOUNT and adding my class instead.

I made this post after following plusfourgames excellent character activation tutorial (which all parts worked except it wouldnt call my over ride method.  So I made this very simple example of that part of the tutorial to try to understand why it didnt work.

Any input would be appreciated.


-Alder



« Last Edit: Nov 01, 12, 10:42:50 AM by HE-Cooper »
Logged

TGSRofar

  • General Accounts
  • *
  • Posts: 153
    • View Profile
Re: Class extension question
« Reply #1 on: May 25, 12, 04:53:33 PM »

The only way the method in your class will be called is if you assign it to the system node. However, you do not have to remove E_Account.  You can just add yours on top of that.  If your class implements everything that is already in E_Account (or at least everything you want to implement) then you can remove E_Account.
Logged
Ron Farrell
Lead Programmer
Triad Game Studios

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Class extension question
« Reply #2 on: May 25, 12, 09:53:58 PM »

Right.  As the code is in standard form, it has E_Account glommed on the account system node, which is unaffected by the fact that there is some class defined which inherits from it.  Note, however, that you would need to remove E_Account in order to add yours if they both define the same method, else that would cause a conflict.  Of all classes glommed onto a node, only one of them may define a given method at-a-time.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Alderdale

  • World Owners
  • ****
  • Posts: 12
    • View Profile
Re: Class extension question
« Reply #3 on: May 27, 12, 01:42:37 PM »

Very nice that really cleared some things up for me, thanks for the replies.
Logged

Alderdale

  • World Owners
  • ****
  • Posts: 12
    • View Profile
Re: Class extension question
« Reply #4 on: May 28, 12, 11:40:07 PM »

~Solved~

My class overides started working today with no changes to code, so Im just happy with that, the other problem for the account counter tut was that my labelCounter object was not directly under the "scrollable" tree in the XML  protype object and was nested under one if its children.
Logged