Jump to content

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!

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.

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...

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...