HeroEngine Forums

HeroEngine Support => Scripting & Programming => Topic started by: Demi101 on Jul 14, 12, 07:43:24 PM

Title: [Resolved] need some help on persistent objects and classes
Post by: Demi101 on Jul 14, 12, 07:43:24 PM
Could someone please explain or point me to the correct wiki page, tutorial or whatever as to what I need to do to get a class I have created to attach to an object and stay persistent?

I have been going in circles trying to get my class functional outside of adding it manually every time I log in.

Thanks
Title: Re: need some help on persistent objects and classes
Post by: Trixer on Jul 17, 12, 04:33:53 PM
As far as I understand you need to make sure its added to the prototype.

http://wiki.heroengine.com/wiki/Prototype

If my understanding serves me correctly you can think of this as a prefab, or if your a coder just a class.. its the base of what other "nodes" in your world are created from.

Meaning that if you want something to stay persistently needs to be part of the prototype.. I think.. dont qoute me... only have HE for 48 hours, but that is my understanding thus far!
Title: Re: need some help on persistent objects and classes
Post by: FI-ScottZ on Jul 17, 12, 05:37:02 PM
Is the node you are adding the class to persistent?

Are you adding a client or server class?
Title: Re: need some help on persistent objects and classes
Post by: Demi101 on Jul 18, 12, 06:09:54 PM
Originally I was using /mnfc <classID> which is not persistent. I then tried issue a cli command /cnfc; +persistent but when i exited the node did not save. I then read that I needed to make association so I made a hard association but again it failed to save.

I am unsure wheather I need to make proto or do this from script every time it loads so I am just looking for where to go to study.
Title: Re: need some help on persistent objects and classes
Post by: HE-JAY on Jul 20, 12, 09:50:17 AM
Could someone please explain or point me to the correct wiki page, tutorial or whatever as to what I need to do to get a class I have created to attach to an object and stay persistent?

I have been going in circles trying to get my class functional outside of adding it manually every time I log in.

Thanks

Can you provide a more specific use case? There are many ways in which you can persist data (http://hewiki.heroengine.com/wiki/Data_storage_options), and there are several ways to create a node from a particular class or add a class to an already persistent node (http://hewiki.heroengine.com/wiki/Node_Persistence) (http://hewiki.heroengine.com/wiki/Nodes_and_Classes).

In order for a node to get loaded in from the database, it must either be hard-associated (http://hewiki.heroengine.com/wiki/Associations) to a root node (such as the area root, account root, character root) or it must be an arbitrary root node (http://hewiki.heroengine.com/wiki/Arbitrary_Root_Node).
Title: Re: need some help on persistent objects and classes
Post by: Trixer on Jul 20, 12, 10:00:49 AM
https://community.heroengine.com/forums/index.php/topic,2650.0.html

This is a very good tutorial, that will get you started in understanding exactly what you want to do.