|
| 29 Sep 2014 01:21 PM |
Does Data Persistence save to universes (the whole game) or only the individual place? I really don't want to have to use DataStores for my place... ROBLOX says they're "more powerful and robust", but if you can't save Instances with them, they're completely useless. |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 29 Sep 2014 01:22 PM |
"if you can't save Instances with them" no, can i have a reason why that makes them useless? please i honestly never see the point in saving instances anyway |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 29 Sep 2014 01:26 PM |
@ 1st reply Ever Play sandbox?
There is a way around not being able to save instances. Save the necessary data (brick size position ect) and recreate the Instance with those values. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2014 01:28 PM |
What, do you expect me to do for i,v in pairs(object:children()) do DataStore:SaveAsync(v.Name,{v.Size,v.Position,v.Name,v.BrickColor}) end ? That'd be really awful to have do that... |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 29 Sep 2014 01:29 PM |
| Well if you REALLY need to save an instance across a game universe, this is the ONLY way to do it. |
|
|
| Report Abuse |
|
|
lokkut
|
  |
| Joined: 18 Mar 2009 |
| Total Posts: 1794 |
|
|
| 29 Sep 2014 01:31 PM |
| Immac, you could just not save an instance. If you tell me what you're doing it for I'll help. |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 29 Sep 2014 01:31 PM |
| Example of why- In sandbox games, people build stuff, save it and rejoin the game and continue working on it. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2014 03:41 PM |
Sandbox uses Data Persistence iirc. If it doesn't, I have no idea how he's capable of saving configurations in the glass and stuff. He probably just saves one little string telling the game to make that type of block when it reloads -- if he's even using datastores. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2014 03:45 PM |
Also, I know I COULD just save a number and then create an IntValue and then change its value to the saved number for every single thing I'm saving.
That's a very sloppy and roundabout way of doing it, though.
It'd be so much easier if I could just put everything inside of one Instance and then save that Instance to the DataStores, then reload that Instance, put it in a player, and have all the values stored there already!
Creating ten new instances and changing their values manually for each number key saved is terrible. |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2014 03:53 PM |
Well, now I just have to save this table and then load it later.
It's a huge pain and I really shouldn't have had to do this, but I did it anyway. It only saves the properties of parts and string/number/int etc. values, since that SHOULD be all I need it to save.
function propsConvert(instances,recursive) local returnTab={} local function scan(theThing) for _,Inst in pairs(theThing) do local tab={} tab["Name"]=Inst.Name tab["ClassName"]=Inst.ClassName if Inst:IsA("BasePart") then tab["FormFactor"]=Inst.FormFactor tab["CanCollide"]=Inst.CanCollide tab["Anchored"]=Inst.Anchored tab["Shape"]=Inst.Shape tab["Size"]=Inst.Size tab["CFrame"]=Inst.CFrame tab["Transparency"]=Inst.Transparency tab["Material"]=Inst.Material tab["BrickColor"]=Inst.BrickColor tab["TopSurface"]=Inst.TopSurface tab["BottomSurface"]=Inst.BottomSurface elseif Inst.Name:find("Value") then tab["Value"]=Inst.Value end returnTab[#returnTab+1]=tab if recursive and #Inst:children()>=1 then scan(Inst) end end end if type(instances)=="table" then scan(instances) elseif type(instances)=="userdata" then local Inst=instances local tab={} tab["Name"]=Inst.Name tab["ClassName"]=Inst.ClassName if Inst:IsA("Part") then print'its a part' tab["BrickColor"]=Inst.BrickColor tab["TopSurface"]=Inst.TopSurface tab["BottomSurface"]=Inst.BottomSurface tab["FormFactor"]=Inst.FormFactor tab["Size"]=Inst.Size tab["CFrame"]=Inst.CFrame tab["Transparency"]=Inst.Transparency tab["Material"]=Inst.Material tab["Anchored"]=Inst.Anchored tab["CanCollide"]=Inst.CanCollide tab["Shape"]=Inst.Shape elseif Inst.Name:find("Value") then tab["Value"]=Inst.Value end return tab end return returnTab end
function instFromProps(convertedProps,parent) for _,v in pairs(convertedProps,true) do ypcall(function() local Inst=Instance.new(v.ClassName,parent) for i,prop in pairs(v) do print(i,prop) Inst[i]=v[i] end end) end end |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 29 Sep 2014 04:12 PM |
| In order to stay under that data limit, make it one string. |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 29 Sep 2014 04:13 PM |
| request limit is what I meant |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2014 05:04 PM |
You DO stay under the data limit; you're saving a table with all the data inside if you do it this way.
This is everything I wrote; it's completely finished now and it works for me. You save propsConvert used preferably with recursive on and on an object's children to a datastore. Then you use GetAsync again on the key you saved it to, if the key exists, you do InstFromProps on the saved datastore and parent the instance(s) wherever you want. You can't save parents since you can't guarantee how the object will load; and you might end up trying to put it in a parent that's not loaded yet or doesn't even exist.
function propsConvert(instances,recursive) local returnTab={} local function scan(theThing) for _,Inst in pairs(theThing) do local tab={} tab["Name"]=Inst.Name tab["ClassName"]=Inst.ClassName if Inst:IsA("Part") then tab["FormFactor"]=Inst.FormFactor tab["CanCollide"]=Inst.CanCollide tab["Anchored"]=Inst.Anchored tab["Shape"]=Inst.Shape tab["Size"]=Inst.Size tab["CFrame"]=Inst.CFrame tab["Transparency"]=Inst.Transparency tab["Material"]=Inst.Material tab["BrickColor"]=Inst.BrickColor tab["TopSurface"]=Inst.TopSurface tab["BottomSurface"]=Inst.BottomSurface elseif Inst:IsA("IntValue") or Inst:IsA("StringValue") or Inst:IsA("NumberValue") or Inst:IsA("BoolValue") then tab["Value"]=Inst.Value end returnTab[#returnTab+1]=tab if recursive and #Inst:children()>=1 then scan(Inst) end end end if type(instances)=="table" then scan(instances) elseif type(instances)=="userdata" then local Inst=instances local tab={} tab["Name"]=Inst.Name tab["ClassName"]=Inst.ClassName if Inst:IsA("BasePart") then print'its a part' tab["BrickColor"]=Inst.BrickColor tab["TopSurface"]=Inst.TopSurface tab["BottomSurface"]=Inst.BottomSurface tab["FormFactor"]=Inst.FormFactor tab["Size"]=Inst.Size tab["CFrame"]=Inst.CFrame tab["Transparency"]=Inst.Transparency tab["Material"]=Inst.Material tab["Anchored"]=Inst.Anchored tab["CanCollide"]=Inst.CanCollide tab["Shape"]=Inst.Shape elseif Inst.ClassName=="StringValue" or Inst.ClassName=="IntValue" then tab["Value"]=Inst.Value end return tab end return returnTab end
function instFromProps(convertedProps,parent) for _,v in pairs(convertedProps,true) do ypcall(function() local Inst=Instance.new(v.ClassName,parent) for i,prop in pairs(v) do Inst[i]=v[i] end end) end end |
|
|
| Report Abuse |
|
|