memcallen Posted June 11, 2016 Share Posted June 11, 2016 How do I make my component save its data? It can hold data but after a re-log its variable are back to their defaults. Link to comment https://forums.kleientertainment.com/forums/topic/68081-making-component-save-its-data/ Share on other sites More sharing options...
Arkathorn Posted June 11, 2016 Share Posted June 11, 2016 Component persistent data functions are as follows: function ComponentName:OnSave() --Return a table containing data that you want to be persistent --For example: local data = {} data.someinfo = self.someinfo return data end function ComponentName:OnLoad(data) --The 'data' parameter is the table that you returned from 'OnSave' --Load your data back here --For example: if data.someinfo then self.someinfo = data.someinfo end end Link to comment https://forums.kleientertainment.com/forums/topic/68081-making-component-save-its-data/#findComment-782268 Share on other sites More sharing options...
Mobbstar Posted June 11, 2016 Share Posted June 11, 2016 @memcallen The above code should suffice for most situations. If you need to, you can use Pre-Load and Load-Post-Init as well, but they behave slightly different. Ideally refer to existing components for that. Link to comment https://forums.kleientertainment.com/forums/topic/68081-making-component-save-its-data/#findComment-782329 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now