SimpleData - A compact DataStore portal

Hi, I’m Finster (FinsterHorizon), and today I’ll introduce you to my first public module, SimpleData.

NOTICE: SimpleData is still currently in a very early state, and everything is subject to change, however I assure you updates should never affect any scripts.

What is SimpleData?

SimpleData is a new module I’ve made to make using Datstores easier for people ( and totally not just for me since I can never remember how to use them )

What does it do?

SimpleData includes 2 straightforward features, .Save() and .Load()

As you can tell, these simply allow you to Save and Load from DataStores.

How do I use it?

At the top of the Module, you’ll see:


SimpleData.StoreKey = "YourDataStoreHere1" -- Put the DataStore you want to save to here!

This will be the only setting in here that you need to change, I advise you change it immediately, as if you wish to have multiple SimpleData nodules, it would be awful for them to overlap with one another.

Under the SimpleData module is the readme script, this contains information such as pre-made data formats for SimpleData and support information (Support info is currently only my username since I’m writing this post right now, will be updated in 1.1)

Format for loading data:

local SimpleData = require(SimpleDataLocation)
	local playerData = SimpleData.Load("PLAYER")
	
	if playerData then
	print(playerData.Cash)
	print(playerData.Points)
	else
		return nil
	end

“PLAYER” can be specified by adding player to the end of your PlayerAdded function, like this:

local SimpleData = require(SimpleDataLocation)
Players.PlayerAdded:Connect(function(player)
local playerData = SimpleData.Load(player)
	if playerData then
	print(playerData.Cash)
	print(playerData.Points)
	else
		return nil
	end
end)

Format for saving data:

local SimpleData = require(SimpleDataLocation)
SimpleData.Save("PLAYER", {Coins = 100, Points = 5})

You’ll need to specify the values being saved. (Again, “PLAYER” can be specified, however it needs to use Players.PlayerRemoving instead of Players.PlayerAdded)

Well, where do I get it??

Here!

It’s available now! What are you waiting for? Try it out!

Remember to submit any/all bugs to this post.

2 Likes

SimpleData 1.1 Release

Yep, I did it.

SimpleData 1.1 is now available, you can simple insert the new updated module into your game from the same model.

Again, you can get it here

New Features:

  • Instant Value Resets [.Reset()]
  • Backup Datastore [.Backup()]

SimpleData now also includes Data Migration to other DataStores!
You can find the mirgration module “SimpleDM” under SimpleData.ExtraAssets.SimpleDM

Automatic Update Detection

Yes, SimpleData now has automatic update detection.

It works via a simple detection from a JSON file on my Github.
If the UpdateGetter detects that you’re using an outdated version, it will alert you in the Output / Developer console.

How do I use these new features?

Just like before, these are very straightforward

Let’s start with .Reset()

.Reset() is a feature especially good for components like rebirths or whatever you call them in your game.

The .Reset() function is one of the only things you’ll need to edit in the SimpleData module.

Scroll down to the function, and you’lll see:

local defaultData = { Coins = 0, Points = 0 } -- Define your default values here

This is where you’ll need to put in all the values that will be reset when the .Reset() function is called.

As all other functions, you will need to specify the key (the player)

Now let’s go onto .Backup()

.Backup() is just .Save(), however this will be sent to a seperate datastore in the case that you somehow lose data from your main datastore.
NOTE: SimpleData WILL NOT call .Backup() automatically!

The usage for .Backup() should be the same as .Save()
You will also be able to customise your backup datastore key, however the default “BackupStore1” should be sufficient enough in my opinion.

Data Migration Feature

I don’t really ever see why you would need this, however if you want to, you can use this freely provided module to migrate your data.

To make things easier, I have added a pre-made shortcut into the main SimpleData module called .Migration, which will simply reroute you to the SimpleDM module.
(This is under the Do not modify section)

In SimpleDM, you will need to specify your new key and your old one:

DataMigration.NowStoreKey = "PlayerData"
DataMigration.OldStoreKey = "PlayerData_v1" -- Example of an old datastore key

The NowStoreKey is the store we’re migrating to, the OldStoreKey is the store we’re migrating from.

After that, id say it’s a good idea to have your join functions call the .Migratefromold() function for the player in the SimpleDM script.

As said before, please report any bugs or give feedback in the comments of this post.

I hope you’ll enjoy 1.1

Hey guys, dropping in quickly to say that SimpleData will be getting a full recode soon to make the code more understandable and allow me to add features more easily.
I assure you that all features with be named the same so that you will not need to change your scripts, as they should blend in seemlessly.

This also means no updates to the module for a few days, so just stay posted.