- I'm playing a game
- I save the game (I plan on using the game.onsave() event to know when to store the data)
- I close Factorio
- Open it back up later
- Load the save game
- The variable that I stored is still there for access
Persistant Data
Persistant Data
Is there any way to store persistent data?
"F**k thy hater"
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com
Re: Persistant Data
Anythin in the glob table is "automagically" saved and loaded for you. It works for plain data (integers, strings, tables, etc.) as well as for factorio objects (lua entity, lua technology, etc.). I would avoid storing functions in there.
Re: Persistant Data
That's useful. I've been storing all my functions there!slpwnd wrote:Anythin in the glob table is "automagically" saved and loaded for you. It works for plain data (integers, strings, tables, etc.) as well as for factorio objects (lua entity, lua technology, etc.). I would avoid storing functions in there.
"F**k thy hater"
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com
Re: Persistant Data
In theory it should work for some simple functions. However it will fail for things like closures and generated functions. You can actually check the file called script.dat in the save directory. It contains the serialized state of the script. There are some binary data now and there but most of it should be readable and "lua-code" like.zer0t3ch wrote:That's useful. I've been storing all my functions there!
Re: Persistant Data
Just looked at it. Doesn't look very friendly!slpwnd wrote:In theory it should work for some simple functions. However it will fail for things like closures and generated functions. You can actually check the file called script.dat in the save directory. It contains the serialized state of the script. There are some binary data now and there but most of it should be readable and "lua-code" like.zer0t3ch wrote:That's useful. I've been storing all my functions there!
"F**k thy hater"
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com
Re: Persistant Data
May I ask what advantages you expect when you store your functions in the glob table?
Re: Persistant Data
I had no clue what to expect, I just thought that was how you're supposed to do it...drs9999 wrote:May I ask what advantages you expect when you store your functions in the glob table?
"F**k thy hater"
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com
-George Watsky
Feel free to contact me!
Skype: Zer0t3ch
Razer Comms: Zer0t3ch
Email: zer0t3ch@live.com