1 Screenshot

About This File

A module that can store, save, and load any arbitrary data.

For developers only! Don't expect it to do anything interesting in-game.

Download contains:

persistentdata.lua - The module. Put this in your mod's scripts folder.

PersistentDataExample_v1.x.zip - Example usage of the module with comments

See the example for information on how to use it.

Mods that currently use it:

Mod Manager - by Blueberrys

Feats of the World - by debugman18

Previously posted here.

Everything provided here is public domain. No warranties for anything. Blah blah blah. Use it however you want!

Attribution would be appreciated, but is not required.


What's New in Version 1.2   See changelog

Released

  • Corrected mod link in description (whoops)
  • Like 2



User Feedback

Recommended Comments

This does not seem to work from Worldgen, as there is no TheSim. I would have to load the information in modmain in the main menu screen and somehow shove it past the Sim reset, but I can't think of any way to do this (other then maybe writing a temporary txt somehow).

Share this comment


Link to comment
Share on other sites

I worked around the aforementioned issue like this, should anybody be interested:

--modmain
local file = assert(io.open("temp-myfile.txt", "w")) --TODO write to mod directory instead of maingame data folder
file:write(json.encode(GLOBAL.MyTable))
file:close()

--modworldgen
local t
local file = io.open("temp-myfile.txt", "r")
if file then
	t = json.decode(file:read()) or {}
	file:close()
else
	t = {}
end

Share this comment


Link to comment
Share on other sites

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