Coder Social home page Coder Social logo

miagobble / greedydataservice Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 54 KB

A datastore solution that simplifies the player data management workflow

Home Page: https://www.igottic.com

License: MIT License

Lua 100.00%
datastore greedy luau roblox saving leaderstats

greedydataservice's Introduction

GreedyDataService

A datastore solution that simplifies the player data management workflow

About

GreedyDataService is a simple module that allows you to easily edit player data from any server scope without any substantial datastore cooldowns (this is thanks to boatbomber's HeatUp module).

Highlighted features:

  • Simplicity; ability to easily get and edit user data, even if they are not in the server
  • Scalability; use in both your personal and professional projects
  • Automation for leaderstats; it can easily create leaderstat values for you, and updating the leaderstats value objects will thus update the values internally and still save (for those who use this workflow!)
  • Readability; the API is readable and easily understandable, allowing the developer(s) to quickly adjust to it
  • Session locking; prevent those pesky data exploits/bugs!

So, why should I use this over other data solutions?

I want to emphasize the ease of use for this resource. It's simplicity is unrivaled, you will not find an easier data management system.

Many data management modules require more setup, meaning you become the one responsibile for managing datastore limits, setup structure, sanity checking, etc. With GreedyDataService, all of that friction is lifted; simply intialize a player's data session with one line of code, which, if you want, also manages the public leaderstats values you see in the player list.

I made this resource because it feels like a huge waste of time setting up data management code with other resources. This module satisfies my needs and speeds up development!

Example script

local playersService = game:GetService("Players")

local greedyDataService = require(script.Parent.GreedyDataService)

local function playerAdded(player : Player)
	local leaderstatsSession = greedyDataService:loadPlayer(player)

	leaderstatsSession.data.Money = 1000 -- Sets "Money" to 1000
	leaderstatsSession:set("XP", 500) -- Sets "XP" to 500
	-- leaderstatsSession.data.whatever = value is the
	-- same as leaderstatsSession:set("whatever", value)

	-- For the rest of this, instead of using methods, I'll index .data

	leaderstatsSession.data("Joins", function(lastNumberOfJoins)
		return lastNumberOfJoins + 1
	end) -- Increments "Joins" by 1

	-- You can also do leaderstatsSession.data.Joins += 1

	if leaderstatsSession.data.Status == "new" then
		-- If a player is new, then say they are a rookie
		leaderstatsSession.data.Status = "rookie"

	elseif leaderstatsSession.data.Joins > 10 then
		-- If they joined more than 10 times, they are a visitor!
		leaderstatsSession.data.Status = "visitor"

	elseif leaderstatsSession.data.Joins > 100 then
		-- Wow, over 100 visits! They are now a regular.
		leaderstatsSession.data.Status = "regular"
	end

	print(leaderstatsSession:get("Status"))
	-- Prints "rookie", "visitor", or "regular"

	print(leaderstatsSession.data.Status)
	-- Should print the same thing again!

	table.insert(leaderstatsSession.data.Inventory, `DailyReward#{leaderstatsSession.data.Joins}`) -- Add something to a table
	print(leaderstatsSession.data.Inventory) -- Will get bigger every time you join!
end

for _, player in playersService:GetPlayers() do
	playerAdded(player)
end

playersService.PlayerAdded:Connect(playerAdded)

☝️ Key takeaway: local leaderstatsSession = greedyDataService:loadPlayer(player) was the only line of code needed to load and initialize the data.

Installation

There are currently two ways to install this: Wally and Roblox File

Wally

Keep an eye! This is coming to Wally soon.

Roblox File

You can download the Roblox file by going to releases.

More Info

⚠️ This is a new resource and may be unstable. Let me know about any issues!

  • Feel free to forward any suggestions or ideas to the replies section of the DevForum post.
  • Read the API Documentation to learn about how to use this.
  • The License describes the permissions of this resource.

Here is an uncopylocked example place to help you understand this more! Below is the YouTube video walking you through this:

https://www.youtube.com/watch?v=ZhlR9H6GX2M&feature=youtu.be

Patreon

If you appreciate this resource, please consider subscribing to my Patreon page for $1 a month! Everything helps and I mega-appreciate it 💖

greedydataservice's People

Contributors

miagobble avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.