|
| 14 Oct 2014 08:06 PM |
I'm using datastore currently to store a table of values
I set the datastore as something like "1, 3, 2" and then I create a table like this
table = {datastore:GetAsync(whatever)}
however, it counts the ENTIRE datastore as one string, so when I print #table, it returns 1 no matter how many commas.
Is there a way I could make the script detect commas to separate the different things from eachother, so that when I return #table, it returns the actual number of things there are in the table? |
|
|
| Report Abuse |
|
|
|
| 14 Oct 2014 08:07 PM |
for _,Value in pairs(Table:GetChildren()) do Value:SetAsync() end
for _,Value in pairs(Table:GetChildren()) do Value:GetAsync() end
|
|
|
| Report Abuse |
|
|
|
| 14 Oct 2014 08:19 PM |
| That would work if I'm setting a value FROM a table, but I'm GETTING a table from a datastore. |
|
|
| Report Abuse |
|
|
Locard
|
  |
| Joined: 13 Apr 2014 |
| Total Posts: 3516 |
|
|
| 14 Oct 2014 08:30 PM |
tab = {1,2,3}
datastore:SetAsync("data",tab)
then to retrieve it...
local new = datastore:GetAsync("data")
print(new[1]) >> 1
print(new[3]) >> 3
print(new[4]) >> nil
The problem with that is that you wouldn't be able to have mixed data in the table. In that case, you would use a dictionary. |
|
|
| Report Abuse |
|
|