A way to store client-side persistent data for addons

HTML5 added something called web storage. It allows web applications to save arbitrary string data on the client browser. It’s size per site is limited to 5 MB.

My suggestion would be to add something similar for addons, so we can save e.g. shared preferences across servers. Size could be limited in the same way, or maybe even less. This should be all abstracted away to a simple key-value based system.

Use cases:

  • Storing addon preferences locally that can be used across servers
  • Sharing some state between independent servers (e.g. dupes, wiremod scripts, etc…)

To address potential storage size issues:

  • Size per addon would be limited to 5MB or less
  • Total storage size can be limited, it would auto-purge when that limit is exceeding starting by the oldest accessed data
  • Addon storage could be auto-purged when the addon gets uninstalled

Could be even integrated with Steam cloud if anyone needs that…

Can’t you just write a .json file to save data like Pac3 and Wiremod do already?

1 Like

In gmod, there’s already a clientside SQLite database and filesystem that is used for storing settings, clientside data, dupes, whatever. Presumably S&Box will have such functionality as well.

It would make sense though to allow per-addon DB table/virtual filesystem usage if you need it to protect from other addons reading/writing your addon data (imagine a fun workshop addon that has a backdoor that sniffs your dupes and sends them to a 3rd party server, not very fun).

A possibility to read and write globally accessible data should also be left as an option for when it’s needed.


it would make more sense to make it server-based (and a global storage with opt-in) than addon based when we store something on the client so the client has more controll over who has access to which files


Yes, but that’s completely impractical. If I’m creating a basic addon, why would I want to manually serialize and deserialize JSON data on the filesystem? Why not have a system where you simply provide the game with the values you want to save, and the game figures out the rest?

If complex addons want more control over their data, they can roll their own system, but there should be built in support for simple data saving and loading.

1 Like