generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: DataStore for inventory

Previous Thread :: Next Thread 
Mariofanlollipop is not online. Mariofanlollipop
Joined: 15 Jul 2011
Total Posts: 569
21 Mar 2014 02:06 PM
I need one and it seems there are none in freemodels yet. I am still very unfamiliar with datastore, and I need help. The wiki is useless.
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
21 Mar 2014 02:16 PM
This data store is much easier to work with for something like an inventory. You can just dump the inventory table directly into the data store and it will serialize it for you:

local Inventory = {
Planks = 5;
Nails = 10;
Rope = 6;
}

local DataStore = game:GetService('DataStoreService'):GetDataStore('SomeName')

local PlayerEntryPrefix = 'PlayerData$'
DataStore:SetAsync(PlayerEntryPrefix..player.userId, Inventory)

-- loading

local Inventory = DataStore:GetAsync(PlayerEntryPrefix..player.userId)
if not Inventory then
Inventory = {}
end
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
21 Mar 2014 02:23 PM
someone explain what the all -ighty -ollar ($) is doing there. it is a part of teh string, yes, but why to add it?
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
21 Mar 2014 02:30 PM
Separator so it's easy to read for debugging. Normally an underscore would be my go-to, but separating usernames in a string from something else my go-to is a $, because underscores can often show up in usernames.
Report Abuse
Trioxide is not online. Trioxide
Joined: 29 Mar 2011
Total Posts: 32902
21 Mar 2014 02:31 PM
Thanks
Report Abuse
MettaurSp is not online. MettaurSp
Joined: 20 Mar 2010
Total Posts: 3179
21 Mar 2014 04:58 PM
I would personally go with ':' or '|'. They seem more visually friendly for separation to me.
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
21 Mar 2014 05:02 PM
I would avoid ":" or "|".

":" implies that there's some sort of a key-value association there, as opposed to "$" implying that the two pieces have been sort of "concatenated" to form a single identifier. Same thing for "|".

Really what you want is more of a concatenator than a separator, but you also want it to be easy to see the two separate parts. I think that "$" is one of the only good choices for what to use.
Report Abuse
MettaurSp is not online. MettaurSp
Joined: 20 Mar 2010
Total Posts: 3179
21 Mar 2014 05:07 PM
What about '&'? It can be used in the place of 'and' in plain English and while reading the key, it can be interpreted as 'Stats' and username/ID (or whatever other values are put in the key).
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
30 Jul 2014 08:50 PM
Sorry to bump an old thread however, does anyone know if stravant's method count's towards data limit each time you want to retrieve something from the table?
Report Abuse
VoltiCoil is not online. VoltiCoil
Joined: 20 Nov 2008
Total Posts: 1227
30 Jul 2014 10:27 PM
anyone?

_________________________________________________________________________________________They said it couldn't be done, I proved them wrong.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image