Jump to content

About components constructors


Rtd

Recommended Posts

Hi!

 

To make it simple : I just want to add a variable to the constructor of a component.

 

I don't think a ComponentPostInit will do the trick but I'm not sure if a ClassPostInit is appropriate here...

Then, I only see the require method...And in this case, what about the saving/loading of my variable between game sessions ?

 

Thank you very much!

Link to comment
Share on other sites

If all you want to do is add a variable to everyone using a certain component, componentpostinit will do. Saving/loading is trickier. If you're lucky the component doesn't already have a save/load function so you can just use the normal ones. If they do, I would suggest not altering those, instead you should create a new component that you can call from the old.

Link to comment
Share on other sites

Thank you Heavenfall!

But for what I'm trying to do (adding a variable to the temperature component), that seems to be a bit overcomplicated to me since the temperature component is used in a lot of different script locations (seasons for example)...so i have the feeling that is not the right way to do this...

Link to comment
Share on other sites

Ok, I'm sorry. I thought I was explicit enough.

 

So, for what I'm trying to do, I'm trying to modify the temperature component of the game.

Until now, I was just overriding the whole temperature component with my own in my mod folder, but I decided to go with the API and alter only what's need to be in the temperature component.

In my overrided (mod folder) temperature component, I had some variables that I added inside the class.

And now I need to be able to add them (inside the class) with the help of the API. That's where I'm stuck!

I need these variables to be added to the class because I'm using them in a lot of my overrided (PostInit) functions and they need to be saved/loaded with the instance.

 

I hope this time I make it more understandable! :D

Any help on this would be greatly appreciated. Thank you! :D

 

PS: And as I said in my last topic: I'm not (and by far) an expert in Lua nor DS mod scripting, and English is not my native language...So if you need some more explanations don't hesitate to ask me! Thank you! :D

Link to comment
Share on other sites

And that's it ? oO

 

Oh, Dear... xD

I was thinking this can't be so simple! xD

 

Thank very much Heavenfall! :D

 

(PS: I assume I have now to save/load them with OnSave/OnLoad functions if I'm not mistaken... ;) )

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...