|
| 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
|
  |
 |
| 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
|
  |
| 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
|
  |
 |
| 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
|
  |
| Joined: 29 Mar 2011 |
| Total Posts: 32902 |
|
| |
|
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
|
  |
 |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|