|
| 01 Apr 2014 01:14 PM |
I am really confused with DataStore and how it saves, what it saves and how it loads, could anyone help me?
But first let me take a selfie |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 02:23 PM |
bump
But first let me take a selfie |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:43 PM |
burmp
But first let me take a selfie |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:44 PM |
it's basically a long list of a key string and value which you can use to access data
and it's much more robust than data persistence
i'm asian |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:46 PM |
yes but what save? Would you use IntValues/BoolValues? I'm confused by it or is it the key that saves?
But first let me take a selfie |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:48 PM |
You get the DataStore from pts = game:GetService("DataStoreService"):GetDataStore("Points")
the key is generally used for player identifiers and the value is obviously the value
i'm asian |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:50 PM |
Okay here's my code:
level = Instance.new("IntValue") xp = Instance.new("IntValue") mana = Instance.new("IntValue")
stats = game:GetService("DataStoreService"):GetDataStore("stats")
function playerConnect(player) if player:IsA("Player") then repeat wait() until player.DataReady level.Parent = player xp.Parent = player mana.Parent = player end end
game.Players.PlayerAdded:connect(playerConnect)
I just need to know do I save the IntValues to DataStore and how. Or do I create 'values'? But first let me take a selfie |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:52 PM |
stats:SetAsync(key, value) and use different data stores for different stats
i'm asian |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 01 Apr 2014 03:53 PM |
Consider it as a cabinet that has a lot of information in it
local datastore =game:GetService"DataStoreService":GetDataStore("NAMEOFDATASTORE") ^ That tells you which cabinet to look in, and it gives you the cabinet
now
local stuff=datastore:GetAsync("NameOfItem") -- This is like a key to opening the cabinet. Now you got the object you want and you can do whatever you want with it
datastore:SetAsync("NameOfItem", "Potato") --Tis opens up the cabinet, takes out everything inside that section, and replaces it with the second thing, i.e. "Potato" in this case
datastore:UpdateAsync("NameOfItem", function(old) return newvalue end) --This takes out the cabinet info, modifies it according to the function, and replaces it with the modified version
Hope this helped |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:53 PM |
So I would not need the IntValues?
But first let me take a selfie |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:54 PM |
The current code:
stats = game:GetService("DataStoreService"):GetDataStore("stats")
function playerConnect(player) if player:IsA("Player") then repeat wait() until player.DataReady stats:SetAsync("mana", 0) end end
game.Players.PlayerAdded:connect(playerConnect)
is this correct?
But first let me take a selfie |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 01 Apr 2014 03:56 PM |
You save the VALUE of the intValue
stats = game:GetService("DataStoreService"):GetDataStore("stats") --This is only a cabinet. You need to open the cabinet with a certain "Key" to get certain information.
function playerConnect(player) if player:IsA("Player") then repeat wait() until player.DataReady
local level = Instance.new("IntValue") local xp = Instance.new("IntValue") local mana = Instance.new("IntValue")
level.Parent = player xp.Parent = player mana.Parent = player level.Value = stats:GetAsync(player.Name.."Level") xp.Value = stats:GetAsync(player.Name.."XP") mana.Value = stats:GetAsync(player.Name.."Mana")--Like this end end
game.Players.PlayerAdded:connect(playerConnect) |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 03:58 PM |
Would I not set it then get it? :l
But first let me take a selfie |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 01 Apr 2014 03:59 PM |
| No, setting would overwrite the current data stored in the DataStore. |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 04:00 PM |
Okay.
But first let me take a selfie |
|
|
| Report Abuse |
|
|
|
| 01 Apr 2014 04:10 PM |
| http://www.roblox.com/Global-DataStore-item?id=151263580 |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2014 10:14 AM |
I'm now confused with UpdateAsync()
What's "function(old) return newvalue end"
But first let me take a selfie |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 02 Apr 2014 11:48 AM |
:UpdateAsync("Potato", function(old) return old+15 end)
This would take the number stored in "Potato", add 15 to it and save it. |
|
|
| Report Abuse |
|
|
KOzero
|
  |
| Joined: 11 May 2010 |
| Total Posts: 1411 |
|
|
| 02 Apr 2014 11:56 AM |
| Bump,Going to check this thread later. |
|
|
| Report Abuse |
|
|
Kingmouli
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 1292 |
|
|
| 02 Apr 2014 11:57 AM |
| Why is it named old? Like script.Parent.Touched:connect(function(hit) you name it hit because it's the thing that touched it. But old? |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 02 Apr 2014 11:59 AM |
The old value that was stored in the DataStore
|
|
|
| Report Abuse |
|
|
|
| 02 Apr 2014 12:11 PM |
@wazap So I'm doing it right?
Shrek is love shrek is life. |
|
|
| Report Abuse |
|
|
|
| 02 Apr 2014 12:12 PM |
Owait, thought this was another thread hoooldddd on:
-----Saving Code----- game.Players.PlayerRemoving:connect(function(player) local level = player.Lvlle local xp = player.ExpP stats:UpdateAsync(xp, function(old) return xp.Value end) stats:UpdateAsync(level, function(old) return xp.Value end) -- Is this right? end) -----END-----
Shrek is love shrek is life. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 02 Apr 2014 12:13 PM |
| idk what you're doing so I cant say anything. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 02 Apr 2014 12:14 PM |
game.Players.PlayerRemoving:connect(function(player) local level = player.Lvlle local xp = player.ExpP
stats:UpdateAsync(xp, function(old) return xp.Value end) stats:UpdateAsync(level, function(old) return level.Value end) -- Is this right? end)
Ya that looks right. |
|
|
| Report Abuse |
|
|