|
| 20 May 2017 02:14 PM |
| How would you save an Instance using Data Store? It used to be so much easier using Data Persistence. |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 May 2017 02:28 PM |
You totally can, but it's not easy.
Basically, you've got to store all the relevant information about the instances. How much is relevant is up to you and the solution you're trying to implement.
E.g. if you want to save a part, you might want to save this information: ClassName, CFrame, Size, BrickColor, Material, the player who created it.
Unfortunately you can't save UserData to DataStores. Basically this means that you have to convert all of these to either tables, strings or numbers.
ClassName needs to be a string CFrame can be a table of numbers (12, IIRC) Size can be a table of 3 numbers BrickColor can be a number or a string (number is better for performance and latency, but strings are easier to understand) Same with Material Player can NOT be the name of the player. It has to be their UserID, because players can change their name at any time.
Okay so an example "part table" could look like this:
partTable = { ClassName = "Part", CFrame = {1###,##,##,##,#####,##,#####,##,##}### Size = {10, 10, 10}, BrickColor = 50 -- or whatever BrickColor.Palette(50) is Material = 2 -- or whatever Enum.Material:GetEnumItems[2] is Creator = 12356123 -- or an actual valid UserID }
You could save this to DataStores as is. You obviously need to write a function that does all of this for you, so that you can save any part. Different Classes have different properties with different data types. If converting any datatypes to a savable type is a problem, feel free to ask follow up questions. |
|
|
| Report Abuse |
|
|
|
| 20 May 2017 02:29 PM |
"You totally can"
No, you can't.
|
|
|
| Report Abuse |
|
|
| |
|
Bit_blox
|
  |
| Joined: 28 Aug 2016 |
| Total Posts: 974 |
|
|
| 20 May 2017 02:34 PM |
dire dont bother arguing with Unsub its no use
- Hello world - |
|
|
| Report Abuse |
|
|
|
| 20 May 2017 02:34 PM |
You can't save tables or userdata in data stores and everything else is converted to a string. You can't save instances but you can save information about them.
|
|
|
| Report Abuse |
|
|
|
| 20 May 2017 02:35 PM |
I implied that tables aren't converted to JSON when saved. I didn't mean to.
|
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:07 PM |
Dude if you opened a studio save file in notepad or whatever, you'd see that it's just XML. Instances are XML. XML can be turned into a table. Tables can be saved to datastores. So instances can be saved to datastores. |
|
|
| Report Abuse |
|
|
Narqwhal
|
  |
| Joined: 24 Apr 2011 |
| Total Posts: 301 |
|
|
| 20 May 2017 04:08 PM |
Not exactly. Saving data and recreating an instance is not the same as saving the instance itself. Kind of like teleportation would work with us, not the same person between each TP. :P
scripters.cf |
|
|
| Report Abuse |
|
|
| |
|
Narqwhal
|
  |
| Joined: 24 Apr 2011 |
| Total Posts: 301 |
|
|
| 20 May 2017 04:10 PM |
Sorry to hear that. Either way, easy way to prove they ain't the same, print their memory location, not the same.
scripters.cf |
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:11 PM |
direMitten, you don't know what you're talking about. Of course you can save the XML string, but who the hell would do that? That's one of the dumbest things I've seen said today.
Instances in ROBLOX are userdata. Userdata is a data type in Lua that ROBLOX data stores do not support. The same thing goes with tables. Tables themselves are not saved; they are converted to JSON automatically and saved as a string. When retrieved, the tables are also reconverted from JSON to an actual Lua table.
Instances can not be saved to data stores.
|
|
|
| Report Abuse |
|
|
Narqwhal
|
  |
| Joined: 24 Apr 2011 |
| Total Posts: 301 |
|
|
| 20 May 2017 04:11 PM |
Wait, you can't do that, that's just for functions. SAME THING. Not the same.
scripters.cf |
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:14 PM |
| I'm not arguing about how DataStore work. I'm making a point that your distinction between *being able to save a table representing an Instance* and *being able to save a table* is moot. It's nothing more than semantics. |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 20 May 2017 04:14 PM |
You cant directly save instances but you can save their properties and load their properties.
#Code for i,v in pairs do repeat end. |
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:15 PM |
And that's precisely because you don't seem to understand how they work. Saving an instance is different from saving information about an instance and somehow you can't understand that. There IS a distinction.
|
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:16 PM |
Like I said, it's not a question about how Roblox works. It's a matter of what you mean when saying "to save an instance".
|
|
|
| Report Abuse |
|
|
lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
|
| 20 May 2017 04:17 PM |
"And that's precisely because you don't seem to understand how they work. Saving an instance is different from saving information about an instance and somehow you can't understand that. There IS a distinction."
a distinction without any practical difference |
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:18 PM |
Then don't be so vague next time. Not everybody thinks the same as you do. However:
"Tables can be saved to datastores. So instances can be saved to datastores."
Is an incorrect statement, regardless of interpretation.
|
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:18 PM |
"a distinction without any practical difference"
Try saving an instance and then try saving information about the instance. Tell me there isn't a difference.
|
|
|
| Report Abuse |
|
|
Narqwhal
|
  |
| Joined: 24 Apr 2011 |
| Total Posts: 301 |
|
|
| 20 May 2017 04:19 PM |
Unsub. is right, end of the story. Back to helping people, everyone...
scripters.cf |
|
|
| Report Abuse |
|
|
lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
|
| 20 May 2017 04:23 PM |
"Try saving an instance and then try saving information about the instance. Tell me there isn't a difference."
an instance is just a physical manifestation of information in a table
loading an instance would be loading the table itself loading information about an instance would be loading the information inside the table (and then putting that information into a new instance)
??? |
|
|
| Report Abuse |
|
|
|
| 20 May 2017 04:25 PM |
This is exactly why you shouldn't be here. Userdata can't be saved in data stores.
|
|
|
| Report Abuse |
|
|
lagio2
|
  |
| Joined: 11 Mar 2010 |
| Total Posts: 4001 |
|
|
| 20 May 2017 04:26 PM |
"This is exactly why you shouldn't be here."
>ad hominem
"Userdata can't be saved in data stores."
ok true ill back off now |
|
|
| Report Abuse |
|
|