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

Author Topic: [Resolved] How to remove a class from a prototype  (Read 3429 times)

dmccollum

  • General Accounts
  • *
  • Posts: 29
    • View Profile
[Resolved] How to remove a class from a prototype
« on: Jan 16, 12, 04:40:45 PM »

While learning how to convert the E_ classes, I created a KIS_Account class and mistakenly created a prototype manually to the KIS_Account. I know now the control panel GUI automatically adds the ACCOUNT prototype once the KIS_Account class is added to the $ACCOUNT system node.

I've tried removing the prototype I created, but get an error message that it's tied to a class, how do you remove the unneeded prototype? Secondly, what happens behind the scenes when you have multiple prototypes assigned to a class? Is it harmless to leave the prototype there? Will the system know to write account data to the ACCOUNT prototype instead of the prototype I created?
« Last Edit: Nov 01, 12, 03:51:03 PM by HE-Cooper »
Logged

Extremo

  • General Accounts
  • *
  • Posts: 24
    • View Profile
Re: How to remove a prototype from a class
« Reply #1 on: Jan 16, 12, 04:47:46 PM »

I think what you mean is that you assigned the KIS_Account class to the $ACCOUNT System node? If so, you remove it with the following function:

http://hewiki.heroengine.com/wiki/GOM-_and_DOM-related_functions#RemoveClassFromPrototype

Code: [Select]
RemoveClassFromPrototype(className as String, node as Node Ref)
If you however mean you created a prototype then just go to your organizer panel and go to Server Prototypes and remove it? That is if you didn't delete the $ACCOUNT System node?

EDIT: The same goes for Client prototypes of course.

I know the error message you are speaking about. It occures when you try to delete a class from the DOM Editor when it is still being referenced to by the prototype. So, what you mean is assumably that you wish to remove the class from the prototype and not the other way around. That's achieved with the function I described first.

Regards,
Extremo.
« Last Edit: Jan 16, 12, 04:49:21 PM by Extremo »
Logged

dmccollum

  • General Accounts
  • *
  • Posts: 29
    • View Profile
Re: How to remove a class from a prototype
« Reply #2 on: Jan 20, 12, 06:48:59 AM »

Extremo, You're correct, I'm trying to remove the class from the prototype. Thank you for your response.

I'm still having problems trying to remove this class. So here's the details.

When I issue a \QP KIS_Account
Code: [Select]
QP LISTBEGIN 0 : "Prototype ID, Name, Description: "
QP LISTELEMENT 0 : "ID+9223372056340079778"
NAME="_KIS_AccountPrototype" DESCRIPTION="Prototype for KIS Account""
QP LISTELEMENT 0 : "ID=9223372056403664347"
NAME="KIS_Account_Prototype" DESCRIPTION="""
QP LISTEND 0 : "End of Prototypes"

Then I run a CMD script that has these two lines.
Code: [Select]
$GLOM._RemoveClassFromPrototype( "KIS_Account", $_KIS_AccountPrototype)
$GLOM._RemoveClassFromPrototype( "KIS_Account", $KIS_Account_Prototype)

I get the following error in the chat window and the class is not removed from the two prototypes.
Code: [Select]
[hsl_error] 1,1: [Character Selection] SCRIPT ERROR: Requested unglom on a prototype, but the node (9223372056526664324 is not a prototype.

Here's what I get when I query that node.
Code: [Select]
\sn 922337205652666324

SN LISTBEGIN 922337205652666324 : "Node ID: 922337205652666324 Base Class ID: 9223372056271750860 Name: "KIS_Account""
SN LISTEND 922337205652666324 : "End of List."
Logged

Extremo

  • General Accounts
  • *
  • Posts: 24
    • View Profile
Re: How to remove a class from a prototype
« Reply #3 on: Jan 20, 12, 07:05:10 AM »

Hey,

There's an easy fix for that really.

Just go on about something along these lines:

Code: [Select]
var prototype = getPrototype("_KIS_AccountPrototype")
var prototype2 = getPrototype("KIS_AccountPrototype")
RemoveClassFromPrototype("KIS_Account", prototype)
RemoveClassFromPrototype("KIS_Account", prototype2)

If that gives the equal error, then clearly something is wrong. Are you sure that the prototype you are referring to is really a prototype?

Also, I find a command much more convinient

Just create a command and use this code or alike.

Code: [Select]
shared function HE_ProcessCommandInput( account as NodeRef, input as String )

  args as List of String
  Tokenize( input, args )
  if args.length < 2 or args.length > 3
    HE_CommandUsage( account, input )
    return
  .
  if args.length == 3
    if ClassExists(args[3])
      var prototype = getPrototype(args[2])
      RemoveClassFromPrototype(args[3], prototype)
      Msg(account, "Successfully unglommed "+args[3]+" from Prototype: "+args[2])
    else
      HE_CommandUsage(account, input)
    .
  .
.

shared function HE_CommandUsage( account as NodeRef, input as String )
  // NOTE, this style is much more efficient on the client than doing a seperate Msg() for each line.
  // This is because only a single label gets created in chat, rather than one per line.
  msg as String = "/unglomclassfromprototype <prototype> <class>$R"
  msg = msg + " - Ungloms the specified Class from the Prototype$R"
  msg = msg + " - WARNING: Do not misspell the Prototype!$R"
  Msg( account, msg )
.

function Msg( account as NodeRef, msg as String )
  $CHAT.CHATPLAYER( account, "", msg )
.

If you're still having problems, please explain in a little more detail how you added the prototype. Thanks.

Regards,
Extremo.
Logged

dmccollum

  • General Accounts
  • *
  • Posts: 29
    • View Profile
Re: How to remove a class from a prototype
« Reply #4 on: Jan 20, 12, 12:48:56 PM »

Thanks again Extremo, but that didn't work either. It has been a few weeks since I created the prototypes, but I believe I used the cpfc command.
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: How to remove a class from a prototype
« Reply #5 on: Jan 20, 12, 01:10:21 PM »

Regarding the code
Code: [Select]
$GLOM._RemoveClassFromPrototype( "KIS_Account", $_KIS_AccountPrototype)
$GLOM._RemoveClassFromPrototype( "KIS_Account", $KIS_Account_Prototype)

That didn't work because when you use $ that creates or references an already created system node (which is a node created from a prototype, not a prototype itself).  You would need to get a noderef to the actual prototype like Extremo showed.  When you tried his code, what happened/printed out?

What is the output when you enter
\sp account
into the console?
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: How to remove a class from a prototype
« Reply #6 on: Jan 20, 12, 01:16:30 PM »

Also, for your _KIS_AccountPrototype and the other one, when you created it did you only do the cpfc and not add any other classes?

If so, then that prototype is natively of that class and so the class cannot be removed.  Removing constitutes "unglomming" and so only applies to classes that were glommed onto existing nodes.

Instead of removal, you should simply destroy those prototypes if you want them gone, as such:
\dp _KIS_AccountPrototype

However, they probably are harmless on their own.  There is no confusion to the system when using $ACCOUNT because that inherently refers to a prototype named "account".  Your prototypes are entirely separate nodes from that.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

dmccollum

  • General Accounts
  • *
  • Posts: 29
    • View Profile
Re: How to remove a class from a prototype
« Reply #7 on: Jan 20, 12, 01:59:02 PM »

Scott,

That worked. Thank you very much Scott and Extremo! Any tips on the proper way to create the prototypes for the E_ replacement stuff?
Logged

LastJudge

  • General Accounts
  • *
  • Posts: 215
    • View Profile
Re: How to remove a class from a prototype
« Reply #8 on: Jan 20, 12, 02:02:57 PM »

Scott,

That worked. Thank you very much Scott and Extremo! Any tips on the proper way to create the prototypes for the E_ replacement stuff?

The E_ prototypes don't really hold any important preset info I think, so just create a prototype from your class. At least that's what I did and everything seems to work.

the command is cpfc <class>, <prototype name>
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: How to remove a class from a prototype
« Reply #9 on: Jan 20, 12, 02:16:51 PM »

Well, for E_ classes that are glommed onto system nodes, those prototypes already exist; they just need a class glommed onto them with HE_ method definitions to override the default behavior.  Either modify those class scripts directly or make you own class like you did and replace the E_ class in the System Node Configuration GUI with your own class.
« Last Edit: Jan 20, 12, 02:18:30 PM by ScottZarnke »
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.