Roblox icon indicating copy to clipboard operation
Roblox copied to clipboard

DataStore2.Combine by default in 2.0.0 (with settings for existing users)

Open Kampfkarren opened this issue 6 years ago • 5 comments

This is something that wasn't born until after it was seen to be an issue without, but new developers won't realize how necessary this is and not do it. Perhaps introduce DataStore2.Uncombine for the opposite, or just tell developers that were using DataStore2 before to just disable the settings. Also introduce a setting for a master key.

Kampfkarren avatar Jul 23 '19 22:07 Kampfkarren

Is there a migration guide somewhere?

visskiss avatar Jul 24 '19 14:07 visskiss

Not yet, though I should write one before starting work on this.

If you're making a new game/making new data, all you should need to do is write at the top: DataStore2.Combine("DATA", "yourKeyHere")

So if you were adding coins to your game, at the top (ideally soon after requiring DataStore2), you'd write: DataStore2.Combine("DATA", "coins")

For existing games, I do want to write a way to transfer uncombined data to combined data stores.

Kampfkarren avatar Jul 24 '19 21:07 Kampfkarren

Idea for migration: introduce a DataStore2.MigrateUncombined or something in a global configuration that'll add the following overhead to initial :Get calls:

  • When calling :Get() with no data, check the combined data store first
  • If there's no data in the combined data store, call Get on the uncombined data store
  • If the was data in the uncombined data store, mark the data store as needing to save (so when they leave it saves into the combined data store)

This is what users have to do already to migrate their data from an uncombined store to a combined one, so it helps for it to be native. Explicit opt in because we don't want to give this overhead to anyone who already have combined data stores set up correctly.

Kampfkarren avatar Sep 10 '19 05:09 Kampfkarren

Sorry for posting this here, but I have no other way of contacting you. For some godforsaken reason the roblox devform won't make me a new user even after like a week of browsing the forums and doing everything I can, including emailing support. So I can't post there at all. ):

I digress. Since Combine is not yet automatic, I was wanting to make it automatic for my personal uses so as to not have to call Combine a trillion times. I'm a veteran programmer, but very new to lua and it's quirks and metatables, so my plan is to simply create a wrapper function that calls DataStore2() then DataStore2.Combine() on the key just created, then return DS2() as normal. But I was wondering how I could elegantly check if a "key" exists, so I don't run Combine each time a player joins and a new DS2() is called for that player of the same "key". Any help or solution? Thank you and sorry again for posting this here, you can feel free to remove this.

Cabledragon avatar Nov 07 '19 18:11 Cabledragon

It's fine to call Combine as much as you want. It doesn't do anything other than say "If you see this key, you're going to be doing it a different way". Not sure what the question is.

Kampfkarren avatar Nov 07 '19 22:11 Kampfkarren