Jump to content

Saving player data and shard migration


Recommended Posts

I always seem to run into issues when it comes to saving data in DST because of the dang caves *shakes fist at server migration*. This time the mod is a server mod, and I need to save player-specific data. The data are boolean values, numbers, and tables of variable length (max of 30) which contain strings and numbers. 

What I was doing at first was saving the data server-side in a master table. I'd create a slot in the master table when a new player joins using their userid as the identifier, convert the table of strings to numbers, send this to the player via bytearray, then convert the numbers back into strings client-side. But then I remembered that the caves have their own data, and if the player migrated to the caves, they'd get a different set of data. If there's a way to share data between shards, this would be preferable, but I'm not sure how you'd do that. 

So then I started thinking about saving the data directly on the player. ModRPCs are pretty limited in the amount of data they can send as far as I know, but I could maybe communicate a seed to the server, and the server can reconstruct the table based on the seed, but then I'd have to create a custom and costly lua-based random function since lua's default randomseed() is ultimately based on the operating system, so the tables may be inconsistent depending on the OS that DST is running on. 

To summarize, I have a table of strings and a table of numbers that both the server and client need to know about. The client needs to know because it needs to create and update a client-side widget based on these tables. The server needs to know because it needs to tinker with server-side data based on the tables. And I need the tables to be saved/loaded and work with migration. 

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
 Share

×
  • Create New...