{"id":"cerebrallabs/cerebral","name":"cerebral","scope":"cerebrallabs","platform":"roblox","description":"A player state management tool","version":"0.0.4","latest":"0.0.4","versions":["0.0.1","0.0.2","0.0.3","0.0.4"],"license":"MIT","licenseRating":"safe","licenseCaveats":["The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{},"integrity":"c331a25a6f59b906621de27ef000f11d3792ce547cee842f4f7b864b803898a2","likes":0,"downloads":0,"install":"forest install cerebrallabs/cerebral","url":"https://forest.dev/p/roblox/cerebrallabs/cerebral","files":"https://api.forest.dev/ai/package/roblox/cerebrallabs/cerebral/files","readme":"<div align=\"center\">\n\n# Cerebral\n**Roblox Player State Management**\\\n*watch my data for me?*\n\n[About](#about) |\n[Supported Platforms](#supported-platforms) |\n[Use](#use) | \n[Road Map](#road-map)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n</div>\n\n> [!WARNING]\n> Cerebral is in its early stages and is **unstable**. **Do not use in production**\n\n## About\n**Cerebral** is a Roblox Player State Management Tool. This tool is created to make managing Player Data through the server as seemeless and error free as possible, so you can spend more time the fun stuff rather than wondering why your *Money* is not increasing.\n\n## Supported Platforms\n**Cerebral** is currently posted on [Wally](www.wally.run) under `cerebrallabs/cerebral`. Roblox Store support is planned.\n\n## Use\n### Set Up\n```luau\nlocal Players = game:GetService(\"Players\")\n\nlocal Cerebral = require(--[[path to Cerebral]])\n\nCerebral:DefineAgentAttributes({\n    \"money\" = Cereberal:Create(\"number\"),\n    \"xp\" = Cereberal:Create(\"number\"),\n    \"is_admin\" = Cerebral:Create(\"boolean\"),\n    \"pet_name\" = Cerebral:Create(\"string\"),\n})\n\nlocal function PlayerAdded(player: Player)\n    local agent: Cerebral.Agent\n    local playerData\n\n    agent = Cerebral:NewAgent(player)\n    playerData = -- Some dataStore getter function\n\n    Cerebral:NewAgent(player, playerData)\nend\n\nlocal function RemovePlayer(player: Player)\n    Cerebral:RemoveAgent(player)\nend\n\nPlayers.PlayerAdded:Connect(PlayerAdded)\nPlayers.PlayerRemoved:Connect(RemovePlayer)\n```\n\n### Use\nImagine a buy station.\n```luau\nlocal Cerebral = require(--[[path to Cerebral]])\nlocal proximitySensor = script.--[[path to proximitySensor]]\n\nlocal COST = 50\n\nproximitySensor.Triggered:Connect(function(player: Player)\n    local playerMoney = Cerebral:GetAgent(player):GetAttribute(\"money\")\n    if playerMoney:Get() >= COST then\n        playerMoney:Decrement(COST)\n        --[[award player whatever this proximitySensor is connected to]]\n    else\n        --[[notify user \"NOT ENOUGH MONEY]]\n    end\nend)\n```\n\n### Road Map\nIn no particular order:\n\n#### 1. Add migrations for `ds_data.data` to better allow for the transfer of data models. I want these to act similarly to how postgres migrates its databases. \n\nFor instance, if we wish to change the name of a attribute name, like `money` to `coins`, we would have the migration move the attribute to the new name upon the player joining the server. \n\nAdditionally, these migrations will (and must) be labeled cardinally. So when a player that has not logged on in a while, their data can migrate thorugh several migrations without breaking anything.\n\nExample:\n```luau\n-- migration 1\nCerebral:Migrate({version = 1}, function(oldData)\n    local newData = oldData\n    newData.ds_data.data.coins = oldData.ds_data.data.money\n    newData.ds_data.data.money = nil\n\n    return newData\nend)\n```\n\nNOTE: Cerebral should store migrations in the data store. Unsure how to go about this, but we want to raise all the flags if a migration is missing. \n\n#### 2. Create more secure default modules.\n\nTake a module that tracks `experience`. `experience` should never be able to decrease. The developer should know this, but adding additoinal protections, like:\n\n```luau\nCerebral:DefineAttributes({ \n    --                            Module Type | Options\n    \"experience\" = Cerebral:Create(\"number\", { protected = true }) \n})\n```\n\nwould be welcomed. Additionally, adding in the `options` functionality via a table supports forward thinking. ","readmeTruncated":false}